|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object de.smartics.properties.spi.config.support.AbstractConfigurationProperties de.smartics.properties.spi.config.support.AbstractAdminModeConfigurationProperties de.smartics.properties.spi.config.support.AbstractConfigurationPropertiesManagement
@ThreadSafe public abstract class AbstractConfigurationPropertiesManagement
Abstract implementation of the ConfigurationProperties
interface.
Constructor Summary | |
---|---|
protected |
AbstractConfigurationPropertiesManagement() Constructor for serializable subclasses. |
protected |
AbstractConfigurationPropertiesManagement(ConfigurationKey<?> key, de.smartics.properties.api.core.domain.PropertyDescriptorRegistry registry, de.smartics.properties.api.core.security.PropertyValueSecurity decrypter) Default constructor. |
Method Summary | |
---|---|
ConfigurationPropertiesManagement |
addDefinitions(PropertyProvider properties) Adds the given definitions to this configuration. |
protected abstract void |
addDefinitionsToStore(PropertyProvider properties) Implementations decide whether or not registered definitions should be written to the store. |
void |
addDescriptors(Class<?> propertySetType) Adds all property descriptors declared in the given type. |
protected 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. |
de.smartics.properties.api.core.domain.PropertyDescriptor |
getDescriptor(de.smartics.properties.api.core.domain.PropertyKey key) Returns the descriptor for the given key. |
de.smartics.properties.api.core.domain.PropertyDescriptor |
getDescriptor(String key) Returns the descriptor for the given key. |
List<de.smartics.properties.api.core.domain.PropertyDescriptor> |
getMandatoryPropertyDescriptors() Returns the list of mandatory properties. |
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(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. |
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. |
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. |
protected abstract void |
setPropertiesToStore(PropertyProvider provider) Allows to store all properties efficiently by subclasses. |
Property |
setProperty(de.smartics.properties.api.core.domain.PropertyKey key, String value) Sets the property value for the given key. |
protected Property |
setPropertyToStore(String name, String value) Sets the property to the given value. |
Property |
unsetProperty(de.smartics.properties.api.core.domain.PropertyKey key) Unsets the property value for the given key. |
void |
validate(boolean lenient, Class<?>... groups) Validates all properties in the given configuration. |
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. |
Methods inherited from class de.smartics.properties.spi.config.support.AbstractAdminModeConfigurationProperties |
---|
isInAdminMode, setToAdminMode, toRepresentative |
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 |
---|
getPropertyStoreAccessor, getPropertyValueSecurity, getRegistry, setToAdminMode, toRepresentative, 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, getValidatedProperty, getValidatedProperty, isInAdminMode, removePropertyChangeListener, removePropertyChangeListener, validate, validate |
Constructor Detail |
---|
protected AbstractConfigurationPropertiesManagement()
protected AbstractConfigurationPropertiesManagement(ConfigurationKey<?> key, de.smartics.properties.api.core.domain.PropertyDescriptorRegistry registry, de.smartics.properties.api.core.security.PropertyValueSecurity decrypter) throws de.smartics.util.lang.NullArgumentException
key
- the key that identifies the configuration.
registry
- the registry to resolve property descriptors.
decrypter
- the helper to decrypt secured property values.
de.smartics.util.lang.NullArgumentException
- if
key
,
registry
or
decrypter
is
null
.
Method Detail |
---|
public final de.smartics.properties.api.core.domain.PropertyDescriptor getDescriptor(String key) throws UnknownPropertyException
ConfigurationPropertiesManagement
getDescriptor
in interface
ConfigurationPropertiesManagement
key
- the of the requested descriptor.
key
.
UnknownPropertyException
- if the property is not known.
public final de.smartics.properties.api.core.domain.PropertyDescriptor getDescriptor(de.smartics.properties.api.core.domain.PropertyKey key) throws UnknownPropertyException
ConfigurationPropertiesManagement
getDescriptor
in interface
ConfigurationPropertiesManagement
key
- the of the requested descriptor.
key
.
UnknownPropertyException
- if the property is not known.
public final void addDescriptors(Class<?> propertySetType) throws de.smartics.properties.api.core.domain.DuplicatePropertyDeclarationsException
ConfigurationPropertiesManagement
addDescriptors
in interface
ConfigurationPropertiesManagement
propertySetType
- the type that declares the descriptors.
de.smartics.properties.api.core.domain.DuplicatePropertyDeclarationsException
- if any of the descriptors declare the same property.
public final List<de.smartics.properties.api.core.domain.PropertyDescriptor> getMandatoryPropertyDescriptors()
ConfigurationPropertiesManagement
Returns a copy that can be edited.
getMandatoryPropertyDescriptors
in interface
ConfigurationPropertiesManagement
public final ConfigurationPropertiesManagement addDefinitions(PropertyProvider properties) throws NullPointerException
ConfigurationPropertiesManagement
addDefinitions
in interface
ConfigurationPropertiesManagement
properties
- the property definitions to add.
NullPointerException
- if
properties
is
null
.
protected abstract void addDefinitionsToStore(PropertyProvider properties) throws PropertyStoreException
Usually configurations that are backed up by an external (e.g. persistent) store do not want to store definitions here. So they override this method with a no-op.
properties
- the properties that are to be registered as definitions.
PropertyStoreException
- if any property cannot be stored. The already stored properties will not be rolled back.
protected abstract void setPropertiesToStore(PropertyProvider provider) throws PropertyStoreException
provider
- the provider with the properties to be stored.
PropertyStoreException
- if any property cannot be stored. The already stored properties will not be rolled back.
public final DescribedProperty getProperty(String key, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException
ConfigurationProperties
getProperty
in interface
ConfigurationProperties
getProperty
in class
AbstractConfigurationProperties
key
- the unique key of the property.
defaultValue
- the default value to use in case no value has been specified.
IllegalArgumentException
- if
key
is blank.
UnknownPropertyException
- if
key
is not known.
public final DescribedProperty getProperty(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException
ConfigurationProperties
getProperty
in interface
ConfigurationProperties
descriptor
- the descriptor containing the unique key of the property.
defaultValue
- the default value to use in case no value has been specified.
UnknownPropertyException
- if the key of the
descriptor
is not known.
IllegalArgumentException
public Object getPropertyAsType(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor) throws IllegalArgumentException, de.smartics.properties.api.core.domain.PropertyValueConversionException, de.smartics.properties.api.core.security.SecurityException, de.smartics.properties.api.core.app.PropertyRootException
ConfigurationProperties
getPropertyAsType
in interface
ConfigurationProperties
descriptor
- descriptor key to the property.
null
if the property's value is actually unset.
IllegalArgumentException
- if
descriptor
is blank.
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.
UnknownPropertyException
- if
descriptor
is not known.
de.smartics.properties.api.core.app.PropertyRootException
- on any problem.
public final ValidatedProperty getValidatedProperty(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Object defaultValue) throws IllegalArgumentException, UnknownPropertyException, de.smartics.properties.api.core.domain.PropertyValidationException, de.smartics.properties.api.core.security.SecurityException
ConfigurationProperties
getValidatedProperty
in interface
ConfigurationProperties
descriptor
- descriptor key to the property.
defaultValue
- the default value to use in case no value has been specified.
null
, although the value / validated value of the returned property may be
null
.
IllegalArgumentException
- if
descriptor
is blank.
UnknownPropertyException
- if
descriptor
is not known.
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.
public final Property setProperty(de.smartics.properties.api.core.domain.PropertyKey key, String value) throws NullPointerException, de.smartics.properties.api.core.domain.PropertyValidationException, de.smartics.properties.api.core.domain.ReadOnlyPropertyException
ConfigurationPropertiesManagement
setProperty
in interface
ConfigurationPropertiesManagement
key
- the key to the property.
value
- the value to the property.
null
is returned if the property had no value prior to this call.
NullPointerException
- if
key
is
null
.
de.smartics.properties.api.core.domain.PropertyValidationException
- if the property value is invalid according to its constraints.
de.smartics.properties.api.core.domain.ReadOnlyPropertyException
- if the property to update is read-only.
public final Property unsetProperty(de.smartics.properties.api.core.domain.PropertyKey key) throws NullPointerException, de.smartics.properties.api.core.domain.ReadOnlyPropertyException
ConfigurationPropertiesManagement
unsetProperty
in interface
ConfigurationPropertiesManagement
key
- the key to the property.
null
is returned if the property had no value prior to this call.
NullPointerException
- if
key
is
null
.
de.smartics.properties.api.core.domain.ReadOnlyPropertyException
- if the property to update is read-only.
public final void validate(boolean lenient, Class<?>... groups) throws ConfigurationValidationException
ConfigurationProperties
validate
in interface
ConfigurationProperties
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.
ConfigurationValidationException
- if the configuration contains properties that do not meet the required constraints.
public final void validate(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, Class<?>... ifInOneOfTheseGroups) throws ConfigurationValidationException
ConfigurationProperties
validate
in interface
ConfigurationProperties
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
.
ConfigurationValidationException
- if property does not meet the required constraints.
public final void validate(de.smartics.properties.api.core.domain.PropertyDescriptor descriptor, String value, Class<?>... ifInOneOfTheseGroups) throws ConfigurationValidationException
ConfigurationProperties
validate
in interface
ConfigurationProperties
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
.
ConfigurationValidationException
- if property does not meet the required constraints.
public void flush()
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.
flush
in interface
ConfigurationPropertiesManagement
protected final Property setPropertyToStore(String name, String value) throws NullPointerException
name
- the name of the property to set.
value
- the value to the property.
null
(although the value of the property may be
null
).
NullPointerException
- if
name
is
null
.
protected final PropertyCollection getPropertyCollectionFromStore()
protected final Property deletePropertyInStore(String name)
name
- the name of the property to delete.
protected final Property getPropertyFromStore(String name)
name
- the name of the property to fetch.
null
(although the value of the property may be
null
).
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |