Class InitializableBean<B,P extends BeanInitialization>
Object
AnchorBean<B>
InitializableBean<B,P>
- Type Parameters:
B- bean-family typeP- initialization-parameters type
- Direct Known Subclasses:
DictionaryBean,Feature,FeatureRelatedBean,FilePathBean,ImageBean,MarksBean,NullParametersBean,PointsBean
A bean that must be initialized with some parameters before being used.
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInitializableBean(BeanInitializer<P> beanInitializer, InitializationParameterAssigner propertyInitializer) Creates a newInitializableBeaninstance. -
Method Summary
Modifier and TypeMethodDescriptionprotected PThe parameters used for initialization.protected LoggerThe logger.Assigns a parameter, if possible, to a bean - as used bybean initializer.voidinitialize(P parameters, Logger logger) Initializes the bean with the necessary parameters.voidinitializeRecursive(P parameters, Logger logger) Initializes this object, and all children objects, so long as they havePonce a Bean doesn't haveP, the children are not evaluated.voidinitRecursiveWithInitializer(BeanInitializer<?> initializer, Logger logger) Initializes the bean and recursively all contained beans (who have compatible initialization requirements)booleanHas the been already been initialized via a call toinitialize(BeanInitialization, Logger)or similar.voidonInitialization(P initialization) Called after initialization.Methods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
InitializableBean
protected InitializableBean(BeanInitializer<P> beanInitializer, InitializationParameterAssigner propertyInitializer) Creates a newInitializableBeaninstance.- Parameters:
beanInitializer- Initializes a bean with another parameter.propertyInitializer- Assigns a parameter, if possible, to a bean - as used bybean initializer.
-
-
Method Details
-
initialize
Initializes the bean with the necessary parameters.This method should always be called once before using the other methods of the bean.
- Parameters:
parameters- parameters to initialize with.logger- a logger for events.- Throws:
InitializeException- if initialization cannot complete successfully.
-
onInitialization
Called after initialization. An empty implementation is provided, to be overridden as needed in the sub-classes.- Parameters:
initialization- parameters used for initialization.- Throws:
InitializeException- if initialization does not successfully complete.
-
initRecursiveWithInitializer
public void initRecursiveWithInitializer(BeanInitializer<?> initializer, Logger logger) throws InitializeException Initializes the bean and recursively all contained beans (who have compatible initialization requirements)- Parameters:
initializer- the property-initializer to use.logger- logger.- Throws:
InitializeException- if the initialization fails, including if correct initialization-parameters cannot be derived.
-
initializeRecursive
Initializes this object, and all children objects, so long as they havePonce a Bean doesn't haveP, the children are not evaluated.- Parameters:
parameters- the parameters to initialize with.logger- logger.- Throws:
InitializeException- if the initialization fails.
-
isInitialized
public boolean isInitialized()Has the been already been initialized via a call toinitialize(BeanInitialization, Logger)or similar.- Returns:
- true iff the bean has been initialized.
-
getLogger
The logger.- Returns:
- the logger.
-
getInitialization
The parameters used for initialization.- Returns:
- the parameters passed for initialization.
- Throws:
InitializeException- if the bean has not been initialized.
-
getPropertyInitializer
Assigns a parameter, if possible, to a bean - as used bybean initializer.
-