Class JsrAutowiredAnnotationBeanPostProcessor
- java.lang.Object
- org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter
- org.springframework.batch.core.jsr.configuration.support.JsrAutowiredAnnotationBeanPostProcessor
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.BeanFactoryAware
,org.springframework.beans.factory.config.BeanPostProcessor
,org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor
,org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor
,org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor
,org.springframework.core.Ordered
,org.springframework.core.PriorityOrdered
public class JsrAutowiredAnnotationBeanPostProcessor extends org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter
This class overrides methods in the copied
SpringAutowiredAnnotationBeanPostProcessor
class to check for theBatchProperty
annotation before processing injection annotations. If the annotation is found, further injection processing for the field is skipped.
Field Summary
Fields Modifier and Type Field Description protected org.apache.commons.logging.Log
logger
Constructor Summary
Constructors Constructor Description JsrAutowiredAnnotationBeanPostProcessor()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.springframework.beans.factory.annotation.InjectionMetadata
buildAutowiringMetadata(java.lang.Class<?> clazz)
java.lang.reflect.Constructor<?>[]
determineCandidateConstructors(java.lang.Class<?> beanClass, java.lang.String beanName)
protected boolean
determineRequiredStatus(java.lang.annotation.Annotation annotation)
Determine if the annotated field or method requires its dependency.protected <T> java.util.Map<java.lang.String,T>
findAutowireCandidates(java.lang.Class<T> type)
Obtain all beans of the given type as autowire candidates.protected java.lang.annotation.Annotation
findAutowiredAnnotation(java.lang.reflect.AccessibleObject ao)
protected org.springframework.beans.factory.annotation.InjectionMetadata
findAutowiringMetadata(java.lang.Class<?> clazz)
int
getOrder()
void
postProcessMergedBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition beanDefinition, java.lang.Class<?> beanType, java.lang.String beanName)
org.springframework.beans.PropertyValues
postProcessPropertyValues(org.springframework.beans.PropertyValues pvs, java.beans.PropertyDescriptor[] pds, java.lang.Object bean, java.lang.String beanName)
void
processInjection(java.lang.Object bean)
'Native' processing method for direct calls with an arbitrary target instance, resolving all of its fields and methods which are annotated with@Autowired
.void
setAutowiredAnnotationType(java.lang.Class<? extends java.lang.annotation.Annotation> autowiredAnnotationType)
Set the 'autowired' annotation type, to be used on constructors, fields, setter methods and arbitrary config methods.void
setAutowiredAnnotationTypes(java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> autowiredAnnotationTypes)
Set the 'autowired' annotation types, to be used on constructors, fields, setter methods and arbitrary config methods.void
setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)
void
setOrder(int order)
void
setRequiredParameterName(java.lang.String requiredParameterName)
Set the name of a parameter of the annotation that specifies whether it is required.void
setRequiredParameterValue(boolean requiredParameterValue)
Set the boolean value that marks a dependency as requiredMethods inherited from class org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter
getEarlyBeanReference, postProcessAfterInitialization, postProcessAfterInstantiation, postProcessBeforeInitialization, postProcessBeforeInstantiation, postProcessProperties, predictBeanType
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Method Detail
findAutowiringMetadata
protected org.springframework.beans.factory.annotation.InjectionMetadata findAutowiringMetadata(java.lang.Class<?> clazz)
findAutowiredAnnotation
protected java.lang.annotation.Annotation findAutowiredAnnotation(java.lang.reflect.AccessibleObject ao)
setAutowiredAnnotationType
public void setAutowiredAnnotationType(java.lang.Class<? extends java.lang.annotation.Annotation> autowiredAnnotationType)
Set the 'autowired' annotation type, to be used on constructors, fields, setter methods and arbitrary config methods.The default autowired annotation type is the Spring-provided
Autowired
annotation, as well asValue
.This setter property exists so that developers can provide their own (non-Spring-specific) annotation type to indicate that a member is supposed to be autowired.
- Parameters:
autowiredAnnotationType
- type to be used by constructors, fields and methods.
setAutowiredAnnotationTypes
public void setAutowiredAnnotationTypes(java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>> autowiredAnnotationTypes)
Set the 'autowired' annotation types, to be used on constructors, fields, setter methods and arbitrary config methods.The default autowired annotation type is the Spring-provided
Autowired
annotation, as well asValue
.This setter property exists so that developers can provide their own (non-Spring-specific) annotation types to indicate that a member is supposed to be autowired.
- Parameters:
autowiredAnnotationTypes
- set of types to be used by constructors, fields and methods.
setRequiredParameterName
public void setRequiredParameterName(java.lang.String requiredParameterName)
Set the name of a parameter of the annotation that specifies whether it is required.- Parameters:
requiredParameterName
- the name of the parameter.- See Also:
setRequiredParameterValue(boolean)
setRequiredParameterValue
public void setRequiredParameterValue(boolean requiredParameterValue)
Set the boolean value that marks a dependency as requiredFor example if using 'required=true' (the default), this value should be
true
; but if using 'optional=false', this value should befalse
.- Parameters:
requiredParameterValue
- true if dependency is required.- See Also:
setRequiredParameterName(String)
setOrder
public void setOrder(int order)
getOrder
public int getOrder()
- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
setBeanFactory
public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory) throws org.springframework.beans.BeansException
- Specified by:
setBeanFactory
in interfaceorg.springframework.beans.factory.BeanFactoryAware
- Throws:
org.springframework.beans.BeansException
postProcessMergedBeanDefinition
public void postProcessMergedBeanDefinition(org.springframework.beans.factory.support.RootBeanDefinition beanDefinition, java.lang.Class<?> beanType, java.lang.String beanName)
- Specified by:
postProcessMergedBeanDefinition
in interfaceorg.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor
determineCandidateConstructors
public java.lang.reflect.Constructor<?>[] determineCandidateConstructors(java.lang.Class<?> beanClass, java.lang.String beanName) throws org.springframework.beans.BeansException
- Specified by:
determineCandidateConstructors
in interfaceorg.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor
- Overrides:
determineCandidateConstructors
in classorg.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter
- Throws:
org.springframework.beans.BeansException
postProcessPropertyValues
public org.springframework.beans.PropertyValues postProcessPropertyValues(org.springframework.beans.PropertyValues pvs, java.beans.PropertyDescriptor[] pds, java.lang.Object bean, java.lang.String beanName) throws org.springframework.beans.BeansException
- Specified by:
postProcessPropertyValues
in interfaceorg.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor
- Overrides:
postProcessPropertyValues
in classorg.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter
- Throws:
org.springframework.beans.BeansException
processInjection
public void processInjection(java.lang.Object bean) throws org.springframework.beans.BeansException
'Native' processing method for direct calls with an arbitrary target instance, resolving all of its fields and methods which are annotated with@Autowired
.- Parameters:
bean
- the target instance to process- Throws:
org.springframework.beans.BeansException
- if autowiring failed
buildAutowiringMetadata
protected org.springframework.beans.factory.annotation.InjectionMetadata buildAutowiringMetadata(java.lang.Class<?> clazz)
findAutowireCandidates
protected <T> java.util.Map<java.lang.String,T> findAutowireCandidates(java.lang.Class<T> type) throws org.springframework.beans.BeansException
Obtain all beans of the given type as autowire candidates.- Type Parameters:
T
- the type of the bean.- Parameters:
type
- the type of the bean.- Returns:
- the target beans, or an empty Collection if no bean of this type is found
- Throws:
org.springframework.beans.BeansException
- if bean retrieval failed
determineRequiredStatus
protected boolean determineRequiredStatus(java.lang.annotation.Annotation annotation)
Determine if the annotated field or method requires its dependency.A 'required' dependency means that autowiring should fail when no beans are found. Otherwise, the autowiring process will simply bypass the field or method when no beans are found.
- Parameters:
annotation
- the Autowired annotation- Returns:
- whether the annotation indicates that a dependency is required