Class 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 the BatchProperty annotation before processing injection annotations. If the annotation is found, further injection processing for the field is skipped.

    • Field Summary

      Fields 
      Modifier and TypeFieldDescription
      protected org.apache.commons.logging.Loglogger 
      • Fields inherited from interface org.springframework.core.Ordered

        HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      protected org.springframework.beans.factory.annotation.InjectionMetadatabuildAutowiringMetadata​(java.lang.Class<?> clazz) 
      java.lang.reflect.Constructor<?>[]determineCandidateConstructors​(java.lang.Class<?> beanClass, java.lang.String beanName) 
      protected booleandetermineRequiredStatus​(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.AnnotationfindAutowiredAnnotation​(java.lang.reflect.AccessibleObject ao) 
      protected org.springframework.beans.factory.annotation.InjectionMetadatafindAutowiringMetadata​(java.lang.Class<?> clazz) 
      intgetOrder() 
      voidpostProcessMergedBeanDefinition​(org.springframework.beans.factory.support.RootBeanDefinition beanDefinition, java.lang.Class<?> beanType, java.lang.String beanName) 
      org.springframework.beans.PropertyValuespostProcessPropertyValues​(org.springframework.beans.PropertyValues pvs, java.beans.PropertyDescriptor[] pds, java.lang.Object bean, java.lang.String beanName) 
      voidprocessInjection​(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.
      voidsetAutowiredAnnotationType​(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.
      voidsetAutowiredAnnotationTypes​(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.
      voidsetBeanFactory​(org.springframework.beans.factory.BeanFactory beanFactory) 
      voidsetOrder​(int order) 
      voidsetRequiredParameterName​(java.lang.String requiredParameterName)
      Set the name of a parameter of the annotation that specifies whether it is required.
      voidsetRequiredParameterValue​(boolean requiredParameterValue)
      Set the boolean value that marks a dependency as required
      • Methods 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
      • Methods inherited from interface org.springframework.beans.factory.config.BeanPostProcessor

        postProcessAfterInitialization, postProcessBeforeInitialization
      • Methods inherited from interface org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor

        resetBeanDefinition
    • Field Detail

      • logger

        protected final org.apache.commons.logging.Log logger
    • Constructor Detail

      • JsrAutowiredAnnotationBeanPostProcessor

        public JsrAutowiredAnnotationBeanPostProcessor()
    • 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 as Value.

        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 as Value.

        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 required

        For example if using 'required=true' (the default), this value should be true; but if using 'optional=false', this value should be false.

        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 interface org.springframework.core.Ordered
      • setBeanFactory

        public void setBeanFactory​(org.springframework.beans.factory.BeanFactory beanFactory)
                            throws org.springframework.beans.BeansException
        Specified by:
        setBeanFactory in interface org.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 interface org.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 interface org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor
        Overrides:
        determineCandidateConstructors in class org.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 interface org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor
        Overrides:
        postProcessPropertyValues in class org.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