de.smartics.properties.spi.config.support
Class AbstractConfigurationPropertiesFactory<T extends ConfigurationPropertiesManagement>

Package class diagram package AbstractConfigurationPropertiesFactory
java.lang.Object
  extended by de.smartics.properties.spi.config.support.AbstractConfigurationPropertiesFactory<T>
Type Parameters:
T - the concrete type of the returned configuration properties.
All Implemented Interfaces:
ConfigurationPropertiesFactory, Serializable
Direct Known Subclasses:
ClasspathConfigurationPropertiesFactory, DataSourceConfigurationPropertiesFactory, PropertiesConfigurationPropertiesFactory, ResourceConfigurationPropertiesFactory

@ThreadSafe
public abstract class AbstractConfigurationPropertiesFactory<T extends ConfigurationPropertiesManagement>
     
     
extends Object
implements ConfigurationPropertiesFactory

Base implementation of the ConfigurationPropertiesFactory.

See Also:
Serialized Form

Constructor Summary
AbstractConfigurationPropertiesFactory()
          Default constructor.
 
Method Summary
 void addPropertyProviders(Collection<PropertyProvider> providers)
          Adds the given providers of properties as additional property definitions.
 void addPropertyProviders(PropertyProvider... providers)
          Adds the given providers of properties as additional property definitions.
 void addRootLocations(Collection<URL> urls)
          Adds the given URLs to the locations to search for property declarations and definitions.
 void addRootLocations(URL... urls)
          Adds the given additional URLs to the locations to search for property declarations and definitions.
 T create(ConfigurationKey key)
          Returns the configuration properties for the given key.
 T createDefault()
          Returns the configuration for the default key.
 ConfigurationPropertiesManagement createDefaultManagement()
          Returns the management view on a configuration for the default key.
 T createManagement(ConfigurationKey key)
          Returns the configuration properties for the given key.
protected abstract  T createNewConfiguration(ConfigurationKey key)
          Creates an empty instance of the configuration properties instance.
 FactoryConfiguration getFactoryConfiguration()
          Returns the factory configuration and changes values.
 Collection<ConfigurationKey> getRegisteredConfigurationKeys()
          Returns a list of keys to the registered configurations.
 PropertyDescriptorRegistry getRegistry()
          Returns the registry of declarations used by all created configurations.
 Collection<ConfigurationKey> matrialize()
          Materializes all configurations found by this factory.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractConfigurationPropertiesFactory

public AbstractConfigurationPropertiesFactory()
Default constructor.

Method Detail

getRegistry

public final PropertyDescriptorRegistry getRegistry()
Returns the registry of declarations used by all created configurations.

Returns:
the registry of declarations used by all created configurations.

getFactoryConfiguration

public final FactoryConfiguration getFactoryConfiguration()
Description copied from interface: ConfigurationPropertiesFactory
Returns the factory configuration and changes values.

Since factories are not thread-safe according to configuration changes, it is expected that the factory is configured prior to any creation calls.

Specified by:
getFactoryConfiguration in interface ConfigurationPropertiesFactory
Returns:
a reference to the factory configuration.

addRootLocations

public final void addRootLocations(Collection<URL> urls)
Description copied from interface: ConfigurationPropertiesFactory
Adds the given URLs to the locations to search for property declarations and definitions. Property definitions are e.g. properties files or similar resources that define the actual value of a property.

Adding URLs only affects later creations of ConfigurationProperties instances.

Specified by:
addRootLocations in interface ConfigurationPropertiesFactory
Parameters:
urls - the URLs to add as search location. If the list is empty or urls is null, nothing is added without a warning.

addRootLocations

public final void addRootLocations(URL... urls)
Description copied from interface: ConfigurationPropertiesFactory
Adds the given additional URLs to the locations to search for property declarations and definitions. Property definitions are e.g. properties files or similar resources that define the actual value of a property.

Adding URLs only affects later creations of ConfigurationProperties instances.

Specified by:
addRootLocations in interface ConfigurationPropertiesFactory
Parameters:
urls - the URLs to add as search location. If the list is empty or urls is null, nothing is added without a warning.

addPropertyProviders

public final void addPropertyProviders(Collection<PropertyProvider> providers)
Description copied from interface: ConfigurationPropertiesFactory
Adds the given providers of properties as additional property definitions.

Adding providers only affects later creations of ConfigurationProperties instances.

Specified by:
addPropertyProviders in interface ConfigurationPropertiesFactory
Parameters:
providers - property providers for additional property name-value pairs. If the list is empty or providers is null, nothing is added without a warning.

addPropertyProviders

public final void addPropertyProviders(PropertyProvider... providers)
Description copied from interface: ConfigurationPropertiesFactory
Adds the given providers of properties as additional property definitions.

Adding providers only affects later creations of ConfigurationProperties instances.

Specified by:
addPropertyProviders in interface ConfigurationPropertiesFactory
Parameters:
providers - property providers for additional property name-value pairs. If the list is empty or providers is null, nothing is added without a warning.

getRegisteredConfigurationKeys

public Collection<ConfigurationKey> getRegisteredConfigurationKeys()
Description copied from interface: ConfigurationPropertiesFactory
Returns a list of keys to the registered configurations.

Specified by:
getRegisteredConfigurationKeys in interface ConfigurationPropertiesFactory
Returns:
the list of configuration keys.

create

public final T create(ConfigurationKey key)
                                                         throws NullPointerException,
                                                                ConfigurationException
Description copied from interface: ConfigurationPropertiesFactory
Returns the configuration properties for the given key. May return a cached instance.

Specified by:
create in interface ConfigurationPropertiesFactory
Parameters:
key - the identifier of the configuration properties that is requested.
Returns:
the requested configuration properties. Never null.
Throws:
NullPointerException - if key is null.
ConfigurationException - on any problem loading the configuration properties.
See Also:
ConfigurationPropertiesFactory.createManagement(ConfigurationKey), ConfigurationKeyHelper

createDefault

public final T createDefault()
Description copied from interface: ConfigurationPropertiesFactory
Returns the configuration for the default key. The default key is not associated with a particular environment or application.

Specified by:
createDefault in interface ConfigurationPropertiesFactory
Returns:
the requested configuration properties. Never null.

createDefaultManagement

public final ConfigurationPropertiesManagement createDefaultManagement()
Description copied from interface: ConfigurationPropertiesFactory
Returns the management view on a configuration for the default key. The default key is not associated with a particular environment or application.

Specified by:
createDefaultManagement in interface ConfigurationPropertiesFactory
Returns:
the requested configuration properties. Never null.

createManagement

public final T createManagement(ConfigurationKey key)
                                                                   throws NullPointerException,
                                                                          ConfigurationException
Description copied from interface: ConfigurationPropertiesFactory
Returns the configuration properties for the given key. May return a cached instance.

Specified by:
createManagement in interface ConfigurationPropertiesFactory
Parameters:
key - the identifier of the configuration properties that is requested.
Returns:
the requested configuration properties. Never null.
Throws:
NullPointerException - if key is null.
ConfigurationException - on any problem loading the configuration properties.
See Also:
ConfigurationPropertiesFactory.create(ConfigurationKey), ConfigurationKeyHelper

matrialize

public final Collection<ConfigurationKey> matrialize()
Description copied from interface: ConfigurationPropertiesFactory
Materializes all configurations found by this factory.

Specified by:
matrialize in interface ConfigurationPropertiesFactory
Returns:
the collection of keys of the materialized configuration. May be empty, but is never null.

createNewConfiguration

protected abstract T createNewConfiguration(ConfigurationKey key)
                                                                               throws NullPointerException,
                                                                                      ConfigurationException
Creates an empty instance of the configuration properties instance. Where the public create methods may consult a cache, this method is required to create a new instance.

Parameters:
key - the key to the instance.
Returns:
the instance. Never null.
Throws:
NullPointerException - if key is null.
ConfigurationException - if the configuration cannot be created.

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2012-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.