Save This Page
Home » spring-framework-2.5.5-with-dependencies » org.springframework » beans » factory » annotation » [javadoc | source]
org.springframework.beans.factory.annotation
public class: AutowiredAnnotationBeanPostProcessor [javadoc | source]
java.lang.Object
   org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter
      org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor

All Implemented Interfaces:
    PriorityOrdered, BeanFactoryAware, MergedBeanDefinitionPostProcessor, SmartInstantiationAwareBeanPostProcessor

org.springframework.beans.factory.config.BeanPostProcessor implementation that autowires annotated fields, setter methods and arbitrary config methods. Such members to be injected are detected through a Java 5 annotation: by default, Spring's Autowired annotation.

Only one constructor (at max) of any given bean class may carry this annotation with the 'required' parameter set to true, indicating the constructor to autowire when used as a Spring bean. If multiple non-required constructors carry the annotation, they will be considered as candidates for autowiring. The constructor with the greatest number of dependencies that can be satisfied by matching beans in the Spring container will be chosen. If none of the candidates can be satisfied, then a default constructor (if present) will be used. An annotated constructor does not have to be public.

Fields are injected right after construction of a bean, before any config methods are invoked. Such a config field does not have to be public.

Config methods may have an arbitrary name and any number of arguments; each of those arguments will be autowired with a matching bean in the Spring container. Bean property setter methods are effectively just a special case of such a general config method. Such config methods do not have to be public.

Note: A default AutowiredAnnotationBeanPostProcessor 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 AutowiredAnnotationBeanPostProcessor bean definition.

Field Summary
protected final  Log logger     
Method from org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor Summary:
determineCandidateConstructors,   determineRequiredStatus,   findAutowireCandidates,   getAutowiredAnnotationType,   getOrder,   postProcessAfterInstantiation,   postProcessMergedBeanDefinition,   postProcessPropertyValues,   processInjection,   setAutowiredAnnotationType,   setBeanFactory,   setOrder,   setRequiredParameterName,   setRequiredParameterValue
Methods from org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter:
determineCandidateConstructors,   getEarlyBeanReference,   postProcessAfterInitialization,   postProcessAfterInstantiation,   postProcessBeforeInitialization,   postProcessBeforeInstantiation,   postProcessPropertyValues,   predictBeanType
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor Detail:
 public Constructor[] determineCandidateConstructors(Class beanClass,
    String beanName) throws BeansException 
 protected boolean determineRequiredStatus(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.

 protected Map findAutowireCandidates(Class type) throws BeansException 
    Obtain all beans of the given type as autowire candidates.
 protected Class getAutowiredAnnotationType() 
    Return the 'autowired' annotation type.
 public int getOrder() 
 public boolean postProcessAfterInstantiation(Object bean,
    String beanName) throws BeansException 
 public  void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition,
    Class beanType,
    String beanName) 
 public PropertyValues postProcessPropertyValues(PropertyValues pvs,
    PropertyDescriptor[] pds,
    Object bean,
    String beanName) throws BeansException 
 public  void processInjection(Object bean) throws BeansException 
    'Native' processing method for direct calls with an arbitrary target instance, resolving all of its fields and methods which are annotated with @Autowired.
 public  void setAutowiredAnnotationType(Class 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.

    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.

 public  void setBeanFactory(BeanFactory beanFactory) throws BeansException 
 public  void setOrder(int order) 
 public  void setRequiredParameterName(String requiredParameterName) 
    Set the name of a parameter of the annotation that specifies whether it is required.
 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.