Class BeanConfigurerSupport
- java.lang.Object
- org.springframework.beans.factory.wiring.BeanConfigurerSupport
- All Implemented Interfaces:
Aware,BeanFactoryAware,DisposableBean,InitializingBean
public class BeanConfigurerSupport extends Object implements BeanFactoryAware, InitializingBean, DisposableBean
Convenient base class for bean configurers that can perform Dependency Injection on objects (however they may be created). Typically subclassed by AspectJ aspects.Subclasses may also need a custom metadata resolution strategy, in the
BeanWiringInfoResolverinterface. The default implementation looks for a bean with the same name as the fully-qualified class name. (This is the default name of the bean in a Spring XML file if the 'id' attribute is not used.)- Since:
- 2.0
- Author:
- Rob Harrop, Rod Johnson, Juergen Hoeller, Adrian Colyer
- See Also:
setBeanWiringInfoResolver(org.springframework.beans.factory.wiring.BeanWiringInfoResolver),ClassNameBeanWiringInfoResolver
Constructor Summary
Constructors Constructor Description BeanConfigurerSupport()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()Check that aBeanFactoryhas been set.voidconfigureBean(Object beanInstance)Configure the bean instance.protected BeanWiringInfoResolvercreateDefaultBeanWiringInfoResolver()Create the default BeanWiringInfoResolver to be used if none was specified explicitly.voiddestroy()Release references to theBeanFactoryandBeanWiringInfoResolverwhen the container is destroyed.voidsetBeanFactory(BeanFactory beanFactory)Set theBeanFactoryin which this aspect must configure beans.voidsetBeanWiringInfoResolver(BeanWiringInfoResolver beanWiringInfoResolver)Set theBeanWiringInfoResolverto use.
Constructor Detail
BeanConfigurerSupport
public BeanConfigurerSupport()
Method Detail
setBeanWiringInfoResolver
public void setBeanWiringInfoResolver(BeanWiringInfoResolver beanWiringInfoResolver)
Set theBeanWiringInfoResolverto use.The default behavior is to look for a bean with the same name as the class. As an alternative, consider using annotation-driven bean wiring.
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)
Set theBeanFactoryin which this aspect must configure beans.- Specified by:
setBeanFactoryin interfaceBeanFactoryAware- Parameters:
beanFactory- owning BeanFactory (nevernull). The bean can immediately call methods on the factory.- See Also:
BeanInitializationException
createDefaultBeanWiringInfoResolver
protected BeanWiringInfoResolver createDefaultBeanWiringInfoResolver()
Create the default BeanWiringInfoResolver to be used if none was specified explicitly.The default implementation builds a
ClassNameBeanWiringInfoResolver.- Returns:
- the default BeanWiringInfoResolver (never
null)
afterPropertiesSet
public void afterPropertiesSet()
Check that aBeanFactoryhas been set.- Specified by:
afterPropertiesSetin interfaceInitializingBean
destroy
public void destroy()
Release references to theBeanFactoryandBeanWiringInfoResolverwhen the container is destroyed.- Specified by:
destroyin interfaceDisposableBean
configureBean
public void configureBean(Object beanInstance)
Configure the bean instance.Subclasses can override this to provide custom configuration logic. Typically called by an aspect, for all bean instances matched by a pointcut.
- Parameters:
beanInstance- the bean instance to configure (must not benull)