| java.lang.Object org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor
RequiredAnnotationBeanPostProcessor | public class RequiredAnnotationBeanPostProcessor extends InstantiationAwareBeanPostProcessorAdapter (Code) | | org.springframework.beans.factory.config.BeanPostProcessor implementation
that enforces required JavaBean properties to have been configured.
Required bean properties are detected through a Java 5 annotation:
by default, Spring's
Required annotation.
The motivation for the existence of this BeanPostProcessor is to allow
developers to annotate the setter properties of their own classes with an
arbitrary JDK 1.5 annotation to indicate that the container must check
for the configuration of a dependency injected value. This neatly pushes
responsibility for such checking onto the container (where it arguably belongs),
and obviates the need (in part) for a developer to code a method that
simply checks that all required properties have actually been set.
Please note that an 'init' method may still need to implemented (and may
still be desirable), because all that this class does is enforce that a
'required' property has actually been configured with a value. It does
not check anything else... In particular, it does not check that a
configured value is not null .
author: Rob Harrop author: Juergen Hoeller since: 2.0 See Also: RequiredAnnotationBeanPostProcessor.setRequiredAnnotationType See Also: Required |
getRequiredAnnotationType | protected Class<? extends Annotation> getRequiredAnnotationType()(Code) | | Return the 'required' annotation type.
|
isRequiredProperty | protected boolean isRequiredProperty(PropertyDescriptor propertyDescriptor)(Code) | | Is the supplied property required to have a value (that is, to be dependency-injected)?
This implementation looks for the existence of a
RequiredAnnotationBeanPostProcessor.setRequiredAnnotationType "required" annotation on the supplied
PropertyDescriptor property .
Parameters: propertyDescriptor - the target PropertyDescriptor (never null ) true if the supplied property has been marked as being required;false if not, or if the supplied property does not have a setter method |
setRequiredAnnotationType | public void setRequiredAnnotationType(Class<? extends Annotation> requiredAnnotationType)(Code) | | Set the 'required' annotation type, to be used on bean property
setter methods.
The default required annotation type is the Spring-provided
Required annotation.
This setter property exists so that developers can provide their own
(non-Spring-specific) annotation type to indicate that a property value
is required.
|
|
|