(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 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 mike  1.2  
 62            PEGASUS_NAMESPACE_BEGIN
 63            
 64 kumpf 1.4  struct PropertyTable;
 65 mike  1.2  
 66            /**
 67              This class reads configuration properties from the config file, maps the 
 68              properties to owners, and implements access methods.
 69            */
 70            
 71            class PEGASUS_CONFIG_LINKAGE ConfigManager
 72            {
 73            
 74            private:
 75            
 76                // This is meant to be a singleton, so the constructor
 77                // and the destructor are made private
 78                static ConfigManager* _instance;
 79            
 80            
 81                /** Constructor. */
 82                ConfigManager();
 83            
 84            
 85                /** Destructor. */
 86 mike  1.2      ~ConfigManager();
 87            
 88            
 89                /** 
 90                Initialize config property with the value specified as a
 91                command line option.
 92            
 93                @param configOption    name and value of the command line option.
 94            
 95                @exception InvalidPropertyValue  if property value is not valid.
 96                @exception UnrecognizedConfigProperty  if property is not defined.
 97                */
 98                Boolean _initPropertyWithCommandLineOption(
 99                    const String& configOption);
100                        //throw (InvalidPropertyValue, UnrecognizedConfigProperty);
101            
102            
103                /** 
104                load config properties from the file 
105            
106                @exception CannotRenameFile  if failed to rename the config file.
107 mike  1.2      @exception ConfigFileSyntaxError  if there are synatx error 
108                                        while parsing the config files.
109                */
110                void _loadConfigProperties();
111                    //throw (CannotRenameFile, ConfigFileSyntaxError);
112            
113            
114                /**
115                Initialize config property owners and add them to the property owner table
116                */
117 kumpf 1.4      void _initPropertyTable();
118 mike  1.2  
119            
120                /** 
121                HashTable to store the config property names and 
122                property owners 
123                */
124 kumpf 1.4      PropertyTable* _propertyTable;
125 mike  1.2  
126                /**
127                Handler to access the config files.
128                */
129                ConfigFileHandler*    _configFileHandler;
130            
131 kumpf 1.3      /**
132                Pegasus home variable
133                */
134                static String	  _pegasusHome;
135            
136 mike  1.2  public:
137            
138                /**
139 kumpf 1.3      Default location of Pegasus home.
140                */
141                static const String PEGASUS_HOME_DEFAULT;
142            
143                /**
144 mike  1.2      Constants representing the command line options.
145                */
146                static const char OPTION_TRACE;
147            
148                static const char OPTION_LOG_TRACE;
149            
150                static const char OPTION_DAEMON;
151            
152            
153                /**
154                Property Owners
155            
156                When a new property owner is created be sure to add static
157                variable pointers for each of the new property owner.
158                */
159                static TracePropertyOwner*      traceOwner;
160            
161                static LogPropertyOwner*        logOwner; 
162            
163                static DefaultPropertyOwner*    defaultOwner;
164            
165 mike  1.2      static SecurityPropertyOwner*   securityOwner; 
166            
167                static RepositoryPropertyOwner* repositoryOwner; 
168            
169                static ShutdownPropertyOwner*   shutdownOwner; 
170            
171 kumpf 1.3      static FileSystemPropertyOwner*   fileSystemOwner; 
172 mike  1.2  
173                /** 
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                @exception ConfigFileSyntaxError  if there is synatx error 
302                                        while parsing the config files.
303                */
304                void mergeConfigFiles(const String& currentFile, const String& plannedFile);
305                    //throw (NoSuchFile, FileNotReadable, CannotRenameFile, 
306                    //    ConfigFileSyntaxError);
307 mike  1.2  
308                /** 
309                Merge the config properties from the default planned config file
310                with the properties in the default current config file.
311            
312                @exception NoSuchFile  if the default config file does not exist.
313                @exception FileNotReadable  if the default config file is not readable.
314                @exception CannotRenameFile  if failed to rename the config file.
315                @exception ConfigFileSyntaxError  if there are synatx error 
316                                        while parsing the config files.
317                */
318                void mergeConfigFiles();
319                    //throw (NoSuchFile, FileNotReadable, CannotRenameFile, 
320                    //    ConfigFileSyntaxError);
321            
322            
323                /** 
324                Merge option values from the command line. 
325            
326                @param argc number of argument on the command line.
327                @param argv list of command line arguments.
328 mike  1.2  
329                @exception  InvalidPropertyValue if validation fails.
330                @exception  UnrecognizedConfigProperty  if property is not defined.
331                */
332                void mergeCommandLine(int& argc, char**& argv);
333                    //throw (UnrecognizedConfigProperty, InvalidPropertyValue);
334 kumpf 1.3  
335            
336                /**
337                Get Pegasus Home
338                */
339                static String getPegasusHome();
340            
341                /**
342                Set Pegasus Home 
343                */
344                static void setPegasusHome(String& home);
345            
346                /**
347                Get Homed Path
348                This function checks if the argument passed is an absolute path. 
349                If true then it returns the same value. Else, it prepends 
350                the value of pegasusHome to the value.
351                */
352                static String getHomedPath(const String& value);
353 mike  1.2  
354            };
355            
356            PEGASUS_NAMESPACE_END
357            
358            #endif /* Pegasus_ConfigManager_h */
359            

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2