open class RequiredAnnotationBeanPostProcessor : InstantiationAwareBeanPostProcessorAdapter, MergedBeanDefinitionPostProcessor, PriorityOrdered, BeanFactoryAware
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.
Note: A default RequiredAnnotationBeanPostProcessor will be registered by the "context:annotation-config" and "context:component-scan" XML tags. Remove or turn off the default annotation configuration there if you intend to specify a custom RequiredAnnotationBeanPostProcessor bean definition.
Author
Rob Harrop
Author
Juergen Hoeller
Since
2.0
See Also
#setRequiredAnnotationTypeRequired
RequiredAnnotationBeanPostProcessor()
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 Note: A default RequiredAnnotationBeanPostProcessor will be registered by the "context:annotation-config" and "context:component-scan" XML tags. Remove or turn off the default annotation configuration there if you intend to specify a custom RequiredAnnotationBeanPostProcessor bean definition. |
static val SKIP_REQUIRED_CHECK_ATTRIBUTE: String
Bean definition attribute that may indicate whether a given bean is supposed to be skipped when performing this post-processor's required property check. |
open fun getOrder(): Int |
|
open fun postProcessMergedBeanDefinition(beanDefinition: RootBeanDefinition, beanType: Class<*>, beanName: String): Unit |
|
open fun postProcessPropertyValues(pvs: PropertyValues, pds: Array<PropertyDescriptor>, bean: Any, beanName: String): PropertyValues |
|
open fun setBeanFactory(beanFactory: BeanFactory): Unit |
|
open fun setOrder(order: Int): Unit |
|
open fun setRequiredAnnotationType(requiredAnnotationType: Class<out Annotation>): Unit
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. |
open fun determineCandidateConstructors(beanClass: Class<*>, beanName: String): Array<Constructor<*>> |
|
open fun getEarlyBeanReference(bean: Any, beanName: String): Any |
|
open fun postProcessAfterInitialization(bean: Any, beanName: String): Any |
|
open fun postProcessAfterInstantiation(bean: Any, beanName: String): Boolean |
|
open fun postProcessBeforeInitialization(bean: Any, beanName: String): Any |
|
open fun postProcessBeforeInstantiation(beanClass: Class<*>, beanName: String): Any |
|
open fun predictBeanType(beanClass: Class<*>, beanName: String): Class<*> |