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

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

@ThreadSafe
public abstract class AbstractConfigurationPropertiesManagement
     
     
extends AbstractConfigurationProperties
implements ConfigurationPropertiesManagement, ConfigurationPropertiesManagementSpi

Abstract implementation of the ConfigurationProperties interface.


Constructor Summary
protected AbstractConfigurationPropertiesManagement()
          Constructor for serializable subclasses.
protected AbstractConfigurationPropertiesManagement(ConfigurationKey key, PropertyDescriptorRegistry registry)
          Default constructor.
 
Method Summary
 ConfigurationPropertiesManagement addDefinitions(Properties properties)
          Adds the given definitions to this configuration.
 void addDescriptors(Class<?> propertySetType)
          Adds all property descriptors declared in the given type.
protected abstract  Property deletePropertyInStore(String name)
          Deletes the property with the given name.
 void flush()
          Signal to flush properties changed in memory to be written to a secondary storage.
 PropertyDescriptor getDescriptor(PropertyKey key)
          Returns the descriptor for the given key.
 PropertyDescriptor getDescriptor(String key)
          Returns the descriptor for the given key.
 List<PropertyDescriptor> getMandatoryPropertyDescriptors()
          Returns the list of mandatory properties.
 Property getProperty(PropertyDescriptor descriptor, Object defaultValue)
          Returns the property for the given descriptor, allowing to transparently provide a default value to be returned in case the property has not been set.
 Property getProperty(String key, Object defaultValue)
          Returns the property for the given key, allowing to transparently provide a default value to be returned in case the property has not been set.
protected abstract  PropertyCollection getPropertyCollectionFromStore()
          Returns a collection to iterate over all properties of the configuration.
protected abstract  Property getPropertyFromStore(String name)
          Fetches the property from the store by the given name.
 ResolvedProperty getResolvedProperty(PropertyDescriptor descriptor, Object defaultValue)
          Returns the resolved property for the given descriptor's key, allowing to transparently provide a default value to be returned in case the property has not been set.
 Property setProperty(PropertyKey key, String value)
          Sets the property value for the given key.
protected abstract  Property setPropertyToStore(String name, String value)
          Sets the property to the given value.
 Property unsetProperty(PropertyKey key)
          Unsets the property value for the given key.
 void validate(boolean lenient)
          Validates all properties in the given configuration.
 
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, toString, 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
getRegistry, toSerializable
 
Methods inherited from interface de.smartics.properties.spi.config.support.ConfigurationPropertiesSpi
getProperties
 
Methods inherited from interface de.smartics.properties.api.config.domain.ConfigurationProperties
addPropertyChangeListener, addPropertyChangeListener, getContext, getContext, getKey, getProperties, getProperty, getProperty, getProperty, getPropertyValue, getPropertyValue, getPropertyValue, getPropertyValue, getPropertyValue, getPropertyValueAsString, getPropertyValueAsString, getPropertyValueAsString, getPropertyValueAsString, getResolvedProperty, getResolvedProperty, removePropertyChangeListener, removePropertyChangeListener, validate
 

Constructor Detail

AbstractConfigurationPropertiesManagement

protected AbstractConfigurationPropertiesManagement()
Constructor for serializable subclasses.


AbstractConfigurationPropertiesManagement

protected AbstractConfigurationPropertiesManagement(ConfigurationKey key,
                                                    PropertyDescriptorRegistry registry)
                                             throws de.smartics.util.lang.NullArgumentException
Default constructor.

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.
Method Detail

getDescriptor

public final PropertyDescriptor getDescriptor(String key)
                                       throws UnknownPropertyException
Description copied from interface: ConfigurationPropertiesManagement
Returns the descriptor for the given key.

Specified by:
getDescriptor in interface ConfigurationPropertiesManagement
Parameters:
key - the of the requested descriptor.
Returns:
the descriptor whose key matches the given key.
Throws:
UnknownPropertyException - if the property is not known.

getDescriptor

public final PropertyDescriptor getDescriptor(PropertyKey key)
                                       throws UnknownPropertyException
Description copied from interface: ConfigurationPropertiesManagement
Returns the descriptor for the given key.

Specified by:
getDescriptor in interface ConfigurationPropertiesManagement
Parameters:
key - the of the requested descriptor.
Returns:
the descriptor whose key matches the given key.
Throws:
UnknownPropertyException - if the property is not known.

addDescriptors

public final void addDescriptors(Class<?> propertySetType)
                          throws DuplicatePropertyDeclarationsException
Description copied from interface: ConfigurationPropertiesManagement
Adds all property descriptors declared in the given type.

Specified by:
addDescriptors in interface ConfigurationPropertiesManagement
Parameters:
propertySetType - the type that declares the descriptors.
Throws:
DuplicatePropertyDeclarationsException - if any of the descriptors declare the same property.

getMandatoryPropertyDescriptors

public final List<PropertyDescriptor> getMandatoryPropertyDescriptors()
Description copied from interface: ConfigurationPropertiesManagement
Returns the list of mandatory properties.

Returns a copy that can be edited.

Specified by:
getMandatoryPropertyDescriptors in interface ConfigurationPropertiesManagement
Returns:
the list of mandatory properties.

addDefinitions

public final ConfigurationPropertiesManagement addDefinitions(Properties properties)
                                                       throws NullPointerException
Description copied from interface: ConfigurationPropertiesManagement
Adds the given definitions to this configuration.

Specified by:
addDefinitions in interface ConfigurationPropertiesManagement
Parameters:
properties - the property definitions to add.
Returns:
a reference to this configuration for chaining.
Throws:
NullPointerException - if properties is null.

getProperty

public final Property getProperty(String key,
                                  Object defaultValue)
                           throws IllegalArgumentException,
                                  UnknownPropertyException
Description copied from interface: ConfigurationProperties
Returns the property for the given key, allowing to transparently provide a default value to be returned in case the property has not been set.

Specified by:
getProperty in interface ConfigurationProperties
Overrides:
getProperty in class AbstractConfigurationProperties
Parameters:
key - the unique key of the property.
defaultValue - the default value to use in case no value has been specified.
Returns:
the requested property.
Throws:
IllegalArgumentException - if key is blank.
UnknownPropertyException - if key is not known.

getProperty

public final Property getProperty(PropertyDescriptor descriptor,
                                  Object defaultValue)
                           throws IllegalArgumentException,
                                  UnknownPropertyException
Description copied from interface: ConfigurationProperties
Returns the property for the given descriptor, allowing to transparently provide a default value to be returned in case the property has not been set.

Specified by:
getProperty in interface ConfigurationProperties
Parameters:
descriptor - the descriptor containing the unique key of the property.
defaultValue - the default value to use in case no value has been specified.
Returns:
the requested property.
Throws:
UnknownPropertyException - if the key of the descriptor is not known.
IllegalArgumentException

getResolvedProperty

public final ResolvedProperty getResolvedProperty(PropertyDescriptor descriptor,
                                                  Object defaultValue)
                                           throws IllegalArgumentException,
                                                  UnknownPropertyException,
                                                  PropertyValidationException
Description copied from interface: ConfigurationProperties
Returns the resolved property for the given descriptor's key, allowing to transparently provide a default value to be returned in case the property has not been set.

Specified by:
getResolvedProperty in interface ConfigurationProperties
Parameters:
descriptor - descriptor key to the property.
defaultValue - the default value to use in case no value has been specified.
Returns:
the resolved property. Never null, although the value / resolved value of the returned property may be null.
Throws:
IllegalArgumentException - if key is blank.
UnknownPropertyException - if key is not known.
PropertyValidationException - if the property is invalid according to its constraints.

setProperty

public final Property setProperty(PropertyKey key,
                                  String value)
                           throws NullPointerException,
                                  PropertyValidationException,
                                  ReadOnlyPropertyException
Description copied from interface: ConfigurationPropertiesManagement
Sets the property value for the given key.

Specified by:
setProperty in interface ConfigurationPropertiesManagement
Parameters:
key - the key to the property.
value - the value to the property.
Returns:
the old value to the property. A value of null is returned if the property had no value prior to this call.
Throws:
NullPointerException - if key is null.
PropertyValidationException - if the property value is invalid according to its constraints.
ReadOnlyPropertyException - if the property to update is read-only.

unsetProperty

public final Property unsetProperty(PropertyKey key)
                             throws NullPointerException,
                                    ReadOnlyPropertyException
Description copied from interface: ConfigurationPropertiesManagement
Unsets the property value for the given key.

Specified by:
unsetProperty in interface ConfigurationPropertiesManagement
Parameters:
key - the key to the property.
Returns:
the old value to the property. A value of null is returned if the property had no value prior to this call.
Throws:
NullPointerException - if key is null.
ReadOnlyPropertyException - if the property to update is read-only.

validate

public final void validate(boolean lenient)
                    throws ConfigurationValidationException
Description copied from interface: ConfigurationProperties
Validates all properties in the given configuration.

Specified by:
validate in interface ConfigurationProperties
Parameters:
lenient - the lenient flag that tells the validation process to handle unknown properties gracefully if set to true. If the value is false unknown properties are reported as validation failures.
Throws:
ConfigurationValidationException - if the configuration contains properties that do not meet the required constraints.

flush

public void flush()
Signal to flush properties changed in memory to be written to a secondary storage.

Implementations are not required to only write on a flush. They have to make sure that after the flush is called, all data is transfered to the secondary storage.

This implementation does nothing on a flush. Should be overridden by implementations that do want to take actions on a flush.

Specified by:
flush in interface ConfigurationPropertiesManagement

setPropertyToStore

protected abstract Property setPropertyToStore(String name,
                                               String value)
                                        throws NullPointerException
Sets the property to the given value.

Implementation Notes:
No property change listeners are informed here. This is solely the call to the underlying store.
Parameters:
name - 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:
NullPointerException - if name is null.

getPropertyCollectionFromStore

protected abstract PropertyCollection getPropertyCollectionFromStore()
Returns a collection to iterate over all properties of the configuration.

Implementation Notes:
No property change listeners are informed here. This is solely the call to the underlying store.
Returns:
a collection to iterate over all properties of the configuration.

deletePropertyInStore

protected abstract Property deletePropertyInStore(String name)
Deletes the property with the given name.

Implementation Notes:
No property change listeners are informed here. This is solely the call to the underlying store.
Parameters:
name - the name of the property to delete.
Returns:
the value of the deleted property.

getPropertyFromStore

protected abstract Property getPropertyFromStore(String name)
Fetches the property from the store by the given name.

Implementation Notes:
No property change listeners are informed here. This is solely the call to the underlying store.
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).


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