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