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, ConfigurationPropertiesManagementFactory, Serializable
Direct Known Subclasses:
AutodetectDataSourceConfigurationPropertiesFactory, ClasspathConfigurationPropertiesFactory, DataSourceConfigurationPropertiesFactory, JndiConfigurationPropertiesFactory, PropertiesConfigurationPropertiesFactory, ResourceConfigurationPropertiesFactory

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

Base implementation of the ConfigurationPropertiesManagementFactory.

See Also:
Serialized Form

Constructor Summary
protected 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.
 String addRootUrls(de.smartics.properties.resource.domain.ArtifactId artifactId)
          Adds the URLs derived from the dependencies provided by the given artifactId to the locations to search for property declarations and definitions.
 T create(ConfigurationKey<?> key)
          Creates the configuration properties instance 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.
 de.smartics.properties.resource.domain.ArtifactRef getArtifactRef(String artifactId)
          Returns the artifact reference by its short ID.
 FactoryConfiguration getFactoryConfiguration()
          Returns the factory configuration and changes values.
 String getId()
          Returns the unique id for this factory
 Collection<ConfigurationKey<?>> getRegisteredConfigurationKeys()
          Returns a list of keys to the registered configurations.
 de.smartics.properties.api.core.domain.PropertyDescriptorRegistry getRegistry()
          Returns the registry of declarations used by all created configurations.
 Collection<ConfigurationKey<?>> materialize()
          Materializes all configurations found by this factory.
 void release()
          Releases resources acquired by this instance.
 ConfigurationPropertiesManagement remove(ConfigurationKey<?> key)
          Removes the configuration with the given key from the cache.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractConfigurationPropertiesFactory

protected AbstractConfigurationPropertiesFactory()
Default constructor.

Method Detail

getId

public String getId()
Description copied from interface: ConfigurationPropertiesFactory
Returns the unique id for this factory

Specified by:
getId in interface ConfigurationPropertiesFactory
Returns:
the uniqu id.

getRegistry

public final de.smartics.properties.api.core.domain.PropertyDescriptorRegistry getRegistry()
Description copied from interface: ConfigurationPropertiesFactory
Returns the registry of declarations used by all created configurations.

Specified by:
getRegistry in interface ConfigurationPropertiesFactory
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.

addRootUrls

public final String addRootUrls(de.smartics.properties.resource.domain.ArtifactId artifactId)
                         throws de.smartics.util.lang.NullArgumentException,
                                de.smartics.properties.resource.repository.RepositoryException,
                                CompoundConfigurationException
Description copied from interface: ConfigurationPropertiesManagementFactory
Adds the URLs derived from the dependencies provided by the given artifactId 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:
addRootUrls in interface ConfigurationPropertiesManagementFactory
Parameters:
artifactId - the reference to the property resources.
Returns:
the URL to the remote repository to fetch the artifact.
Throws:
de.smartics.util.lang.NullArgumentException - if artifactId is null.
de.smartics.properties.resource.repository.RepositoryException - on any problem accessing the remote repository.
CompoundConfigurationException - if loading property resources encountered problems.

getArtifactRef

public final de.smartics.properties.resource.domain.ArtifactRef getArtifactRef(String artifactId)
                                                                        throws NullPointerException
Description copied from interface: ConfigurationPropertiesManagementFactory
Returns the artifact reference by its short ID.

Specified by:
getArtifactRef in interface ConfigurationPropertiesManagementFactory
Parameters:
artifactId - the GAV concatenated and separated by colons.
Returns:
the associated artifact reference or null if there is no artifact reference with the given artifactId registered.
Throws:
NullPointerException - if artifactId is null.

getRegisteredConfigurationKeys

public final 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: ConfigurationPropertiesManagementFactory
Creates the configuration properties instance for the given key.

Specified by:
create in interface ConfigurationPropertiesFactory
Specified by:
create in interface ConfigurationPropertiesManagementFactory
Parameters:
key - the key to identify the requested configuration.
Returns:
the requested configuration.
Throws:
NullPointerException - if key is null.
ConfigurationException - on any problem loading the configuration properties.
See Also:
ConfigurationPropertiesFactory.createManagement(ConfigurationKey), EnvAppConfigurationKeyHelper

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), EnvAppConfigurationKeyHelper

materialize

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

Specified by:
materialize 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.

release

public void release()
Description copied from interface: ConfigurationPropertiesManagementFactory
Releases resources acquired by this instance.

Specified by:
release in interface ConfigurationPropertiesManagementFactory

remove

public final ConfigurationPropertiesManagement remove(ConfigurationKey<?> key)
                                               throws NullPointerException
Description copied from interface: ConfigurationPropertiesManagementFactory
Removes the configuration with the given key from the cache.

Specified by:
remove in interface ConfigurationPropertiesManagementFactory
Parameters:
key - the key of the configuration to remove.
Returns:
a reference to the removed configuration.
Throws:
NullPointerException - if key is null.

toString

public String toString()
Overrides:
toString in class Object


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