de.smartics.properties.api.config.domain
Interface ConfigurationProperties

Package class diagram package ConfigurationProperties
All Known Subinterfaces:
ConfigurationPropertiesManagement, ConfigurationPropertiesManagementSpi, ConfigurationPropertiesSpi, SerializableConfigurationProperties, SerializableConfigurationPropertiesManagement, SerializableConfigurationPropertiesManagementSpi
All Known Implementing Classes:
AbstractAdminModeConfigurationProperties, AbstractAdminModeSupportedPropertiesManagement, AbstractCacheConfigurationPropertiesManagement, AbstractConfigurationProperties, AbstractConfigurationPropertiesManagement, AbstractExternalConfigurationPropertiesManagement, AbstractInMemoryConfigurationProperties, BootConfigurationProperties, CacheConfigurationPropertiesManagement, ClasspathConfigurationProperties, ConfigurationPropertiesManagementProxy, ConfigurationPropertiesManagementWithDefaults, ConfigurationPropertiesProxy, DataSourceConfigurationProperties, JndiConfigurationProperties, PropertiesConfigurationProperties, SerializableCacheConfigurationPropertiesManagement

public interface ConfigurationProperties

Provides access to all configuration properties for a given application in a given environment.

There are two ways to access property values.

  1. Use getProperties(Class) to obtain an implementation of an interface that provides access to the property values through its methods. This is the recommended way to deal with properties.
  2. Use one of the getProperty methods. This access may be more convenient, if the context deals with property keys that are provided by the user (e.g. from an UI).

Implementation Notes:
This interface is intended to be implemented by service providers. API users are intended to us this interface to access properties. For details on creating instances of classes implementing this interface please refer to de.smartics.properties.api.config.

Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds the given listener to track any property changes.
 void addPropertyChangeListener(de.smartics.properties.api.core.domain.PropertyKey name, PropertyChangeListener listener)
          Adds the given listener as a listener to the given property.
 de.smartics.properties.api.core.domain.PropertiesContext getContext(Class<?> declaringType)
          Returns the properties context for the declaring type.
 de.smartics.properties.api.core.domain.PropertyContext getContext(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor)
          Returns the properties context the property described by the given descriptor is part of.
 ConfigurationKey<?> getKey()
          Returns the key of the configuration.
<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.
 DescribedProperty getProperty(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor)
          Returns the property for the given descriptor.
 DescribedProperty getProperty(de.smartics.properties.api.core.domain.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.
 DescribedProperty getProperty(de.smartics.properties.api.core.domain.PropertyKey key)
          Returns the property for the given key.
 DescribedProperty getProperty(String key)
          Returns the property for the given key.
 DescribedProperty 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 getPropertyAsType(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor)
          Returns the yet not validated property for the given descriptor's key.
 Object getPropertyValue(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor)
          Returns the property value for the given descriptor.
 Object getPropertyValue(de.smartics.properties.api.core.domain.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(de.smartics.properties.api.core.domain.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(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor)
          Returns the property string value for the given descriptor.
 String getPropertyValueAsString(de.smartics.properties.api.core.domain.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.
 ValidatedProperty getValidatedProperty(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Object defaultValue)
          Returns the validated 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.
 ValidatedProperty getValidatedProperty(de.smartics.properties.api.core.domain.PropertyKey key, Object defaultValue)
          Returns the validated property for the given key, allowing to transparently provide a default value to be returned in case the property has not been set.
 ValidatedProperty getValidatedProperty(String key, Object defaultValue)
          Returns the validated property for the given key, allowing to transparently provide a default value to be returned in case the property has not been set.
 boolean isInAdminMode()
          Checks whether or not this configuration is in administration mode.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes the given listener to stop tracking property changes.
 void removePropertyChangeListener(de.smartics.properties.api.core.domain.PropertyKey name, PropertyChangeListener listener)
          Removes the given listener as a listener to the given property.
 ConfigurationProperties toRepresentative()
          Creates an representative of this configuration.
 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, Class<?>... groups)
          Validates all properties in the given configuration.
 void validate(Class<?>... groups)
          Validates all properties in the given configuration and groups in a non-lenient fashion.
 void validate(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Class<?>... ifInOneOfTheseGroups)
          Validates the given property in the given configuration.
 void validate(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, String value, Class<?>... ifInOneOfTheseGroups)
          Validates the given property in the given configuration.
 

Method Detail

getKey

ConfigurationKey<?> getKey()
Returns the key of the configuration.

Returns:
the key of the configuration. Never null.

getContext

de.smartics.properties.api.core.domain.PropertiesContext getContext(Class<?> declaringType)
                                                                    throws NullPointerException
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.

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

de.smartics.properties.api.core.domain.PropertyContext getContext(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor)
                                                                  throws NullPointerException
Returns the properties context the property described by the given descriptor is part of.

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.

isInAdminMode

boolean isInAdminMode()
Checks whether or not this configuration is in administration mode. In this mode the configuration is less strict with certain validations. Especially it allows to edit otherwise read-only properties.

Returns:
true if the configuration is in administration mode, false otherwise.

getProperties

<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. The interface must be annotated with an PropertySet annotation.

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

Object getPropertyValue(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor)
                        throws NullPointerException,
                               de.smartics.properties.api.core.domain.PropertyValidationException
Returns the property value for the given descriptor.

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.
de.smartics.properties.api.core.domain.PropertyValidationException - if the property is invalid according to its constraints.

getPropertyValue

Object getPropertyValue(String key)
                        throws IllegalArgumentException,
                               UnknownPropertyException,
                               de.smartics.properties.api.core.domain.PropertyValidationException
Returns the property value for the given key.

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.
de.smartics.properties.api.core.domain.PropertyValidationException - if the property is invalid according to its constraints.

getPropertyValue

Object getPropertyValue(de.smartics.properties.api.core.domain.PropertyKey key)
                        throws IllegalArgumentException,
                               UnknownPropertyException,
                               de.smartics.properties.api.core.domain.PropertyValidationException
Returns the property value for the given key.

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.
de.smartics.properties.api.core.domain.PropertyValidationException - if the property is invalid according to its constraints.

getPropertyValue

Object getPropertyValue(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor,
                        Object defaultValue)
                        throws NullPointerException,
                               de.smartics.properties.api.core.domain.PropertyValueConversionException,
                               de.smartics.properties.api.core.domain.PropertyValidationException,
                               UnknownPropertyException
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.

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.
de.smartics.properties.api.core.domain.PropertyValueConversionException - if conversion fails.
de.smartics.properties.api.core.domain.PropertyValidationException - if the property is invalid according to its constraints.
UnknownPropertyException - if the requested property is not known to the system.

getPropertyValue

Object getPropertyValue(String key,
                        Object defaultValue)
                        throws IllegalArgumentException,
                               UnknownPropertyException,
                               de.smartics.properties.api.core.domain.PropertyValidationException
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.

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.
de.smartics.properties.api.core.domain.PropertyValidationException - if the property is invalid according to its constraints.

getProperty

DescribedProperty getProperty(String key)
                              throws IllegalArgumentException,
                                     UnknownPropertyException
Returns the property for the given key.

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

DescribedProperty getProperty(String key,
                              Object defaultValue)
                              throws IllegalArgumentException,
                                     UnknownPropertyException
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.

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

DescribedProperty getProperty(de.smartics.properties.api.core.domain.PropertyKey key)
                              throws IllegalArgumentException,
                                     UnknownPropertyException
Returns the property for the given key.

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

DescribedProperty getProperty(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor)
                              throws NullPointerException,
                                     UnknownPropertyException
Returns the property for the given descriptor.

Parameters:
descriptor - the descriptor containing the unique key of the property.
Returns:
the requested property.
Throws:
NullPointerException - if descriptor is null.
UnknownPropertyException - if the key of the descriptor is not known.

getProperty

DescribedProperty getProperty(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor,
                              Object defaultValue)
                              throws NullPointerException,
                                     UnknownPropertyException
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.

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:
NullPointerException - if descriptor is null.
UnknownPropertyException - if the key of the descriptor is not known.

getPropertyAsType

Object getPropertyAsType(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor)
                         throws IllegalArgumentException,
                                UnknownPropertyException,
                                de.smartics.properties.api.core.domain.PropertyValueConversionException,
                                de.smartics.properties.api.core.security.SecurityException,
                                de.smartics.properties.api.core.app.PropertyRootException
Returns the yet not validated property for the given descriptor's key. This is useful to access the resolved and converted value to apply validation only under certain conditions.

Parameters:
descriptor - descriptor key to the property.
Returns:
the resolved property. May be null if the property's value is actually unset.
Throws:
IllegalArgumentException - if descriptor is blank.
UnknownPropertyException - if descriptor is not known.
de.smartics.properties.api.core.domain.PropertyValueConversionException - if the property cannot be converted to its value.
de.smartics.properties.api.core.security.SecurityException - on any problem decrypting an encrypted value.
de.smartics.properties.api.core.app.PropertyRootException - on any problem.

getValidatedProperty

ValidatedProperty getValidatedProperty(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor,
                                       Object defaultValue)
                                       throws IllegalArgumentException,
                                              UnknownPropertyException,
                                              de.smartics.properties.api.core.domain.PropertyValueConversionException,
                                              de.smartics.properties.api.core.domain.PropertyValidationException,
                                              de.smartics.properties.api.core.security.SecurityException,
                                              de.smartics.properties.api.core.app.PropertyRootException
Returns the validated 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.

Parameters:
descriptor - descriptor key to the property.
defaultValue - the default value to use in case no value has been specified.
Returns:
the validated property. Never null, although the value / validated value of the returned property may be null.
Throws:
IllegalArgumentException - if descriptor is blank.
UnknownPropertyException - if descriptor is not known.
de.smartics.properties.api.core.domain.PropertyValueConversionException - if the property cannot be converted to its value.
de.smartics.properties.api.core.domain.PropertyValidationException - if the property is invalid according to its constraints.
de.smartics.properties.api.core.security.SecurityException - on any problem decrypting an encrypted value.
de.smartics.properties.api.core.app.PropertyRootException - on any problem.

getValidatedProperty

ValidatedProperty getValidatedProperty(de.smartics.properties.api.core.domain.PropertyKey key,
                                       Object defaultValue)
                                       throws IllegalArgumentException,
                                              UnknownPropertyException,
                                              de.smartics.properties.api.core.domain.PropertyValueConversionException,
                                              de.smartics.properties.api.core.domain.PropertyValidationException,
                                              de.smartics.properties.api.core.security.SecurityException,
                                              de.smartics.properties.api.core.app.PropertyRootException
Returns the validated property for the given key, allowing to transparently provide a default value to be returned in case the property has not been set.

Parameters:
key - the key to the property.
defaultValue - the default value to use in case no value has been specified.
Returns:
the validated property. Never null, although the value / validated value of the returned property may be null.
Throws:
IllegalArgumentException - if key is blank.
UnknownPropertyException - if key is not known.
de.smartics.properties.api.core.domain.PropertyValueConversionException - if the property cannot be converted to its value.
de.smartics.properties.api.core.domain.PropertyValidationException - if the property is invalid according to its constraints.
de.smartics.properties.api.core.security.SecurityException - on any problem decrypting an encrypted value.
de.smartics.properties.api.core.app.PropertyRootException - on any problem.

getValidatedProperty

ValidatedProperty getValidatedProperty(String key,
                                       Object defaultValue)
                                       throws IllegalArgumentException,
                                              UnknownPropertyException,
                                              de.smartics.properties.api.core.domain.PropertyValueConversionException,
                                              de.smartics.properties.api.core.domain.PropertyValidationException,
                                              de.smartics.properties.api.core.security.SecurityException,
                                              de.smartics.properties.api.core.app.PropertyRootException
Returns the validated property for the given key, allowing to transparently provide a default value to be returned in case the property has not been set.

Parameters:
key - the key to the property.
defaultValue - the default value to use in case no value has been specified.
Returns:
the validated property. Never null, although the value / validated value of the returned property may be null.
Throws:
IllegalArgumentException - if key is blank.
UnknownPropertyException - if key is not known.
de.smartics.properties.api.core.domain.PropertyValueConversionException - if the property cannot be converted to its value.
de.smartics.properties.api.core.domain.PropertyValidationException - if the property is invalid according to its constraints.
de.smartics.properties.api.core.security.SecurityException - on any problem decrypting an encrypted value.
de.smartics.properties.api.core.app.PropertyRootException - on any problem.

getPropertyValueAsString

String getPropertyValueAsString(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor)
                                throws NullPointerException,
                                       de.smartics.properties.api.core.domain.PropertyValidationException
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").

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.
de.smartics.properties.api.core.domain.PropertyValidationException - if the property is invalid according to its constraints.

getPropertyValueAsString

String getPropertyValueAsString(String key)
                                throws IllegalArgumentException,
                                       UnknownPropertyException,
                                       de.smartics.properties.api.core.domain.PropertyValidationException
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").

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.
de.smartics.properties.api.core.domain.PropertyValidationException - if the property is invalid according to its constraints.

getPropertyValueAsString

String getPropertyValueAsString(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor,
                                Object defaultValue)
                                throws NullPointerException,
                                       de.smartics.properties.api.core.domain.PropertyValidationException
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").

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.
de.smartics.properties.api.core.domain.PropertyValidationException - if the property is invalid according to its constraints.

getPropertyValueAsString

String getPropertyValueAsString(String key,
                                Object defaultValue)
                                throws IllegalArgumentException,
                                       UnknownPropertyException,
                                       de.smartics.properties.api.core.domain.PropertyValidationException
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").

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.
de.smartics.properties.api.core.domain.PropertyValidationException - if the property is invalid according to its constraints.

validate

void validate()
              throws ConfigurationValidationException
Validates all properties in the given configuration in a non-lenient fashion.

Throws:
ConfigurationValidationException - if the configuration contains properties that do not meet the required constraints.

validate

void validate(Class<?>... groups)
              throws ConfigurationValidationException
Validates all properties in the given configuration and groups in a non-lenient fashion.

Parameters:
groups - the validation groups to consider in the validation process. The groups will be validated in the given order. As soon as a validation group fails, the validation process is aborted without checking the not yet processed groups.
Throws:
ConfigurationValidationException - if the configuration contains properties that do not meet the required constraints.

validate

void validate(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor,
              Class<?>... ifInOneOfTheseGroups)
              throws ConfigurationValidationException
Validates the given property in the given configuration.

Parameters:
descriptor - the descriptor whose value is to be validated.
ifInOneOfTheseGroups - the validation only takes place if this constraint is part of any of the specified groups or the argument is empty or null.
Throws:
ConfigurationValidationException - if property does not meet the required constraints.

validate

void validate(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor,
              String value,
              Class<?>... ifInOneOfTheseGroups)
              throws ConfigurationValidationException
Validates the given property in the given configuration.

Parameters:
descriptor - the descriptor whose value is to be validated.
value - the property value to be validated.
ifInOneOfTheseGroups - the validation only takes place if this constraint is part of any of the specified groups or the argument is empty or null.
Throws:
ConfigurationValidationException - if property does not meet the required constraints.

validate

void validate(boolean lenient,
              Class<?>... groups)
              throws ConfigurationValidationException
Validates all properties in the given configuration.

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.
groups - the validation groups to consider in the validation process. The groups will be validated in the given order. As soon as a validation group fails, the validation process is aborted without checking the not yet processed groups.
Throws:
ConfigurationValidationException - if the configuration contains properties that do not meet the required constraints.

addPropertyChangeListener

void addPropertyChangeListener(de.smartics.properties.api.core.domain.PropertyKey name,
                               PropertyChangeListener listener)
                               throws NullPointerException
Adds the given listener as a listener to the given property.

Parameters:
name - the name of the property to track changes.
listener - the listener to add.
Throws:
NullPointerException - if name or listener is null.

removePropertyChangeListener

void removePropertyChangeListener(de.smartics.properties.api.core.domain.PropertyKey name,
                                  PropertyChangeListener listener)
                                  throws NullPointerException
Removes the given listener as a listener to the given property.

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

void addPropertyChangeListener(PropertyChangeListener listener)
                               throws NullPointerException
Adds the given listener to track any property changes.

Parameters:
listener - the listener to add.
Throws:
NullPointerException - if listener is null.

removePropertyChangeListener

void removePropertyChangeListener(PropertyChangeListener listener)
                                  throws NullPointerException
Removes the given listener to stop tracking property changes.

Parameters:
listener - the listener to remove.
Throws:
NullPointerException - if listener is null.

toSerializable

SerializableConfigurationProperties toSerializable()
Creates a serializable variant of this implementation.

Returns:
a serializable variant of this implementation.
See Also:
ConfigurationPropertiesProxy, ConfigurationPropertiesManagementProxy

toRepresentative

ConfigurationProperties toRepresentative()
Creates an representative of this configuration. If the configuration serves for a specific configuration key, this instance will be returned. If the configuration servers for multiple configuration keys, the representative is returned. The representative is usually the configuration that is associated with the full key.

Returns:
the representative (may be this).


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