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
ConstructorsModifierConstructorDescriptionprotected
InitializableBean
(BeanInitializer<P> beanInitializer, InitializationParameterAssigner propertyInitializer) Creates a newInitializableBean
instance. -
Method Summary
Modifier and TypeMethodDescriptionprotected P
The parameters used for initialization.protected Logger
The logger.Assigns a parameter, if possible, to a bean - as used bybean initializer
.void
initialize
(P parameters, Logger logger) Initializes the bean with the necessary parameters.void
initializeRecursive
(P parameters, Logger logger) Initializes this object, and all children objects, so long as they haveP
once a Bean doesn't haveP
, the children are not evaluated.void
initRecursiveWithInitializer
(BeanInitializer<?> initializer, Logger logger) Initializes the bean and recursively all contained beans (who have compatible initialization requirements)boolean
Has the been already been initialized via a call toinitialize(BeanInitialization, Logger)
or similar.void
onInitialization
(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 newInitializableBean
instance.- 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 haveP
once 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
.
-