3 //=============================================================================
5 * @file XML_Backing_Store.h
7 * This class defines an implementation of the backing store as a single XML file.
9 * @author Darrell Brunsch <brunsch@cs.wustl.edu>
10 * @author Priyanka Gontla <gontla_p@ociweb.com>
12 //=============================================================================
14 #ifndef XML_BACKING_STORE_H
15 #define XML_BACKING_STORE_H
17 #include "ace/config-lite.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "Locator_Repository.h"
27 class ACE_Configuration
;
28 class ACEXML_FileCharStream
;
29 class ACEXML_DefaultHandler
;
32 * @class XML_Backing_Store
34 * @brief XML backing store interface containing all ImR persistent information
38 class XML_Backing_Store
: public Locator_Repository
41 typedef std::pair
<ACE_CString
, ACE_CString
> NameValue
;
42 typedef std::vector
<NameValue
> NameValues
;
43 XML_Backing_Store (const Options
& opts
,
45 bool suppress_erase
= false);
47 virtual ~XML_Backing_Store ();
49 /// indicate the XML filename as the persistence mode for the repository
50 virtual const ACE_TCHAR
* repo_mode () const;
52 /// create the Server_Info server object
53 /// @param info the source Server_Info data
54 /// @param server_started indicates if the server object
55 /// existed when data was persisted
56 /// @param extra_params extra name value pairs that
57 /// were reported for the server
58 virtual void load_server (Server_Info
*info
,
60 const NameValues
& extra_params
);
62 /// create the Activator_Info activator object
63 /// @param activator_name the Activator_Info name
64 /// @param token the Activator_Info token
65 /// @param ior the Activator_Info ior
66 /// @param extra_params extra name value pairs that
67 /// were reported for the activator
68 virtual void load_activator (const ACE_CString
& activator_name
,
70 const ACE_CString
& ior
,
71 const NameValues
& extra_params
);
73 /// perform XML backing store specific initialization
74 /// (loads servers and activators from the backing store)
75 virtual int init_repo (PortableServer::POA_ptr imr_poa
);
77 /// perform server persistent update
78 virtual int persistent_update (const Server_Info_Ptr
& info
, bool add
);
80 /// perform activator persistent update
81 virtual int persistent_update (const Activator_Info_Ptr
& info
, bool add
);
83 /// perform persistent remove
84 virtual int persistent_remove (const ACE_CString
& name
, bool activator
);
86 /// load the contents of a file into the repo using a Locator_XMLHandler
87 /// @param filename the filename to read the contents from
88 /// @param open_file the already open FILE stream for the
90 int load_file (const ACE_TString
& filename
, FILE* open_file
= 0);
92 /// load the contents of a file into the repo using the provided
93 /// ACEXML_DefaultHandler
94 /// @param filename the filename to read the contents from
95 /// @param xml_handler the ACEXML_DefaultHandler to use to parse
97 /// @param debug the current debug level
98 /// @param open_file the already open FILE stream for the
100 static int load_file (const ACE_TString
& filename
,
101 ACEXML_DefaultHandler
& xml_handler
,
103 FILE* open_file
= 0);
105 /// persist the server
106 /// @param fp the FILE stream to persist the server contents to
107 /// @param info the Server_Info to persist
108 /// @param tag_prepend a character string to prepend at the start
109 /// of every xml line to maintain proper indentation
110 /// @param name_values extra name value pairs to write as attributes
111 void persist(FILE* fp
,
112 const Server_Info
& info
,
113 const char* tag_prepend
,
114 const NameValues
& name_values
= NameValues());
116 /// persist the activator
117 /// @param fp the FILE stream to persist the activator contents to
118 /// @param info the Server_Info to persist
119 /// @param tag_prepend a character string to prepend at the start
120 /// of every xml line to maintain proper indentation
121 /// @param name_values extra name value pairs to write as attributes
122 void persist(FILE* fp
,
123 const Activator_Info
& info
,
124 const char* tag_prepend
,
125 const NameValues
& name_values
= NameValues());
127 /// create the Server_Info server object
128 /// @param server_started indication from persistence indicating if the
129 /// server object was present
130 /// @param si the server info in question
131 void create_server(bool server_started
, const Server_Info_Ptr
& si
);
134 /// the filename indicated in the Options for the backing store
135 const ACE_TString filename_
;
138 /// persist all servers and activators
142 #endif /* XML_BACKING_STORE_H */