de.smartics.properties.spi.config.domain
Class ConfigurationPropertiesProxy

Package class diagram package ConfigurationPropertiesProxy
java.lang.Object
  extended by de.smartics.properties.spi.config.domain.ConfigurationPropertiesProxy
All Implemented Interfaces:
ConfigurationProperties, SerializableConfigurationProperties, Serializable
Direct Known Subclasses:
ConfigurationPropertiesManagementProxy

public class ConfigurationPropertiesProxy
     
     
extends Object
implements SerializableConfigurationProperties

A serialization proxy that allows non serializable configuration properties instances to be serialized using their factories cache and ability to recreate that instances.

See Also:
Serialized Form

Constructor Summary
ConfigurationPropertiesProxy(ConfigurationKey key, ConfigurationPropertiesFactory factory)
          Default constructor.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds the given listener to track any property changes.
 void addPropertyChangeListener(PropertyKey name, PropertyChangeListener listener)
          Adds the given listener as a listener to the given property.
 PropertiesContext getContext(Class<?> declaringType)
          Returns the properties context for the declaring type.
 PropertyContext getContext(PropertyDescriptor descriptor)
          Returns the properties context the property described by the given descriptor is part of.
protected  ConfigurationPropertiesFactory getFactory()
          Returns the factory to create instances of the configuration properties.
 ConfigurationKey getKey()
          Returns the key of the configuration properties instance is to be associated with.
<T> T
getProperties(Class<T> propertiesInterface)
          Returns a implementation of the given interface that has access to the property keys, the property descriptors and the properties itself, when they are declared in the given interface.
 Property getProperty(PropertyDescriptor descriptor)
          Returns the property for the given descriptor.
 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(PropertyKey key)
          Returns the property for the given key.
 Property getProperty(String key)
          Returns the property for the given key.
 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.
 Object getPropertyValue(PropertyDescriptor descriptor)
          Returns the property value for the given descriptor.
 Object getPropertyValue(PropertyDescriptor descriptor, Object defaultValue)
          Returns the property value for the given descriptor, allowing to transparently provide a default value to be returned in case the property has not been set.
 Object getPropertyValue(PropertyKey key)
          Returns the property value for the given key.
 Object getPropertyValue(String key)
          Returns the property value for the given key.
 Object getPropertyValue(String key, Object defaultValue)
          Returns the property value for the given key, allowing to transparently provide a default value to be returned in case the property has not been set.
 String getPropertyValueAsString(PropertyDescriptor descriptor)
          Returns the property string value for the given descriptor.
 String getPropertyValueAsString(PropertyDescriptor descriptor, Object defaultValue)
          Returns the property string value for the given descriptor.
 String getPropertyValueAsString(String key)
          Returns the property string value for the given key.
 String getPropertyValueAsString(String key, Object defaultValue)
          Returns the property string value for the given key.
 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.
 ResolvedProperty getResolvedProperty(PropertyKey key, Object defaultValue)
          Returns the resolved property for the given key, allowing to transparently provide a default value to be returned in case the property has not been set.
 ResolvedProperty getResolvedProperty(String key, Object defaultValue)
          Returns the resolved property for the given key, allowing to transparently provide a default value to be returned in case the property has not been set.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes the given listener to stop tracking property changes.
 void removePropertyChangeListener(PropertyKey name, PropertyChangeListener listener)
          Removes the given listener as a listener to the given property.
 SerializableConfigurationProperties toSerializable()
          Creates a serializable variant of this implementation.
 void validate()
          Validates all properties in the given configuration in a non-lenient fashion.
 void validate(boolean lenient)
          Validates all properties in the given configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationPropertiesProxy

public ConfigurationPropertiesProxy(ConfigurationKey key,
                                    ConfigurationPropertiesFactory factory)
Default constructor.

Parameters:
key - the key of the configuration properties instance is to be associated with
factory - the factory to create instances of the configuration properties.
Method Detail

getKey

public final ConfigurationKey getKey()
Returns the key of the configuration properties instance is to be associated with.

Specified by:
getKey in interface ConfigurationProperties
Returns:
the key of the configuration properties instance is to be associated with.

getFactory

protected final ConfigurationPropertiesFactory getFactory()
Returns the factory to create instances of the configuration properties.

Returns:
the factory to create instances of the configuration properties.

getContext

public final PropertiesContext getContext(Class<?> declaringType)
                                   throws NullPointerException
Description copied from interface: ConfigurationProperties
Returns the properties context for the declaring type. The declaring type is the interface type annotated with the PropertySet annotation. The context provides information about the properties of that set.

Specified by:
getContext in interface ConfigurationProperties
Parameters:
declaringType - the type that declares the properties whose context is requested.
Returns:
the context for the properties declared by the given type.
Throws:
NullPointerException - if declaringType is null.

getContext

public final PropertyContext getContext(PropertyDescriptor descriptor)
                                 throws NullPointerException
Description copied from interface: ConfigurationProperties
Returns the properties context the property described by the given descriptor is part of.

Specified by:
getContext in interface ConfigurationProperties
Parameters:
descriptor - the descriptor of the property whose context is requested.
Returns:
the context of the property described by the descriptor.
Throws:
NullPointerException - if descriptor is null.

getProperties

public final <T> T getProperties(Class<T> propertiesInterface)
Description copied from interface: ConfigurationProperties
Returns a implementation of the given interface that has access to the property keys, the property descriptors and the properties itself, when they are declared in the given interface. The interface must be annotated with an PropertySet annotation.

Specified by:
getProperties in interface ConfigurationProperties
Type Parameters:
T - type variable to enable a type save return value.
Parameters:
propertiesInterface - a PropertySet annotated interface for which a implementation to access the property keys, descriptors and values is requested.
Returns:
a implementation of the given interface to access property information.

getPropertyValue

public final Object getPropertyValue(PropertyDescriptor descriptor)
                              throws NullPointerException,
                                     PropertyValidationException
Description copied from interface: ConfigurationProperties
Returns the property value for the given descriptor.

Specified by:
getPropertyValue in interface ConfigurationProperties
Parameters:
descriptor - the key to the property.
Returns:
the value to the property. A value of null is returned in cause of an optional property being not set.
Throws:
NullPointerException - if descriptor is null.
PropertyValidationException - if the property is invalid according to its constraints.

getPropertyValue

public final Object getPropertyValue(String key)
                              throws IllegalArgumentException,
                                     UnknownPropertyException,
                                     PropertyValidationException
Description copied from interface: ConfigurationProperties
Returns the property value for the given key.

Specified by:
getPropertyValue in interface ConfigurationProperties
Parameters:
key - the key to the property.
Returns:
the value to the property. A value of null is returned in cause of an optional property being not set.
Throws:
IllegalArgumentException - if key is blank.
UnknownPropertyException - if key is not known.
PropertyValidationException - if the property is invalid according to its constraints.

getPropertyValue

public final Object getPropertyValue(PropertyKey key)
                              throws IllegalArgumentException,
                                     UnknownPropertyException,
                                     PropertyValidationException
Description copied from interface: ConfigurationProperties
Returns the property value for the given key.

Specified by:
getPropertyValue in interface ConfigurationProperties
Parameters:
key - the key to the property.
Returns:
the value to the property. A value of null is returned in cause of an optional property being not set.
Throws:
IllegalArgumentException - if key is blank.
UnknownPropertyException - if key is not known.
PropertyValidationException - if the property is invalid according to its constraints.

getPropertyValue

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

Specified by:
getPropertyValue in interface ConfigurationProperties
Parameters:
descriptor - the key to the property.
defaultValue - the default value to use in case no value has been specified.
Returns:
the value to the property. A value of null is returned in cause of an optional property being not set.
Throws:
NullPointerException - if descriptor is null.
PropertyValueConversionException - if conversion fails.
PropertyValidationException - if the property is invalid according to its constraints.
UnknownPropertyException - if the requested property is not known to the system.

getPropertyValue

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

Specified by:
getPropertyValue in interface ConfigurationProperties
Parameters:
key - the key to the property.
defaultValue - the default value to use in case no value has been specified.
Returns:
the value to the property. A value of null is returned in cause of an optional property being not set.
Throws:
IllegalArgumentException - if key is blank.
UnknownPropertyException - if key is not known.
PropertyValidationException - if the property is invalid according to its constraints.

getProperty

public final Property getProperty(String key)
                           throws IllegalArgumentException,
                                  UnknownPropertyException
Description copied from interface: ConfigurationProperties
Returns the property for the given key.

Specified by:
getProperty in interface ConfigurationProperties
Parameters:
key - the unique key of the property.
Returns:
the requested property.
Throws:
IllegalArgumentException - if key is blank.
UnknownPropertyException - if key is not known.

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
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(PropertyKey key)
                           throws IllegalArgumentException,
                                  UnknownPropertyException
Description copied from interface: ConfigurationProperties
Returns the property for the given key.

Specified by:
getProperty in interface ConfigurationProperties
Parameters:
key - the unique key of the property.
Returns:
the requested property.
Throws:
IllegalArgumentException - if key is blank.
UnknownPropertyException - if key is not known.

getProperty

public final Property getProperty(PropertyDescriptor descriptor)
                           throws IllegalArgumentException,
                                  UnknownPropertyException
Description copied from interface: ConfigurationProperties
Returns the property for the given descriptor.

Specified by:
getProperty in interface ConfigurationProperties
Parameters:
descriptor - the descriptor containing the unique key of the property.
Returns:
the requested property.
Throws:
UnknownPropertyException - if the key of the descriptor is not known.
IllegalArgumentException

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.

getResolvedProperty

public final ResolvedProperty getResolvedProperty(PropertyKey key,
                                                  Object defaultValue)
                                           throws IllegalArgumentException,
                                                  UnknownPropertyException,
                                                  PropertyValidationException
Description copied from interface: ConfigurationProperties
Returns the resolved 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:
getResolvedProperty in interface ConfigurationProperties
Parameters:
key - the 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.

getResolvedProperty

public final ResolvedProperty getResolvedProperty(String key,
                                                  Object defaultValue)
                                           throws IllegalArgumentException,
                                                  UnknownPropertyException,
                                                  PropertyValidationException
Description copied from interface: ConfigurationProperties
Returns the resolved 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:
getResolvedProperty in interface ConfigurationProperties
Parameters:
key - the 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.

getPropertyValueAsString

public final String getPropertyValueAsString(PropertyDescriptor descriptor)
                                      throws NullPointerException,
                                             PropertyValidationException
Description copied from interface: ConfigurationProperties
Returns the property string value for the given descriptor. If the property type is not String, the Object.toString() method is called to create the string representation of the value. null is always returned as null (not as the String "null").

Specified by:
getPropertyValueAsString in interface ConfigurationProperties
Parameters:
descriptor - the key to the property.
Returns:
the value to the property. A value of null is returned in cause of an optional property being not set.
Throws:
NullPointerException - if descriptor is null.
PropertyValidationException - if the property is invalid according to its constraints.

getPropertyValueAsString

public final String getPropertyValueAsString(String key)
                                      throws IllegalArgumentException,
                                             UnknownPropertyException,
                                             PropertyValidationException
Description copied from interface: ConfigurationProperties
Returns the property string value for the given key. If the property type is not String, the Object.toString() method is called to create the string representation of the value. null is always returned as null (not as the String "null").

Specified by:
getPropertyValueAsString in interface ConfigurationProperties
Parameters:
key - the key to the property.
Returns:
the value to the property. A value of null is returned in cause of an optional property being not set.
Throws:
IllegalArgumentException - if key is blank.
UnknownPropertyException - if key is not known.
PropertyValidationException - if the property is invalid according to its constraints.

getPropertyValueAsString

public final String getPropertyValueAsString(PropertyDescriptor descriptor,
                                             Object defaultValue)
                                      throws NullPointerException,
                                             PropertyValidationException
Description copied from interface: ConfigurationProperties
Returns the property string value for the given descriptor. If the property type is not String, the Object.toString() method is called to create the string representation of the value. null is always returned as null (not as the String "null").

Specified by:
getPropertyValueAsString in interface ConfigurationProperties
Parameters:
descriptor - the key to the property.
defaultValue - the default value to use in case no value has been specified.
Returns:
the value to the property. A value of null is returned in cause of an optional property being not set.
Throws:
NullPointerException - if descriptor is null.
PropertyValidationException - if the property is invalid according to its constraints.

getPropertyValueAsString

public final String getPropertyValueAsString(String key,
                                             Object defaultValue)
                                      throws IllegalArgumentException,
                                             UnknownPropertyException,
                                             PropertyValidationException
Description copied from interface: ConfigurationProperties
Returns the property string value for the given key. If the property type is not String, the Object.toString() method is called to create the string representation of the value. null is always returned as null (not as the String "null").

Specified by:
getPropertyValueAsString in interface ConfigurationProperties
Parameters:
key - the key to the property.
defaultValue - the default value to use in case no value has been specified.
Returns:
the value to the property. A value of null is returned in cause of an optional property being not set.
Throws:
IllegalArgumentException - if key is blank.
UnknownPropertyException - if key is not known.
PropertyValidationException - if the property is invalid according to its constraints.

validate

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

Specified by:
validate in interface ConfigurationProperties
Throws:
ConfigurationValidationException - if the configuration contains properties that do not meet the required constraints.

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.

addPropertyChangeListener

public final void addPropertyChangeListener(PropertyKey name,
                                            PropertyChangeListener listener)
                                     throws NullPointerException
Description copied from interface: ConfigurationProperties
Adds the given listener as a listener to the given property.

Specified by:
addPropertyChangeListener in interface ConfigurationProperties
Parameters:
name - the name of the property to track changes.
listener - the listener to add.
Throws:
NullPointerException - if name or listener is null.

removePropertyChangeListener

public final void removePropertyChangeListener(PropertyKey name,
                                               PropertyChangeListener listener)
                                        throws NullPointerException
Description copied from interface: ConfigurationProperties
Removes the given listener as a listener to the given property.

Specified by:
removePropertyChangeListener in interface ConfigurationProperties
Parameters:
name - the name of the property to stop tracking changes.
listener - the listener to remove.
Throws:
NullPointerException - if name or listener is null.

addPropertyChangeListener

public final void addPropertyChangeListener(PropertyChangeListener listener)
                                     throws NullPointerException
Description copied from interface: ConfigurationProperties
Adds the given listener to track any property changes.

Specified by:
addPropertyChangeListener in interface ConfigurationProperties
Parameters:
listener - the listener to add.
Throws:
NullPointerException - if listener is null.

removePropertyChangeListener

public final void removePropertyChangeListener(PropertyChangeListener listener)
                                        throws NullPointerException
Description copied from interface: ConfigurationProperties
Removes the given listener to stop tracking property changes.

Specified by:
removePropertyChangeListener in interface ConfigurationProperties
Parameters:
listener - the listener to remove.
Throws:
NullPointerException - if listener is null.

toSerializable

public SerializableConfigurationProperties toSerializable()
Description copied from interface: ConfigurationProperties
Creates a serializable variant of this implementation.

Specified by:
toSerializable in interface ConfigurationProperties
Returns:
a serializable variant of this implementation.
See Also:
ConfigurationPropertiesProxy, ConfigurationPropertiesManagementProxy


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