public class PropertyFieldCollection extends Object implements PropertyCollection, Serializable
Property's from a class. Property is added to the collection. LoggingPropertyChangeListener is automatically a added to all the Properties.PropertyIO will be validated using [PropertyCollectionFactory.initializeIO(io,logger,validationHandler)], and the validationHandler will be called both if it is valid or invalid.Property and parse the "PropertyFieldFilter.accept" method. Using [PropertyCollectionFactory.initializeFieldCollection(class,propertyIO,logger,validationHandler,propertyFieldFilter)]PropertyIO to all the Property's.Property's, and the validationHandler will be called both if they are is valid or invalid.LoggingPropertyChangeListener is added to all identified Property's. [NEW in version 1.6]postValidation where custom activation/crossvalidation of Properties can be performed.
Property's to the collection.PropertyCollectionFactory.initializeFieldCollection(Object, Class, PropertyIO, Log, PropertyValidationHandler, PropertyFieldFilter),
PropertyFieldFilter,
PropertyFieldFilterFactory,
Serialized FormPROPERTY_REGISTRY_DO_NOT_REGISTER, PROPERTY_REGISTRY_NO_TIMEOUT| Constructor and Description |
|---|
PropertyFieldCollection(PropertyFieldFilter propertyFieldFilter)
Default Constructor, where the class from where detection of static members of class type
Property will be performed is this class,
and the logger is a new instance of Log for this class,
and the PropertyValidationHandler is an instance of LoggingPropertyValidationHandler,
and the PropertyIO is a instance of ResourceStreamPropertyIO with this class as input. |
PropertyFieldCollection(PropertyFieldFilter propertyFieldFilter,
PropertyIO io)
Constructor, where the class from where detection of static members of class type
Property will be performed is this class,
and the PropertyValidationHandler is an instance of LoggingPropertyValidationHandler,
and the logger is a new instance of Log for this class. |
PropertyFieldCollection(PropertyFieldFilter propertyFieldFilter,
PropertyIO io,
Class<?> clazz,
org.apache.commons.logging.Log logger,
PropertyValidationHandler propertyValidationHandler)
Constructor.
|
PropertyFieldCollection(PropertyFieldFilter propertyFieldFilter,
PropertyIO io,
org.apache.commons.logging.Log logger)
Constructor, where the class from where detection of static members of class type
Property will be performed is this class,
and the PropertyValidationHandler is an instance of LoggingPropertyValidationHandler. |
PropertyFieldCollection(PropertyFieldFilter propertyFieldFilter,
PropertyIO io,
org.apache.commons.logging.Log logger,
PropertyValidationHandler propertyValidationHandler)
Constructor, where the class from where detection of static members of class type
Property will be performed is this class. |
PropertyFieldCollection(PropertyFieldFilter propertyFieldFilter,
PropertyIO io,
PropertyValidationHandler propertyValidationHandler)
Constructor, where the class from where detection of static members of class type
Property will be performed is this class,
and the logger is a new instance of Log for this class. |
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a
PropertyChangeListener to all registrered Property's in the PropertyCollection. |
PropertyIO |
getIo()
The PropertyIO.
|
Iterator<Property<?>> |
getIterator()
Property Iterator.
|
List<Property<?>> |
getList()
Property list sorted by name, as a
Collections.unmodifiableList. |
org.apache.commons.logging.Log |
getLogger()
The
org.apache.commons.logging.Log used. |
String |
getName()
Gets the name of the collection, default is getClass().getName();.
|
protected List<Property<?>> |
getProperties()
Gets the properties for the PropertyFieldCollection.
|
Property<?> |
getPropertyByName(String propertyName)
Get a Property by name.
|
PropertyFieldFilter |
getPropertyFieldFilter()
The instance of a
PropertyFieldFilter. |
PropertyValidationHandler |
getPropertyValidationHandler()
When a property collection validates all the properties it contains, then this handler defines what happens
in case the a property is valid or invalid.
|
long |
getRegistryTimeout()
The number of milliseconds before a PropertyCollection is automatically remove from PropertyCollectionRegistry.
|
static void |
initialize(PropertyFieldCollection collection)
Initialize the PropertyFieldCollection when the Property in the class is declared as non-static fields.
|
void |
postValidation()
After the PropertyCollection has validation the PropertyIO and all the Properties, it calls this method.
|
void |
preValidation()
This method is called before any validation of PropertyIO and Properties is performed, this is where you typically can setup global configurations.
|
void |
reload()
Resets the cache typed values for all the
Property's in the PropertyIO for this collection which forces a reload from the property IO. |
void |
removeAllPropertyChangeListeners()
Remove all PropertyChangeListener's from the Property's in the Collection.
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a
PropertyChangeListener from all registered Property's in the collection. |
protected void |
setProperties(List<Property<?>> properties) |
void |
setPropertyValidationHandler(PropertyValidationHandler propertyValidationHandler)
Here you can set your PropertyValidationHandler instance.
|
int |
size()
Number of properties.
|
void |
validate()
Validates all the
Property's in the collection an throws an
PropertyException for the first that failsvalidation. |
List<PropertyValidationVO> |
validation()
Validates all the
Property's in the collection, stores the result in
a java.util.List of PropertyValidationVO. |
public PropertyFieldCollection(PropertyFieldFilter propertyFieldFilter, PropertyIO io, Class<?> clazz, org.apache.commons.logging.Log logger, PropertyValidationHandler propertyValidationHandler)
propertyFieldFilter - the filter which select the fields from classes and interfaces above which should be initializedio - the PropertyIO instance from where the Property's will be loaded.clazz - the class from where detection of static members of class type Property will be performed.logger - the loggerpropertyValidationHandler - the validation handler, used to perform operations on initialization when a Property is either valid or invalid, or a PropertyIO is either valid or invalid.public PropertyFieldCollection(PropertyFieldFilter propertyFieldFilter, PropertyIO io, org.apache.commons.logging.Log logger)
Property will be performed is this class,
and the PropertyValidationHandler is an instance of LoggingPropertyValidationHandler. propertyFieldFilter - the filter which select the fields from classes and interfaces above which should be initializedio - the PropertyIO instance from where the Property's will be loaded.logger - the loggerLoggingPropertyValidationHandlerpublic PropertyFieldCollection(PropertyFieldFilter propertyFieldFilter, PropertyIO io, org.apache.commons.logging.Log logger, PropertyValidationHandler propertyValidationHandler)
Property will be performed is this class. propertyFieldFilter - the filter which select the fields from classes and interfaces above which should be initializedio - the PropertyIO instance from where the Property's will be loaded.logger - the loggerpropertyValidationHandler - the validation handler, used to perform operations on initialization when a Property is either valid or invalid, or a PropertyIO is either valid or invalid.public PropertyFieldCollection(PropertyFieldFilter propertyFieldFilter, PropertyIO io)
Property will be performed is this class,
and the PropertyValidationHandler is an instance of LoggingPropertyValidationHandler,
and the logger is a new instance of Log for this class. propertyFieldFilter - the filter which select the fields from classes and interfaces above which should be initializedio - the PropertyIO instance from where the Property's will be loaded.LoggingPropertyValidationHandlerpublic PropertyFieldCollection(PropertyFieldFilter propertyFieldFilter, PropertyIO io, PropertyValidationHandler propertyValidationHandler)
Property will be performed is this class,
and the logger is a new instance of Log for this class. propertyFieldFilter - the filter which select the fields from classes and interfaces above which should be initializedio - the PropertyIO instance from where the Property's will be loaded.propertyValidationHandler - the validation handler, used to perform operations on initialization when a Property is either valid or invalid, or a PropertyIO is either valid or invalid.public PropertyFieldCollection(PropertyFieldFilter propertyFieldFilter)
Property will be performed is this class,
and the logger is a new instance of Log for this class,
and the PropertyValidationHandler is an instance of LoggingPropertyValidationHandler,
and the PropertyIO is a instance of ResourceStreamPropertyIO with this class as input. propertyFieldFilter - the filter which select the fields from classes and interfaces above which should be initializedLoggingPropertyValidationHandler,
ResourceStreamPropertyIO.ResourceStreamPropertyIO(Class)public String getName()
PropertyCollectiongetName in interface PropertyCollectionpublic long getRegistryTimeout()
PropertyCollectiongetRegistryTimeout in interface PropertyCollectionPropertyCollectionRegistrypublic PropertyFieldFilter getPropertyFieldFilter()
PropertyFieldFilter.public final void reload()
PropertyCollectionProperty's in the PropertyIO for this collection which forces a reload from the property IO.reload in interface PropertyCollectionpublic final int size()
PropertyCollectionsize in interface PropertyCollectionProperty's in the collection.public final void validate()
throws PropertyException
PropertyCollectionProperty's in the collection an throws an
PropertyException for the first that failsvalidation.validate in interface PropertyCollectionPropertyException - if any of the Property's fails validation.public final List<PropertyValidationVO> validation()
PropertyCollectionProperty's in the collection, stores the result in
a java.util.List of PropertyValidationVO.
The purpose is for the client to have a list to show in any user interface the state of
properties.validation in interface PropertyCollectionPropertyValidationVOpublic final Property<?> getPropertyByName(String propertyName)
PropertyCollectiongetPropertyByName in interface PropertyCollectionpropertyName - the name of the propertyProperty if found, otherwise null.public final Iterator<Property<?>> getIterator()
PropertyCollectiongetIterator in interface PropertyCollectionProperty's in the collection.Iteratorpublic final List<Property<?>> getList()
PropertyCollectionCollections.unmodifiableList.
Remember to sort before turning it in to a unmodifiableList list.getList in interface PropertyCollectionCollections.unmodifiableList(List)public org.apache.commons.logging.Log getLogger()
PropertyCollectionorg.apache.commons.logging.Log used.getLogger in interface PropertyCollectionpublic final PropertyIO getIo()
PropertyCollectiongetIo in interface PropertyCollectionProperty's has been initialized with.PropertyIOpublic final PropertyValidationHandler getPropertyValidationHandler()
PropertyCollectiongetPropertyValidationHandler in interface PropertyCollectionPropertyValidationHandler of none is defined than LoggingPropertyValidationHandler is used.PropertyValidationHandler,
LoggingPropertyValidationHandlerpublic final void setPropertyValidationHandler(PropertyValidationHandler propertyValidationHandler)
PropertyCollectionsetPropertyValidationHandler in interface PropertyCollectionpropertyValidationHandler - your instance of a PropertyValidationHandler.PropertyValidationHandlerpublic void preValidation()
PropertyCollectionpreValidation in interface PropertyCollectionpublic void postValidation()
throws PropertyException
PropertyCollection
public class MyPropertiesDemo extends PropertyStaticCollection implements MyProperties {
public MyPropertiesDemo(FilePropertyIO io) {
super(io);
}
public void postValidation() throws PropertyException {
ActivationValidator activator = new ActivationValidator();
activator.given(MyProperties.PORT_NUMBER.getTypedValue()==443,MyProperties.A_SSL_CONFIG);
activator.given(MyProperties.MY_STRING,MyProperties.MY_NUMBER_A,MyProperties.MY_NUMBER_B,MyProperties.MY_NUMBER_C,MyProperties.MY_NUMBER_D);
}
}
It throws an exceptionpostValidation in interface PropertyCollectionPropertyExceptionpublic void addPropertyChangeListener(PropertyChangeListener listener) throws NullPointerException
PropertyCollectionPropertyChangeListener to all registrered Property's in the PropertyCollection. addPropertyChangeListener in interface PropertyCollectionlistener - the listener to be added to all Property's.NullPointerException - if listener was null or the PropertyIO of the collection is null.Property.addPropertyChangeListener(PropertyChangeListener),
LoggingPropertyValidationHandlerpublic void removePropertyChangeListener(PropertyChangeListener listener) throws NullPointerException
PropertyCollectionPropertyChangeListener from all registered Property's in the collection. removePropertyChangeListener in interface PropertyCollectionlistener - the listener to be removed.NullPointerException - if listener was null or the PropertyIO of the collection is null.Property.removePropertyChangeListener(PropertyChangeListener)public static void initialize(PropertyFieldCollection collection)
collection - the instance of the PropertyFieldCollection.public void removeAllPropertyChangeListeners()
PropertyCollectionremoveAllPropertyChangeListeners in interface PropertyCollectionprotected final List<Property<?>> getProperties()