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

  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 a.arora 1.19 #include <Pegasus/Common/AutoPtr.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 mike     1.2  
 64               PEGASUS_NAMESPACE_BEGIN
 65               
 66 kumpf    1.4  struct PropertyTable;
 67 mike     1.2  
 68               /**
 69                 This class reads configuration properties from the config file, maps the 
 70                 properties to owners, and implements access methods.
 71               */
 72               
 73               class PEGASUS_CONFIG_LINKAGE ConfigManager
 74               {
 75               
 76               private:
 77               
 78                   // This is meant to be a singleton, so the constructor
 79                   // and the destructor are made private
 80                   static ConfigManager* _instance;
 81               
 82               
 83                   /** Constructor. */
 84                   ConfigManager();
 85               
 86               
 87                   /** 
 88 mike     1.2      Initialize config property with the value specified as a
 89                   command line option.
 90               
 91                   @param configOption    name and value of the command line option.
 92               
 93                   @exception InvalidPropertyValue  if property value is not valid.
 94                   @exception UnrecognizedConfigProperty  if property is not defined.
 95                   */
 96                   Boolean _initPropertyWithCommandLineOption(
 97                       const String& configOption);
 98                           //throw (InvalidPropertyValue, UnrecognizedConfigProperty);
 99               
100               
101                   /** 
102                   load config properties from the file 
103               
104                   @exception CannotRenameFile  if failed to rename the config file.
105 kumpf    1.17     @exception CannotOpenFile if failed to set permissions on 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 kumpf    1.17         //throw (CannotRenameFile, ConfigFileSyntaxError, CannotOpenFile);
111 mike     1.2  
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 a.arora  1.19     AutoPtr<PropertyTable> _propertyTable; //PEP101
124 mike     1.2  
125                   /**
126                   Handler to access the config files.
127                   */
128 a.arora  1.19     AutoPtr<ConfigFileHandler>    _configFileHandler; //PEP101
129 mike     1.2  
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 konrad.r 1.18     static ProviderDirPropertyOwner*	providerDirOwner;
173 mike     1.2      /** 
174                   Construct the singleton instance of the ConfigManager and return a 
175                   pointer to that instance.
176                   */
177                   static ConfigManager* getInstance();
178               
179               
180                   /** 
181                   Update current value of a property.
182               
183 kumpf    1.7      @param  propertyName  The name of the property to update (eg. "httpPort").
184 mike     1.2      @param  propertyValue The new value of the property.  If the value is
185                                         null, the property should be reset to its default
186                                         value.
187 kumpf    1.5      @param  unset         Specifies whether the property should be updated
188                                         or unset.
189 mike     1.2      @return true if the property found and updated, else false.
190               
191                   @exception NonDynamicConfigProperty  if property is not dynamic.
192                   @exception UnrecognizedConfigProperty  if property is not defined.
193                   @exception InvalidPropertyValue  if property value is not valid.
194                   */
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.13         //    UnrecognizedConfigProperty);
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                   */
217 kumpf    1.5      Boolean updatePlannedValue(
218                       const String& name,
219                       const String& value,
220                       Boolean unset);
221 mike     1.2          //throw (NonDynamicConfigProperty, InvalidPropertyValue, 
222 kumpf    1.13         //    UnrecognizedConfigProperty);
223 mike     1.2  
224               
225                   /** 
226                   Validate the value of a property.
227               
228                   @param  name    The name of the property.
229                   @param  value   The value of the property to be validated. 
230                   @return true if the value of the property is valid, else false.
231               
232                   @exception UnrecognizedConfigProperty  if property is not defined.
233                   */
234                   Boolean validatePropertyValue(const String& name, const String& value);
235                       //throw (UnrecognizedConfigProperty);
236               
237                   /**
238                   Get default value of the specified property.
239               
240                   @param  name    The name of the property.
241                   @return string containing the default value of the specified property.
242               
243                   @exception UnrecognizedConfigProperty  if property is not defined.
244 mike     1.2      */
245                   String getDefaultValue(const String& name);
246                       //throw (UnrecognizedConfigProperty);
247               
248               
249                   /** 
250                   Get current value of the specified property.
251               
252                   @param  name    The name of the property.
253                   @return string containing the current value of the specified property.
254               
255                   @exception UnrecognizedConfigProperty  if property is not defined.
256                   */
257                   String getCurrentValue(const String& name);
258                       //throw (UnrecognizedConfigProperty);
259               
260               
261                   /** 
262                   Get planned value of the specified property.
263               
264                   @param  name    The name of the property.
265 mike     1.2      @return string containing the current value of the specified property.
266               
267                   @exception UnrecognizedConfigProperty  if property is not defined.
268                   */
269                   String getPlannedValue(const String& name);
270                       //throw (UnrecognizedConfigProperty);
271               
272               
273                   /** 
274                   Get all the attributes of the specified property.
275               
276                   @param name          The name of the property.
277                   @param propertyInfo  List containing the property info.
278               
279                   @exception UnrecognizedConfigProperty  if property is not defined.
280                   */
281                   void getPropertyInfo(const String& name, Array<String>& propertyInfo);
282                       //throw (UnrecognizedConfigProperty);
283               
284               
285                   /** 
286 mike     1.2      Get a list of all the property names.
287               
288                   @param propertyNames  List containing all the property names.
289                   */
290                   void getAllPropertyNames(Array<String>& propertyNames);
291               
292                   /** 
293                   Merges the config properties from the specified configuration files.
294               
295                   @param currentFile   Name of file that contains current config properties.
296                   @param plannedFile   Name of file that contains planned config properties.
297               
298                   @exception NoSuchFile  if the specified config file does not exist.
299                   @exception FileNotReadable  if the specified config file is not readable.
300                   @exception CannotRenameFile  if failed to rename the config file.
301 kumpf    1.17     @exception CannotOpenFile if failed to set permissions on the config file.
302 mike     1.2      @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 kumpf    1.17         //    ConfigFileSyntaxError, CannotOpenFile);
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 kumpf    1.17     @exception CannotOpenFile if failed to set permissions on the config file.
317 mike     1.2      @exception ConfigFileSyntaxError  if there are synatx error 
318                                           while parsing the config files.
319                   */
320                   void mergeConfigFiles();
321                       //throw (NoSuchFile, FileNotReadable, CannotRenameFile, 
322 kumpf    1.17         //    ConfigFileSyntaxError, CannotOpenFile);
323 mike     1.2  
324               
325                   /** 
326                   Merge option values from the command line. 
327               
328                   @param argc number of argument on the command line.
329                   @param argv list of command line arguments.
330               
331                   @exception  InvalidPropertyValue if validation fails.
332                   @exception  UnrecognizedConfigProperty  if property is not defined.
333                   */
334                   void mergeCommandLine(int& argc, char**& argv);
335                       //throw (UnrecognizedConfigProperty, InvalidPropertyValue);
336 kumpf    1.3  
337               
338                   /**
339                   Get Pegasus Home
340                   */
341                   static String getPegasusHome();
342               
343                   /**
344                   Set Pegasus Home 
345                   */
346                   static void setPegasusHome(String& home);
347               
348                   /**
349                   Get Homed Path
350                   This function checks if the argument passed is an absolute path. 
351                   If true then it returns the same value. Else, it prepends 
352                   the value of pegasusHome to the value.
353                   */
354                   static String getHomedPath(const String& value);
355 mike     1.2  
356               };
357               
358               PEGASUS_NAMESPACE_END
359               
360               #endif /* Pegasus_ConfigManager_h */
361               

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2