Does not inherit
#include rwsf/cm/ConfigurationManager.h
Class ConfigurationManager represents a central point for receiving and modifying binding information in associated ConfigurationHandlers.
When a ConfigurationManager receives a request for a binding, it checks its local cache, then each of its ConfigurationHandlers, in order, until either a binding by the given name is found or all possible sources are exhausted. If the latter occurs, an invalid (!.isValid()) ConfigBinding is returned.
A binding can automatically include the values of other bindings using references. If the value of a simple binding begins with the key character '@', the CM searches its sources for a binding by the name following the character. If found, the binding value is replaced by the referenced binding value before being returned.
If a reference is not resolvable, an invalid ConfigBinding is returned. Example use: a service needs to store transaction data in a database. A company-wide WSDL uses a reference for a database connection. The database connection is then defined in region-specifc WSDL files for regional databases, thus allowing the major portion of common configuration information to be stored in a common file with location-specific information to be in smaller files.
ConfigurationManager();
Default constructor
~ConfigurationManager();
Default destructor
void addConfigurationHandler(ConfigurationHandler * handler);
Adds the given configuration handler. Multiple configuration handlers are allowed, and are checked in the order they are added.
void clear();
Clears all binding information.
ConfigBinding getBinding(const std::string & name) const;
Checks all configuration handlers for the given binding, and if found, returns the binding handle. throws rwsf::ConfigurationException("Circular reference") if a configurationBinding links to one of its parents bindings in the tree.
std::list< std::string > getBindingNames() const;
Returns a list of the binding names stored in this ConfigurationManager (all bindings in all configuration handlers).
rwsf::Logger getLogger();
Returns the logger for this configuration manager.
bool hasBinding(const std::string & name) const;
Returns true if the given binding is stored in this ConfigurationManager (checks all associated configuration handlers); otherwise, false.
void initialize(const std::string & configFile);
Initializes this configuration manager with the given init file. The init file must be either an absolute path, or relative to the current working directory.
Exceptions
rwsf::Exception |
if initialization fails. |
void loadBindingDirectory(const std::string & dir);
Loads bindings from the given directory on all configuration handlers.
void loadBindingFile(const std::string & file);
Loads bindings from the given file on all configuration handlers.
void removeBinding(const std::string & key);
Clears the given binding from the ConfigurationManager.
void removeConfigurationHandler(ConfigurationHandler * handler);
Removes a configuration handler.
void setBinding(const std::string & key, const ConfigBinding & b);
Sets the binding in the first configuration handler with the specified name to the given binding handle.
void setLogger(const rwsf::Logger & logger);
Sets the logger for this configuration manager.
© Copyright Rogue Wave Software, Inc. All Rights Reserved. All Rights Reserved. Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. HydraExpress is a trademark of Rogue Wave Software, Inc. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.