de.smartics.properties.spi.config.support
Class AbstractInMemoryConfigurationProperties

Package class diagram package AbstractInMemoryConfigurationProperties
java.lang.Object
  extended by de.smartics.properties.spi.config.support.AbstractConfigurationProperties
      extended by de.smartics.properties.spi.config.support.AbstractConfigurationPropertiesManagement
          extended by de.smartics.properties.spi.config.support.AbstractInMemoryConfigurationProperties
All Implemented Interfaces:
ConfigurationProperties, ConfigurationPropertiesManagement, SerializableConfigurationProperties, SerializableConfigurationPropertiesManagement, ConfigurationPropertiesManagementSpi, ConfigurationPropertiesSpi, Serializable
Direct Known Subclasses:
BootConfigurationProperties, ClasspathConfigurationProperties, PropertiesConfigurationProperties

@ThreadSafe
public abstract class AbstractInMemoryConfigurationProperties
     
     
extends AbstractConfigurationPropertiesManagement
implements SerializableConfigurationPropertiesManagement

An implementation that stores all properties in-memory.

See Also:
Serialized Form

Constructor Summary
AbstractInMemoryConfigurationProperties(ConfigurationKey key, PropertyDescriptorRegistry registry)
          Convenience constructor requiring that a properties file with the same name as the properties set class exists on the class path.
AbstractInMemoryConfigurationProperties(ConfigurationKey key, PropertyDescriptorRegistry registry, boolean requiresDefaultOnClassPath)
          Default constructor requiring that a properties file with the same name as the properties set class exists on the class path.
 
Method Summary
 AbstractInMemoryConfigurationProperties addClassPathProperties(Class<?> propertiesInterface)
          Loads the properties for the given properties interface from the class path.
protected  Property deletePropertyInStore(String name)
          Deletes the property with the given name.
protected  PropertyCollection getPropertyCollectionFromStore()
          Returns a collection to iterate over all properties of the configuration.
protected  Property getPropertyFromStore(String name)
          Fetches the property from the store by the given name.
 Property setPropertyToStore(String key, String value)
          Sets the property to the given value.
 String toString()
          Returns the string representation of the object.
 
Methods inherited from class de.smartics.properties.spi.config.support.AbstractConfigurationPropertiesManagement
addDefinitions, addDescriptors, flush, getDescriptor, getDescriptor, getMandatoryPropertyDescriptors, getProperty, getProperty, getResolvedProperty, setProperty, unsetProperty, validate
 
Methods inherited from class de.smartics.properties.spi.config.support.AbstractConfigurationProperties
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, getContext, getContext, getKey, getProperties, getProperties, getProperty, getProperty, getProperty, getPropertyDescriptor, getPropertyValue, getPropertyValue, getPropertyValue, getPropertyValue, getPropertyValue, getPropertyValueAsString, getPropertyValueAsString, getPropertyValueAsString, getPropertyValueAsString, getRegistry, getResolvedProperty, getResolvedProperty, removePropertyChangeListener, removePropertyChangeListener, resolveAndConvert, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.smartics.properties.api.config.domain.ConfigurationPropertiesManagement
addDefinitions, addDescriptors, flush, getDescriptor, getDescriptor, getMandatoryPropertyDescriptors, getRegistry, setProperty, toSerializable, unsetProperty
 
Methods inherited from interface de.smartics.properties.api.config.domain.ConfigurationProperties
addPropertyChangeListener, addPropertyChangeListener, getContext, getContext, getKey, getProperties, getProperty, getProperty, getProperty, getProperty, getProperty, getPropertyValue, getPropertyValue, getPropertyValue, getPropertyValue, getPropertyValue, getPropertyValueAsString, getPropertyValueAsString, getPropertyValueAsString, getPropertyValueAsString, getResolvedProperty, getResolvedProperty, getResolvedProperty, removePropertyChangeListener, removePropertyChangeListener, validate, validate
 
Methods inherited from interface de.smartics.properties.spi.config.support.ConfigurationPropertiesSpi
getProperties
 

Constructor Detail

AbstractInMemoryConfigurationProperties

public AbstractInMemoryConfigurationProperties(ConfigurationKey key,
                                               PropertyDescriptorRegistry registry)
                                        throws de.smartics.util.lang.NullArgumentException
Convenience constructor requiring that a properties file with the same name as the properties set class exists on the class path.

Parameters:
key - the key that identifies the configuration.
registry - the registry to resolve property descriptors.
Throws:
de.smartics.util.lang.NullArgumentException - if key or registry is null.

AbstractInMemoryConfigurationProperties

public AbstractInMemoryConfigurationProperties(ConfigurationKey key,
                                               PropertyDescriptorRegistry registry,
                                               boolean requiresDefaultOnClassPath)
                                        throws de.smartics.util.lang.NullArgumentException
Default constructor requiring that a properties file with the same name as the properties set class exists on the class path.

Parameters:
key - the key that identifies the configuration.
registry - the registry to resolve property descriptors.
requiresDefaultOnClassPath - the flag controls the behavior on not finding default properties on the classpath.
Throws:
de.smartics.util.lang.NullArgumentException - if key or registry is null.
Method Detail

getPropertyFromStore

protected final Property getPropertyFromStore(String name)
Description copied from class: AbstractConfigurationPropertiesManagement
Fetches the property from the store by the given name.

Specified by:
getPropertyFromStore in class AbstractConfigurationPropertiesManagement
Parameters:
name - the name of the property to fetch.
Returns:
the property value. Must not be null (although the value of the property may be null).

setPropertyToStore

public final Property setPropertyToStore(String key,
                                         String value)
                                  throws PropertyValidationException,
                                         ReadOnlyPropertyException
Description copied from class: AbstractConfigurationPropertiesManagement
Sets the property to the given value.

Specified by:
setPropertyToStore in class AbstractConfigurationPropertiesManagement
Parameters:
key - the name of the property to set.
value - the value to the property.
Returns:
the old property. Must not be null (although the value of the property may be null).
Throws:
PropertyValidationException
ReadOnlyPropertyException

deletePropertyInStore

protected final Property deletePropertyInStore(String name)
Description copied from class: AbstractConfigurationPropertiesManagement
Deletes the property with the given name.

Specified by:
deletePropertyInStore in class AbstractConfigurationPropertiesManagement
Parameters:
name - the name of the property to delete.
Returns:
the value of the deleted property.

getPropertyCollectionFromStore

protected final PropertyCollection getPropertyCollectionFromStore()
Description copied from class: AbstractConfigurationPropertiesManagement
Returns a collection to iterate over all properties of the configuration.

Specified by:
getPropertyCollectionFromStore in class AbstractConfigurationPropertiesManagement
Returns:
a collection to iterate over all properties of the configuration.

addClassPathProperties

public final AbstractInMemoryConfigurationProperties addClassPathProperties(Class<?> propertiesInterface)
                                                                     throws de.smartics.util.lang.NullArgumentException,
                                                                            ConfigurationLoadingException
Loads the properties for the given properties interface from the class path.

The properties file is expected to be at the same location with a name identical to the interface plus the file extension .properties .

Parameters:
propertiesInterface - the properties defining interface whose properties are loaded.
Returns:
a reference to this configuration for chaining.
Throws:
de.smartics.util.lang.NullArgumentException - if propertiesInterface is null.
ConfigurationLoadingException - if the properties file cannot be loaded.

toString

public String toString()
Returns the string representation of the object.

Overrides:
toString in class AbstractConfigurationProperties
Returns:
the string representation of the object.


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