com.sdm.quasar.client.core.common.config
Class DefaultConfigManager

java.lang.Object
  extended bycom.sdm.quasar.client.core.common.config.DefaultConfigManager
All Implemented Interfaces:
ConfigManager, ConfigProvider, SystemInfoProvider

public class DefaultConfigManager
extends java.lang.Object
implements ConfigManager, SystemInfoProvider

Default implementation of a ConfigManager.

Possible extensions for further releases:


Constructor Summary
DefaultConfigManager()
          Creates a new DefaultConfigManager.
DefaultConfigManager(ConfigProvider parent)
          Creates a DefaultConfigManager using the given ConfigProvider as parent.
DefaultConfigManager(ConfigProvider parent, java.util.Map initialConfig)
          Creates a DefaultConfigManager with initial configuration and using the given ConfigProvider as parent.
DefaultConfigManager(java.util.Map initialConfig)
          Creates a DefaultConfigManager with initial configuration.
 
Method Summary
 void addConfigurationDescription(ConfigurationDescriptor configurationDescriptor)
          Adds a ConfigurationDescriptor to this ConfigManager.
 void addValue(java.lang.Class keyClass, java.lang.Object value)
          Registers a global implementation for an interface.
 void addValue(java.lang.String key, java.lang.Object value)
          Adds a value to the configuration.
 void addValuesFromMap(java.util.Map configMap)
          Adds values from the given configuration Map.
 void addValuesWithReader(ConfigReader configReader)
          Adds object values using the ConfigReader to the configuration.
 void collectSystemInfo(SystemInfoNode root, SystemInfoOptions options)
          Builds the system information tree upon local information of the implementor.
 Configuration getConfiguration(java.lang.Class configurationClass)
          Returns the implementation for the given interface class.
 ConfigProvider getParent()
          Returns the parent ConfigProvider or null, if no parent exists.
 java.lang.Object getValue(java.lang.Class keyClass)
          Returns the Object implementing a given interface.
 java.lang.Object getValue(java.lang.String key)
          Returns the Object corresponding to the given configuration key.
 boolean hasConfiguration(java.lang.Class configurationClass)
          Returns true, if there is a Configuration stored under the given configuration key class.
 java.lang.Object requireValue(java.lang.Class keyClass)
          Returns the Object implementing a given interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultConfigManager

public DefaultConfigManager()
Creates a new DefaultConfigManager.


DefaultConfigManager

public DefaultConfigManager(ConfigProvider parent)
Creates a DefaultConfigManager using the given ConfigProvider as parent.

Parameters:
parent - the parent ConfigProvider to use (not null)

DefaultConfigManager

public DefaultConfigManager(java.util.Map initialConfig)
Creates a DefaultConfigManager with initial configuration.

Parameters:
initialConfig - the initial configuration parameters. The keys must be either of type String or of type Class.

DefaultConfigManager

public DefaultConfigManager(ConfigProvider parent,
                            java.util.Map initialConfig)
Creates a DefaultConfigManager with initial configuration and using the given ConfigProvider as parent.

Parameters:
parent - the parent ConfigProvider to use (not null)
initialConfig - the initial configuration parameters. The keys must be either of type String or of type Class. Entries with key String will be available using getValue(java.lang.String) and entrie with key Class will be available using getValue(java.lang.Class).
Method Detail

getParent

public ConfigProvider getParent()
Returns the parent ConfigProvider or null, if no parent exists.


addConfigurationDescription

public void addConfigurationDescription(ConfigurationDescriptor configurationDescriptor)
Description copied from interface: ConfigManager
Adds a ConfigurationDescriptor to this ConfigManager. In advantage to adding a simple key-value-mapping, ConfigurationDescriptors allow lazy instantiation of the configuration values.

Specified by:
addConfigurationDescription in interface ConfigManager
Parameters:
configurationDescriptor - the ConfigurationDescriptor (not null)
See Also:
ConfigManager.addConfigurationDescription(com.sdm.quasar.client.core.common.config.ConfigurationDescriptor)

getValue

public java.lang.Object getValue(java.lang.String key)
Description copied from interface: ConfigProvider
Returns the Object corresponding to the given configuration key. If the key is unknown, null will be returned. Values may be added using one of the add-methods of the ConfigManager.

Specified by:
getValue in interface ConfigProvider
Parameters:
key - the key to the configuration entry (not null)
Returns:
the value of the configuration entry, may be null.
See Also:
ConfigProvider.getValue(java.lang.String)

getConfiguration

public Configuration getConfiguration(java.lang.Class configurationClass)
Description copied from interface: ConfigProvider
Returns the implementation for the given interface class.

Specified by:
getConfiguration in interface ConfigProvider
See Also:
ConfigProvider.getConfiguration(java.lang.Class)

hasConfiguration

public boolean hasConfiguration(java.lang.Class configurationClass)
Description copied from interface: ConfigProvider
Returns true, if there is a Configuration stored under the given configuration key class.

Specified by:
hasConfiguration in interface ConfigProvider
See Also:
ConfigProvider.hasConfiguration(java.lang.Class)

getValue

public java.lang.Object getValue(java.lang.Class keyClass)
Description copied from interface: ConfigProvider
Returns the Object implementing a given interface. This can be used as a global registry for implementations that are not Services.

Specified by:
getValue in interface ConfigProvider
Parameters:
keyClass - the class of the interface
Returns:
the registered implementation corresponding to the interface or null if there is no implementation registered for that interface
See Also:
ConfigProvider.getValue(java.lang.Class)

requireValue

public java.lang.Object requireValue(java.lang.Class keyClass)
Description copied from interface: ConfigProvider
Returns the Object implementing a given interface. In opposite to ConfigProvider.getValue(Class), throws an exception if the value is not contained.

Specified by:
requireValue in interface ConfigProvider
Parameters:
keyClass - the class of the interface
Returns:
the registered implementation corresponding to the interface
See Also:
ConfigProvider.requireValue(java.lang.Class)

addValue

public void addValue(java.lang.String key,
                     java.lang.Object value)
Description copied from interface: ConfigManager
Adds a value to the configuration. If the key has already a value assigned to, the old value will be replaced by the new value.

Specified by:
addValue in interface ConfigManager
Parameters:
key - the key to the configuration entry
value - the value of the configuration entry, may be null.
See Also:
ConfigManager.addValue(java.lang.String, java.lang.Object)

addValue

public void addValue(java.lang.Class keyClass,
                     java.lang.Object value)
Description copied from interface: ConfigManager
Registers a global implementation for an interface. The implementation is retrievable using ConfigProvider.getValue(Class).

Note The keyClass will be stored as full qualified class name.

Specified by:
addValue in interface ConfigManager
Parameters:
keyClass - the key class
value - the implementation for the given key class
See Also:
ConfigManager.addValue(java.lang.Class, java.lang.Object)

addValuesFromMap

public void addValuesFromMap(java.util.Map configMap)
Adds values from the given configuration Map. The keys must be either of type String or of type Class.


addValuesWithReader

public void addValuesWithReader(ConfigReader configReader)
                         throws java.io.IOException
Description copied from interface: ConfigManager
Adds object values using the ConfigReader to the configuration.

Specified by:
addValuesWithReader in interface ConfigManager
Parameters:
configReader - the ConfigReader to be used for reading the file and creating the configuration value
Throws:
java.io.IOException - if an exception occurs while reading the file.
See Also:
ConfigManager.addValuesWithReader(com.sdm.quasar.client.core.common.config.ConfigReader)

collectSystemInfo

public void collectSystemInfo(SystemInfoNode root,
                              SystemInfoOptions options)
Description copied from interface: SystemInfoProvider
Builds the system information tree upon local information of the implementor. The system information tree can be used within development by inspecting the system; so implementors should append their internal state (depending on the details settings within SystemInfoOptions). The information can be appended to the tree by adding new child SystemInformationNodes to the root node given using the SystemInfoNode.createChild(String) method and by setting information attributes the these nodes or the given root node.

Specified by:
collectSystemInfo in interface SystemInfoProvider
Parameters:
root - the SystemInfoNode to add information to (guaranteed to be not null)
options - contains additional options, that might influence the amount of information added to the tree (guaranteed to be not null)
See Also:
SystemInfoProvider.collectSystemInfo(com.sdm.quasar.client.core.common.sysinfo.SystemInfoNode, com.sdm.quasar.client.core.common.sysinfo.SystemInfoOptions)