1 karl 1.14 //%2003////////////////////////////////////////////////////////////////////////
|
2 mike 1.2 //
|
3 karl 1.14 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
|
7 mike 1.2 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
9 kumpf 1.9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
12 mike 1.2 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
|
15 kumpf 1.9 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
16 mike 1.2 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
18 kumpf 1.9 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
21 mike 1.2 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 //
|
24 kumpf 1.9 //==============================================================================
|
25 mike 1.2 //
26 // Author: Nag Boranna (nagaraja_boranna@hp.com)
27 //
|
28 kumpf 1.3 // Modified By: Sushma Fernandes, Hewlett-Packard Company
29 // (sushma_fernandes@hp.com)
|
30 kumpf 1.4 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
31 mike 1.2 //
32 //%////////////////////////////////////////////////////////////////////////////
33
34
35 ///////////////////////////////////////////////////////////////////////////////
36 //
37 // This file defines the classes necessary to manage configuration properties
38 // specified on the commandline and configuration files for Pegasus.
39 //
40 ///////////////////////////////////////////////////////////////////////////////
41
42 #ifndef Pegasus_ConfigManager_h
43 #define Pegasus_ConfigManager_h
44
45 #include <cctype>
|
46 mday 1.8 #include <stdlib.h>
|
47 mike 1.2 #include <Pegasus/Common/Config.h>
48 #include <Pegasus/Common/String.h>
|
49 kumpf 1.11 #include <Pegasus/Common/ArrayInternal.h>
|
50 kumpf 1.10 #include <Pegasus/Common/InternalException.h>
|
51 mike 1.2 #include <Pegasus/Config/ConfigPropertyOwner.h>
52 #include <Pegasus/Config/ConfigFileHandler.h>
53
54 #include <Pegasus/Config/TracePropertyOwner.h>
55 #include <Pegasus/Config/LogPropertyOwner.h>
56 #include <Pegasus/Config/DefaultPropertyOwner.h>
57 #include <Pegasus/Config/SecurityPropertyOwner.h>
58 #include <Pegasus/Config/RepositoryPropertyOwner.h>
59 #include <Pegasus/Config/ShutdownPropertyOwner.h>
|
60 kumpf 1.3 #include <Pegasus/Config/FileSystemPropertyOwner.h>
|
61 konrad.r 1.18 #include <Pegasus/Config/ProviderDirPropertyOwner.h>
|
62 mike 1.2
63 PEGASUS_NAMESPACE_BEGIN
64
|
65 kumpf 1.4 struct PropertyTable;
|
66 mike 1.2
67 /**
68 This class reads configuration properties from the config file, maps the
69 properties to owners, and implements access methods.
70 */
71
72 class PEGASUS_CONFIG_LINKAGE ConfigManager
73 {
74
75 private:
76
77 // This is meant to be a singleton, so the constructor
78 // and the destructor are made private
79 static ConfigManager* _instance;
80
81
82 /** Constructor. */
83 ConfigManager();
84
85
86 /** Destructor. */
87 mike 1.2 ~ConfigManager();
88
89
90 /**
91 Initialize config property with the value specified as a
92 command line option.
93
94 @param configOption name and value of the command line option.
95
96 @exception InvalidPropertyValue if property value is not valid.
97 @exception UnrecognizedConfigProperty if property is not defined.
98 */
99 Boolean _initPropertyWithCommandLineOption(
100 const String& configOption);
101 //throw (InvalidPropertyValue, UnrecognizedConfigProperty);
102
103
104 /**
105 load config properties from the file
106
107 @exception CannotRenameFile if failed to rename the config file.
|
108 kumpf 1.17 @exception CannotOpenFile if failed to set permissions on the config file.
|
109 mike 1.2 @exception ConfigFileSyntaxError if there are synatx error
110 while parsing the config files.
111 */
112 void _loadConfigProperties();
|
113 kumpf 1.17 //throw (CannotRenameFile, ConfigFileSyntaxError, CannotOpenFile);
|
114 mike 1.2
115
116 /**
117 Initialize config property owners and add them to the property owner table
118 */
|
119 kumpf 1.4 void _initPropertyTable();
|
120 mike 1.2
121
122 /**
123 HashTable to store the config property names and
124 property owners
125 */
|
126 kumpf 1.4 PropertyTable* _propertyTable;
|
127 mike 1.2
128 /**
129 Handler to access the config files.
130 */
131 ConfigFileHandler* _configFileHandler;
132
|
133 kumpf 1.3 /**
134 Pegasus home variable
135 */
136 static String _pegasusHome;
137
|
138 mike 1.2 public:
139
140 /**
|
141 kumpf 1.3 Default location of Pegasus home.
142 */
143 static const String PEGASUS_HOME_DEFAULT;
144
145 /**
|
146 mike 1.2 Constants representing the command line options.
147 */
148 static const char OPTION_TRACE;
149
150 static const char OPTION_LOG_TRACE;
151
152 static const char OPTION_DAEMON;
153
154
155 /**
156 Property Owners
157
158 When a new property owner is created be sure to add static
159 variable pointers for each of the new property owner.
160 */
161 static TracePropertyOwner* traceOwner;
162
163 static LogPropertyOwner* logOwner;
164
165 static DefaultPropertyOwner* defaultOwner;
166
167 mike 1.2 static SecurityPropertyOwner* securityOwner;
168
169 static RepositoryPropertyOwner* repositoryOwner;
170
171 static ShutdownPropertyOwner* shutdownOwner;
172
|
173 kumpf 1.3 static FileSystemPropertyOwner* fileSystemOwner;
|
174 mike 1.2
|
175 konrad.r 1.18 static ProviderDirPropertyOwner* providerDirOwner;
|
176 mike 1.2 /**
177 Construct the singleton instance of the ConfigManager and return a
178 pointer to that instance.
179 */
180 static ConfigManager* getInstance();
181
182
183 /**
184 Update current value of a property.
185
|
186 kumpf 1.7 @param propertyName The name of the property to update (eg. "httpPort").
|
187 mike 1.2 @param propertyValue The new value of the property. If the value is
188 null, the property should be reset to its default
189 value.
|
190 kumpf 1.5 @param unset Specifies whether the property should be updated
191 or unset.
|
192 mike 1.2 @return true if the property found and updated, else false.
193
194 @exception NonDynamicConfigProperty if property is not dynamic.
195 @exception UnrecognizedConfigProperty if property is not defined.
196 @exception InvalidPropertyValue if property value is not valid.
197 */
|
198 kumpf 1.5 Boolean updateCurrentValue(
199 const String& name,
200 const String& value,
201 Boolean unset);
|
202 mike 1.2 //throw (NonDynamicConfigProperty, InvalidPropertyValue,
|
203 kumpf 1.13 // UnrecognizedConfigProperty);
|
204 mike 1.2
205 /**
206 Update planned value of a property.
207
|
208 kumpf 1.7 @param propertyName The name of the property to update (eg. "httpPort").
|
209 mike 1.2 @param propertyValue The new value of the property. If the value is
210 null, the property should be reset to its default
211 value.
|
212 kumpf 1.5 @param unset Specifies whether the property should be updated
213 or unset.
|
214 mike 1.2 @return Boolean True if the property found and updated.
215
216 @exception NonDynamicConfigProperty if property is not dynamic.
217 @exception UnrecognizedConfigProperty if property is not defined.
218 @exception InvalidPropertyValue if property value is not valid.
219 */
|
220 kumpf 1.5 Boolean updatePlannedValue(
221 const String& name,
222 const String& value,
223 Boolean unset);
|
224 mike 1.2 //throw (NonDynamicConfigProperty, InvalidPropertyValue,
|
225 kumpf 1.13 // UnrecognizedConfigProperty);
|
226 mike 1.2
227
228 /**
229 Validate the value of a property.
230
231 @param name The name of the property.
232 @param value The value of the property to be validated.
233 @return true if the value of the property is valid, else false.
234
235 @exception UnrecognizedConfigProperty if property is not defined.
236 */
237 Boolean validatePropertyValue(const String& name, const String& value);
238 //throw (UnrecognizedConfigProperty);
239
240 /**
241 Get default value of the specified property.
242
243 @param name The name of the property.
244 @return string containing the default value of the specified property.
245
246 @exception UnrecognizedConfigProperty if property is not defined.
247 mike 1.2 */
248 String getDefaultValue(const String& name);
249 //throw (UnrecognizedConfigProperty);
250
251
252 /**
253 Get current value of the specified property.
254
255 @param name The name of the property.
256 @return string containing the current value of the specified property.
257
258 @exception UnrecognizedConfigProperty if property is not defined.
259 */
260 String getCurrentValue(const String& name);
261 //throw (UnrecognizedConfigProperty);
262
263
264 /**
265 Get planned value of the specified property.
266
267 @param name The name of the property.
268 mike 1.2 @return string containing the current value of the specified property.
269
270 @exception UnrecognizedConfigProperty if property is not defined.
271 */
272 String getPlannedValue(const String& name);
273 //throw (UnrecognizedConfigProperty);
274
275
276 /**
277 Get all the attributes of the specified property.
278
279 @param name The name of the property.
280 @param propertyInfo List containing the property info.
281
282 @exception UnrecognizedConfigProperty if property is not defined.
283 */
284 void getPropertyInfo(const String& name, Array<String>& propertyInfo);
285 //throw (UnrecognizedConfigProperty);
286
287
288 /**
289 mike 1.2 Get a list of all the property names.
290
291 @param propertyNames List containing all the property names.
292 */
293 void getAllPropertyNames(Array<String>& propertyNames);
294
295 /**
296 Merges the config properties from the specified configuration files.
297
298 @param currentFile Name of file that contains current config properties.
299 @param plannedFile Name of file that contains planned config properties.
300
301 @exception NoSuchFile if the specified config file does not exist.
302 @exception FileNotReadable if the specified config file is not readable.
303 @exception CannotRenameFile if failed to rename the config file.
|
304 kumpf 1.17 @exception CannotOpenFile if failed to set permissions on the config file.
|
305 mike 1.2 @exception ConfigFileSyntaxError if there is synatx error
306 while parsing the config files.
307 */
308 void mergeConfigFiles(const String& currentFile, const String& plannedFile);
309 //throw (NoSuchFile, FileNotReadable, CannotRenameFile,
|
310 kumpf 1.17 // ConfigFileSyntaxError, CannotOpenFile);
|
311 mike 1.2
312 /**
313 Merge the config properties from the default planned config file
314 with the properties in the default current config file.
315
316 @exception NoSuchFile if the default config file does not exist.
317 @exception FileNotReadable if the default config file is not readable.
318 @exception CannotRenameFile if failed to rename the config file.
|
319 kumpf 1.17 @exception CannotOpenFile if failed to set permissions on the config file.
|
320 mike 1.2 @exception ConfigFileSyntaxError if there are synatx error
321 while parsing the config files.
322 */
323 void mergeConfigFiles();
324 //throw (NoSuchFile, FileNotReadable, CannotRenameFile,
|
325 kumpf 1.17 // ConfigFileSyntaxError, CannotOpenFile);
|
326 mike 1.2
327
328 /**
329 Merge option values from the command line.
330
331 @param argc number of argument on the command line.
332 @param argv list of command line arguments.
333
334 @exception InvalidPropertyValue if validation fails.
335 @exception UnrecognizedConfigProperty if property is not defined.
336 */
337 void mergeCommandLine(int& argc, char**& argv);
338 //throw (UnrecognizedConfigProperty, InvalidPropertyValue);
|
339 kumpf 1.3
340
341 /**
342 Get Pegasus Home
343 */
344 static String getPegasusHome();
345
346 /**
347 Set Pegasus Home
348 */
349 static void setPegasusHome(String& home);
350
351 /**
352 Get Homed Path
353 This function checks if the argument passed is an absolute path.
354 If true then it returns the same value. Else, it prepends
355 the value of pegasusHome to the value.
356 */
357 static String getHomedPath(const String& value);
|
358 mike 1.2
359 };
360
361 PEGASUS_NAMESPACE_END
362
363 #endif /* Pegasus_ConfigManager_h */
364
|