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

java.lang.Object
  extended bycom.sdm.quasar.client.core.common.config.AbstractConfigurationDescriptor
All Implemented Interfaces:
ConfigurationDescriptor, Disposable
Direct Known Subclasses:
BeanCreatorConfigurationDescriptor

public abstract class AbstractConfigurationDescriptor
extends java.lang.Object
implements ConfigurationDescriptor

An abstract implementation of a ConfigurationDescriptor.

Version:
1.$Revision$
Author:
Thomas Wolf

Constructor Summary
AbstractConfigurationDescriptor(java.lang.Class configurationKeyClass)
          Creates a new AbstractConfigurationDescriptor.
AbstractConfigurationDescriptor(java.lang.String configurationKey)
          Creates a new AbstractConfigurationDescriptor.
 
Method Summary
protected abstract  java.lang.Object createConfigurationValue(java.lang.String key, ConfigProvider configProvider)
          Subclasses must implement this method to create the configuration value.
 void dispose()
          Disposes the component.
protected abstract  void disposeConfigurationValue(java.lang.String key, java.lang.Object value)
          Subclasses must implement this method to dispose the configuration value.
 java.lang.String getKey()
          Returns the key for the configuration entry.
 java.lang.Object getValue()
          Returns the configuration value.
 boolean isLoaded()
          Returns true, iff this ConfigurationDescriptor is loaded; this means, loadConfiguration(ConfigProvider) was called before and the value can be accessed.
 void loadConfiguration(ConfigProvider configProvider)
          Loads the configuration, which means, that getValue() might be called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractConfigurationDescriptor

public AbstractConfigurationDescriptor(java.lang.String configurationKey)
Creates a new AbstractConfigurationDescriptor.

Parameters:
configurationKey - the configuration key

AbstractConfigurationDescriptor

public AbstractConfigurationDescriptor(java.lang.Class configurationKeyClass)
Creates a new AbstractConfigurationDescriptor.

Method Detail

getKey

public final java.lang.String getKey()
Description copied from interface: ConfigurationDescriptor
Returns the key for the configuration entry.

Specified by:
getKey in interface ConfigurationDescriptor
See Also:
ConfigurationDescriptor.getKey()

getValue

public java.lang.Object getValue()
Description copied from interface: ConfigurationDescriptor
Returns the configuration value. The caller must ensure, that this method will only be called, if the ConfigurationDescriptor is loaded.

Specified by:
getValue in interface ConfigurationDescriptor
See Also:
ConfigurationDescriptor.getValue()

isLoaded

public boolean isLoaded()
Description copied from interface: ConfigurationDescriptor
Returns true, iff this ConfigurationDescriptor is loaded; this means, ConfigurationDescriptor.loadConfiguration(ConfigProvider) was called before and the value can be accessed.

Specified by:
isLoaded in interface ConfigurationDescriptor
See Also:
ConfigurationDescriptor.isLoaded()

loadConfiguration

public final void loadConfiguration(ConfigProvider configProvider)
Description copied from interface: ConfigurationDescriptor
Loads the configuration, which means, that ConfigurationDescriptor.getValue() might be called. The call occures only once, until Disposable.dispose() is called.

Specified by:
loadConfiguration in interface ConfigurationDescriptor
Parameters:
configProvider - the ConfigProvider, that may be used to access other values.
See Also:
ConfigurationDescriptor.loadConfiguration(com.sdm.quasar.client.core.common.config.ConfigProvider)

dispose

public final void dispose()
                   throws DisposeException
Description copied from interface: Disposable
Disposes the component.

Important:
This method is called by an administrating component and must never be called directly.

The implementation should release any resources or objects allocated and any services registered. Furthermore, this method should be developed carefully to free a maximum of resources even when the system may have become unstable. In case of one or multiple errors, you should collect them in a DisposeException, continue with the execution, and throw it at the end of the method.

Note: The implementation must not return before the component is disposed. Any threads or asynchronous calls started must be completed before this method returns.

Specified by:
dispose in interface Disposable
Throws:
DisposeException - if there was one or more errors while disposing the component.
See Also:
Disposable.dispose()

createConfigurationValue

protected abstract java.lang.Object createConfigurationValue(java.lang.String key,
                                                             ConfigProvider configProvider)
Subclasses must implement this method to create the configuration value.

Parameters:
key - the configuration key (not null)
configProvider - the ConfigProvider registered to (not null)
Returns:
the configuration value

disposeConfigurationValue

protected abstract void disposeConfigurationValue(java.lang.String key,
                                                  java.lang.Object value)
Subclasses must implement this method to dispose the configuration value.

Parameters:
key - the configuration key (not null)
value - the configuration value