(file) Return to ConfigManager.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Config

  1 martin 1.38 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.39 //
  3 martin 1.38 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.39 //
 10 martin 1.38 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.39 //
 17 martin 1.38 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.39 //
 20 martin 1.38 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.39 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.38 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.39 //
 28 martin 1.38 //////////////////////////////////////////////////////////////////////////
 29 mike   1.2  //
 30             //%////////////////////////////////////////////////////////////////////////////
 31             
 32             
 33             ///////////////////////////////////////////////////////////////////////////////
 34 chip   1.24 //
 35 mike   1.2  // This file defines the classes necessary to manage configuration properties
 36 chip   1.24 // specified on the commandline and configuration files for Pegasus.
 37 mike   1.2  //
 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 a.arora 1.19 #include <Pegasus/Common/AutoPtr.h>
 50 david.dillard 1.21 #include <Pegasus/Common/HashTable.h>
 51 dev.meetei    1.44 #include <Pegasus/Common/HostAddress.h>
 52 mike          1.2  #include <Pegasus/Config/ConfigPropertyOwner.h>
 53                    #include <Pegasus/Config/ConfigFileHandler.h>
 54                    
 55                    #include <Pegasus/Config/TracePropertyOwner.h>
 56                    #include <Pegasus/Config/LogPropertyOwner.h>
 57                    #include <Pegasus/Config/DefaultPropertyOwner.h>
 58                    #include <Pegasus/Config/SecurityPropertyOwner.h>
 59                    #include <Pegasus/Config/RepositoryPropertyOwner.h>
 60                    #include <Pegasus/Config/ShutdownPropertyOwner.h>
 61 kumpf         1.3  #include <Pegasus/Config/FileSystemPropertyOwner.h>
 62 konrad.r      1.18 #include <Pegasus/Config/ProviderDirPropertyOwner.h>
 63 chip          1.24 #include <Pegasus/Config/NormalizationPropertyOwner.h>
 64 mike          1.2  
 65 venkat.puvvada 1.43 #ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT
 66                     #include <Pegasus/Config/IndicationServicePropertyOwner.h>
 67                     #endif
 68                     
 69 mike           1.2  PEGASUS_NAMESPACE_BEGIN
 70                     
 71                     /**
 72 kumpf          1.34     This class reads configuration properties from the config file, maps the
 73                         properties to owners, and implements access methods.
 74 mike           1.2  */
 75                     class PEGASUS_CONFIG_LINKAGE ConfigManager
 76                     {
 77                     private:
 78                     
 79 kumpf          1.20     /**
 80                             Refers to the singleton ConfigManager instance.  If no ConfigManager
 81                             instance has been constructed, this value is null.
 82                          */
 83 kumpf          1.37     static AutoPtr<ConfigManager> _instance;
 84 mike           1.2  
 85                         /** Constructor. */
 86                         ConfigManager();
 87                     
 88 chip           1.24     /**
 89 kumpf          1.34         Initialize config property with the value specified as a
 90                             command line option.
 91 mike           1.2  
 92 kumpf          1.34         @param configOption    name and value of the command line option.
 93 mike           1.2  
 94 kumpf          1.34         @exception InvalidPropertyValue  if property value is not valid.
 95                             @exception UnrecognizedConfigProperty  if property is not defined.
 96 mike           1.2      */
 97                         Boolean _initPropertyWithCommandLineOption(
 98                             const String& configOption);
 99                     
100                     
101 chip           1.24     /**
102 kumpf          1.34         load config properties from the file
103 mike           1.2  
104 kumpf          1.34         @exception CannotRenameFile  if failed to rename the config file.
105                             @exception CannotOpenFile if failed to set permissions on the config
106                                 file.
107                             @exception ConfigFileSyntaxError  if there are synatx error
108                                 while parsing the config files.
109 mike           1.2      */
110                         void _loadConfigProperties();
111                     
112                     
113                         /**
114 kumpf          1.34         Initialize config property owners and add them to the property owner
115                             table
116 mike           1.2      */
117 kumpf          1.4      void _initPropertyTable();
118 mike           1.2  
119 david.dillard  1.21     /**
120 marek          1.45         Check for fixed value and return the fixed value as String if
121                             Initializes the two config properties hostName and
122                             fullyQualifiedHostname when defined as fixed values
123 karl           1.47     */
124 marek          1.46     Boolean _fixedValueCheck(const String& name,String & value) const;
125 marek          1.45 
126                         /**
127 kumpf          1.34         HashTable used to identify owners.
128 david.dillard  1.21     */
129                         typedef HashTable<String,
130                             ConfigPropertyOwner*,EqualFunc<String>,HashFunc<String> > OwnerTable;
131                     
132                         /**
133 kumpf          1.34         HashTable used to identify fixed values.
134 david.dillard  1.21     */
135 kumpf          1.34     typedef HashTable<String, const char*, EqualFunc<String>, HashFunc<String> >
136                             FixedValueTable;
137 david.dillard  1.21 
138 david.dillard  1.22     /*
139 kumpf          1.34         friend declaration needed by some compilers to allow OwnerTable and
140                             FixedValueTable to be accessible from PropertyTable.
141 david.dillard  1.22     */
142                         struct PropertyTable;
143                         friend struct ConfigManager::PropertyTable;
144                     
145 david.dillard  1.21     /**
146 kumpf          1.34         Structure used to identify properties.
147 david.dillard  1.21     */
148                         struct PropertyTable
149                         {
150                             OwnerTable ownerTable;
151                             FixedValueTable fixedValueTable;
152                         };
153 mike           1.2  
154 chip           1.24     /**
155 kumpf          1.34         HashTable to store the config property names and property owners
156 mike           1.2      */
157 kumpf          1.34     AutoPtr<PropertyTable> _propertyTable;
158 mike           1.2  
159                         /**
160 kumpf          1.34         Handler to access the config files.
161 mike           1.2      */
162 kumpf          1.34     AutoPtr<ConfigFileHandler> _configFileHandler;
163 mike           1.2  
164 kumpf          1.3      /**
165 kumpf          1.34         Pegasus home variable
166 kumpf          1.3      */
167 kumpf          1.34     static String _pegasusHome;
168 kumpf          1.3  
169 mike           1.2  public:
170                     
171                         /**
172 kumpf          1.34         Default location of Pegasus home.
173 kumpf          1.3      */
174                         static const String PEGASUS_HOME_DEFAULT;
175                     
176 mike           1.2      /**
177 kumpf          1.34         Property Owners
178 mike           1.2  
179 kumpf          1.34         When a new property owner is created be sure to add static
180 karl           1.47         variable pointers for the new property owner.
181 mike           1.2      */
182 kumpf          1.37     static TracePropertyOwner traceOwner;
183 mike           1.2  
184 kumpf          1.37     static LogPropertyOwner logOwner;
185 mike           1.2  
186 kumpf          1.37     static DefaultPropertyOwner defaultOwner;
187 mike           1.2  
188 kumpf          1.37     static SecurityPropertyOwner securityOwner;
189 mike           1.2  
190 kumpf          1.37     static RepositoryPropertyOwner repositoryOwner;
191 mike           1.2  
192 kumpf          1.37     static ShutdownPropertyOwner shutdownOwner;
193 mike           1.2  
194 kumpf          1.37     static FileSystemPropertyOwner fileSystemOwner;
195 mike           1.2  
196 kumpf          1.37     static ProviderDirPropertyOwner providerDirOwner;
197 kumpf          1.20 
198 kumpf          1.37     static NormalizationPropertyOwner normalizationOwner;
199 chip           1.24 
200 venkat.puvvada 1.43 #ifdef PEGASUS_ENABLE_DMTF_INDICATION_PROFILE_SUPPORT
201                         static IndicationServicePropertyOwner indicationServiceOwner;
202                     #endif
203                     
204 kumpf          1.20     /**
205                             Boolean indicating whether configuration data should be read from
206 kumpf          1.26         and persisted to configuration files.  If true, this ConfigManager
207                             instance actively manages the configuration data.  All operations
208                             are functional and updates are written to the configuration files.  If
209 kumpf          1.20         false, the ConfigManager does not read to or write from configuration
210 kumpf          1.26         files.  In addition, property values are not validated.  When this
211                             value is false, the behavior of methods that specifically implicate
212                             configuration files is not defined.  The default value is false.
213 kumpf          1.20      */
214                         Boolean useConfigFiles;
215                     
216 chip           1.24     /**
217 kumpf          1.20         Get a reference to the singleton ConfigManager instance.  If no
218                             ConfigManager instance exists, construct one.
219 mike           1.2      */
220                         static ConfigManager* getInstance();
221                     
222 chip           1.24     /**
223 kumpf          1.34         Initialize the current value of a config property.
224 kumpf          1.20 
225 kumpf          1.34         @param  propertyName  The name of the property to initialize (e.g.,
226                                 "httpPort").
227                             @param  propertyValue The initial value of the property.
228                             @return true if the property found and initialized, else false.
229 kumpf          1.20 
230 kumpf          1.34         @exception UnrecognizedConfigProperty  if property is not defined.
231                             @exception InvalidPropertyValue  if property value is not valid.
232 kumpf          1.20     */
233                         Boolean initCurrentValue(
234                             const String& name,
235                             const String& value);
236                     
237 chip           1.24     /**
238 kumpf          1.34         Update current value of a property.
239 mike           1.2  
240 kumpf          1.34         @param propertyName  The name of the property to update
241                                 (e.g., "httpPort").
242                             @param propertyValue The new value of the property.  If the value is
243                                 null, the property should be reset to its default value.
244 venkat.puvvada 1.41         @param userName User requesting update.
245 venkat.puvvada 1.42         @timeoutSeconds Timeout in seconds to complete the update.
246 kumpf          1.34         @param unset Specifies whether the property should be updated or unset.
247                             @return true if the property found and updated, else false.
248                     
249                             @exception NonDynamicConfigProperty if property is not dynamic.
250                             @exception UnrecognizedConfigProperty if property is not defined.
251                             @exception InvalidPropertyValue if property value is not valid.
252 mike           1.2      */
253 kumpf          1.5      Boolean updateCurrentValue(
254                             const String& name,
255                             const String& value,
256 venkat.puvvada 1.41         const String& userName,
257 venkat.puvvada 1.42         Uint32 timeoutSeconds,
258 kumpf          1.5          Boolean unset);
259 mike           1.2  
260 chip           1.24     /**
261 kumpf          1.34         Update planned value of a property.
262 mike           1.2  
263 kumpf          1.34         @param propertyName The name of the property to update
264                                 (e.g., "httpPort").
265                             @param propertyValue The new value of the property.  If the value is
266                                 null, the property should be reset to its default value.
267                             @param unset Specifies whether the property should be updated or unset.
268                             @return Boolean True if the property found and updated.
269                     
270                             @exception NonDynamicConfigProperty if property is not dynamic.
271                             @exception UnrecognizedConfigProperty if property is not defined.
272                             @exception InvalidPropertyValue if property value is not valid.
273 mike           1.2      */
274 kumpf          1.5      Boolean updatePlannedValue(
275                             const String& name,
276                             const String& value,
277                             Boolean unset);
278 mike           1.2  
279 chip           1.24     /**
280 kumpf          1.34         Validate the value of a property.
281 mike           1.2  
282 kumpf          1.34         @param name The name of the property.
283                             @param value The value of the property to be validated.
284                             @return true if the value of the property is valid, else false.
285 mike           1.2  
286 kumpf          1.34         @exception UnrecognizedConfigProperty if property is not defined.
287 mike           1.2      */
288                         Boolean validatePropertyValue(const String& name, const String& value);
289                     
290                         /**
291 kumpf          1.34         Get default value of the specified property.
292 mike           1.2  
293 kumpf          1.34         @param name The name of the property.
294                             @return string containing the default value of the specified property.
295 mike           1.2  
296 kumpf          1.34         @exception UnrecognizedConfigProperty if property is not defined.
297 mike           1.2      */
298 aruran.ms      1.30     String getDefaultValue(const String& name) const;
299 mike           1.2  
300 chip           1.24     /**
301 kumpf          1.34         Get current value of the specified property.
302 mike           1.2  
303 kumpf          1.34         @param name The name of the property.
304                             @return string containing the current value of the specified property.
305 mike           1.2  
306 kumpf          1.34         @exception UnrecognizedConfigProperty if property is not defined.
307 mike           1.2      */
308 aruran.ms      1.30     String getCurrentValue(const String& name) const;
309 mike           1.2  
310 chip           1.24     /**
311 kumpf          1.34         Get planned value of the specified property.
312 mike           1.2  
313 kumpf          1.34         @param name The name of the property.
314                             @return string containing the current value of the specified property.
315 mike           1.2  
316 kumpf          1.34         @exception UnrecognizedConfigProperty if property is not defined.
317 mike           1.2      */
318 aruran.ms      1.30     String getPlannedValue(const String& name) const;
319 mike           1.2  
320 chip           1.24     /**
321 kumpf          1.34         Get all the attributes of the specified property.
322 mike           1.2  
323 kumpf          1.34         @param name The name of the property.
324                             @param propertyInfo List containing the property info.
325 mike           1.2  
326 kumpf          1.34         @exception UnrecognizedConfigProperty if property is not defined.
327 mike           1.2      */
328 aruran.ms      1.30     void getPropertyInfo(const String& name, Array<String>& propertyInfo) const;
329 mike           1.2  
330 chip           1.24     /**
331 karl           1.47         Get the help on the specified property.
332                     
333                             @param name The name of the property.
334                             @param propertyInfo List containing the property info.
335                     
336                             @exception UnrecognizedConfigProperty if property is not defined.
337                         */
338                         void getPropertyHelp(const String& name, String& propertyInfo) const;
339                     
340                         /**
341 kumpf          1.34         Get a list of all the property names.
342 mike           1.2  
343 kumpf          1.34         @param propertyNames List containing all the property names.
344                             @param includeHiddenProperties Boolean indicating whether hidden
345                                 properties should be included in the returned list.
346 kumpf          1.20     */
347                         void getAllPropertyNames(
348                             Array<String>& propertyNames,
349 aruran.ms      1.30         Boolean includeHiddenProperties) const;
350 mike           1.2  
351 chip           1.24     /**
352 kumpf          1.34         Merges the config properties from the specified configuration files.
353 mike           1.2  
354 kumpf          1.34         @param currentFile Name of file that contains current config properties.
355                             @param plannedFile Name of file that contains planned config properties.
356 mike           1.2  
357 kumpf          1.34         @exception NoSuchFile if the specified config file does not exist.
358                             @exception FileNotReadable if the specified config file is not readable.
359                             @exception CannotRenameFile if failed to rename the config file.
360                             @exception CannotOpenFile if failed to set permissions on the config
361                                 file.
362                             @exception ConfigFileSyntaxError if there is syntax error
363                                 while parsing the config files.
364                             @exception InvalidPropertyValue if validation fails for a config
365                                 property in either file.
366                             @exception UnrecognizedConfigProperty if a config property specified in
367                                 either file is not defined.
368                         */
369                         void mergeConfigFiles(
370                             const String& currentFile,
371                             const String& plannedFile);
372                     
373                         /**
374                             Merge the config properties from the default planned config file
375                             with the properties in the default current config file.
376                     
377                             @exception NoSuchFile if the default config file does not exist.
378 kumpf          1.34         @exception FileNotReadable if the default config file is not readable.
379                             @exception CannotRenameFile if failed to rename the config file.
380                             @exception CannotOpenFile if failed to set permissions on the config
381                                 file.
382                             @exception ConfigFileSyntaxError if there are synatx error
383                                 while parsing the config files.
384                             @exception InvalidPropertyValue if validation fails for a config
385                                 property in either file.
386                             @exception UnrecognizedConfigProperty if a config property specified in
387                                 either file is not defined.
388 mike           1.2      */
389                         void mergeConfigFiles();
390                     
391 chip           1.24     /**
392 mateus.baur    1.35         Load the config properties from the current and planned files.
393                     
394                             @exception NoSuchFile  if the default config file does not exist.
395                             @exception FileNotReadable  if the default config file is not readable.
396                             @exception CannotRenameFile  if failed to rename the config file.
397 kumpf          1.36         @exception CannotOpenFile if failed to set permissions on the config
398                                 file.
399 mateus.baur    1.35         @exception ConfigFileSyntaxError  if there are synatx error
400                                 while parsing the config files.
401 kumpf          1.36         @exception InvalidPropertyValue if validation fails for a config
402                                 property in either file.
403 mateus.baur    1.35         @exception UnrecognizedConfigProperty if a config property specified in
404                                 either file is not defined.
405                         */
406                         void loadConfigFiles();
407                     
408                         /**
409 kumpf          1.34         Merge option values from the command line.
410 mike           1.2  
411 kumpf          1.34         @param argc number of argument on the command line.
412                             @param argv list of command line arguments.
413 mike           1.2  
414 kumpf          1.34         @exception InvalidPropertyValue if validation fails.
415                             @exception UnrecognizedConfigProperty if property is not defined.
416 mike           1.2      */
417                         void mergeCommandLine(int& argc, char**& argv);
418 kumpf          1.3  
419                         /**
420 kumpf          1.34         Get Pegasus Home
421 kumpf          1.3      */
422                         static String getPegasusHome();
423                     
424                         /**
425 kumpf          1.34         Set Pegasus Home
426 kumpf          1.3      */
427 aruran.ms      1.27     static void setPegasusHome(const String& home);
428 kumpf          1.3  
429                         /**
430 kumpf          1.34         Get Homed Path
431                             This function checks if the argument passed is an absolute path.
432                             If true then it returns the same value. Else, it prepends
433                             the value of pegasusHome to the value.
434 kumpf          1.3      */
435                         static String getHomedPath(const String& value);
436 mike           1.2  
437 kumpf          1.33     /**
438                             Parses a boolean configuration property value.
439                             @param propertyValue A String containing a boolean configuration
440                                 property value.
441                             @return True if the specified configuration property value represents
442                                 a boolean value of "true", false otherwise.
443                         */
444                         static Boolean parseBooleanValue(const String& propertyValue);
445 kavita.gupta   1.40 
446                         /**
447                             Validates a boolean configuration property value.
448                             @param propertyValue A String containing a boolean configuration
449                                 property value.
450                             @return True if the specified configuration property value is a valid
451                                 boolean value of 'true' or 'false'
452                         */
453                         static Boolean isValidBooleanValue(const String& propertyValue);
454 dev.meetei     1.44    /**
455                             get the ip addresses to listen on for connection
456 karl           1.47         @param propertyValue A String containing a comma separated list of ips
457                             @return an array of ip adress specified for configuration property
458                                 listenAdrress
459 dev.meetei     1.44     */
460                         static Array<HostAddress> getListenAddress(const String& propertyValue);
461                     
462 kavita.gupta   1.40 
463 karl           1.47     /**
464                          * gets the Internationalized string for "dynamic" or "static"
465                          */
466                     
467                         String getDynamicAttributeStatus(const String& name);
468                     
469 mike           1.2  };
470                     
471                     PEGASUS_NAMESPACE_END
472                     
473                     #endif /* Pegasus_ConfigManager_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2