|
The Spring Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter
org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
public class AutowiredAnnotationBeanPostProcessor
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, indicating the constructor to autowire when used as a Spring bean. Such a 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.
setAutowiredAnnotationType(java.lang.Class extends java.lang.annotation.Annotation>),
Autowired,
CommonAnnotationBeanPostProcessor| Constructor Summary | |
|---|---|
AutowiredAnnotationBeanPostProcessor()
|
|
| Method Summary | |
|---|---|
Constructor |
determineConstructor(Class beanClass,
String beanName)
Determine the constructor to use for the given bean. |
protected Class<? extends Annotation> |
getAutowiredAnnotationType()
Return the 'autowired' annotation type. |
protected Object |
getBeanOfType(Class type)
Obtain a unique bean of the given type. |
boolean |
postProcessAfterInstantiation(Object bean,
String beanName)
Perform operations after the bean has been instantiated, via a constructor or factory method, but before Spring property population (from explicit properties or autowiring) occurs. |
void |
setAutowiredAnnotationType(Class<? extends Annotation> autowiredAnnotationType)
Set the 'autowired' annotation type, to be used on constructors, fields, setter methods and arbitrary config methods. |
void |
setBeanFactory(BeanFactory beanFactory)
Callback that supplies the owning factory to a bean instance. |
| Methods inherited from class org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter |
|---|
postProcessAfterInitialization, postProcessBeforeInitialization, postProcessBeforeInstantiation, postProcessPropertyValues, predictBeanType |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AutowiredAnnotationBeanPostProcessor()
| Method Detail |
|---|
public void setAutowiredAnnotationType(Class<? extends Annotation> autowiredAnnotationType)
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.
protected Class<? extends Annotation> getAutowiredAnnotationType()
public void setBeanFactory(BeanFactory beanFactory) throws BeansException
BeanFactoryAwareInvoked after the population of normal bean properties
but before an initialization callback such as
InitializingBean.afterPropertiesSet() or a custom init-method.
setBeanFactory in interface BeanFactoryAwarebeanFactory - owning BeanFactory (never null).
The bean can immediately call methods on the factory.
BeansException - in case of initialization errorsBeanInitializationExceptionpublic Constructor determineConstructor(Class beanClass, String beanName) throws BeansException
SmartInstantiationAwareBeanPostProcessor
determineConstructor in interface SmartInstantiationAwareBeanPostProcessordetermineConstructor in class InstantiationAwareBeanPostProcessorAdapterbeanClass - the raw class of the beanbeanName - the name of the bean
null if none specified
BeansException - in case of errorspublic boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException
InstantiationAwareBeanPostProcessor
postProcessAfterInstantiation in interface InstantiationAwareBeanPostProcessorpostProcessAfterInstantiation in class InstantiationAwareBeanPostProcessorAdapterbean - the bean instance created, but whose properties have not yet been setbeanName - the name of the bean
true if properties should be set on the bean; false
if property population should be skipped. Normal implementations should return true.
Returning false will also prevent any subsequent InstantiationAwareBeanPostProcessor
instances being invoked on this bean instance.
BeansException - in case of errorsprotected Object getBeanOfType(Class type) throws BeansException
type - the type of the bean
null)
BeansException - if we failed to obtain the bean
|
The Spring Framework | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||