Class BeanInitializer<P>
Object
BeanInitializer<P>
- Type Parameters:
P
- init-param type
Tries to initialize a bean and it's children with particular parameters, if possible.
If the passed parameters are not directly suitable for initialization, other parameters may also be derived and used instead.
Specifically, two types of properties will be initialized:
- Properties that have identical property-type to
P
(the current parameters). - Properties with another property-type that can be extracted from
P
(the current parameters).
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionBeanInitializer
(Class<?> initializationType) Simpler case where only the current-parameters can be initialized, but for no further property-types.BeanInitializer
(Class<?> initializationType, List<ExtractDerivedParameter<P, ?>> extractersToAdd) More complex-case where both current-parameters and other extracted property-types can be initialized. -
Method Summary
Modifier and TypeMethodDescriptionboolean
applyInitializationIfPossibleTo
(Object bean, Object parent, Logger logger) Applies the initialization to a bean if possible.Class
<?> Type of parameters to be propagated, corresponding toP
.void
Sets the current parameters used for propagation.
-
Constructor Details
-
BeanInitializer
Simpler case where only the current-parameters can be initialized, but for no further property-types.- Parameters:
initializationType
- type of parameters to be propagated, corresponding to<P>
.
-
BeanInitializer
public BeanInitializer(Class<?> initializationType, List<ExtractDerivedParameter<P, ?>> extractersToAdd) More complex-case where both current-parameters and other extracted property-types can be initialized.- Parameters:
initializationType
- type of parameters to be propagated, corresponding to<P>
.extractersToAdd
- extracters to used for other property-types that can be derived from current property-type.
-
-
Method Details
-
setParam
Sets the current parameters used for propagation.- Parameters:
param
- the parameters to be assigned, and to be propagated into initialized beans.
-
applyInitializationIfPossibleTo
public boolean applyInitializationIfPossibleTo(Object bean, Object parent, Logger logger) throws InitializeException Applies the initialization to a bean if possible.As a prerequisite,
setParam(Object)
must be called before calling this method.Initialization is possible if either the parameters set above, or derived parameters are of acceptable type.
- Parameters:
bean
- the bean to be initialized.parent
- the parent bean ofbean
.logger
- logger for any errors.- Returns:
- true if some kind of initialization occurred with this property, false otherwise.
- Throws:
InitializeException
- if initialization could not successfully complete.
-
getInitializationType
Type of parameters to be propagated, corresponding toP
.
-