spring AutowireCapableBeanFactory 自动注入
2016-03-29 15:34 youxin 阅读(1622) 评论(0) 编辑 收藏 举报文档:http://docs.spring.io/spring/docs/3.0.x/javadoc-api/org/springframework/beans/factory/config/AutowireCapableBeanFactory.html
public interface AutowireCapableBeanFactoryextends BeanFactory
Extension of the BeanFactory
interface to be implemented by bean factories that are capable of autowiring, provided that they want to expose this functionality for existing bean instances.
This subinterface of BeanFactory is not meant to be used in normal application code: stick to BeanFactory
or ListableBeanFactory
for typical use cases.
Integration code for other frameworks can leverage this interface to wire and populate existing bean instances that Spring does not control the lifecycle of. This is particularly useful for WebWork Actions and Tapestry Page objects, for example.
Note that this interface is not implemented by ApplicationContext
facades, as it is hardly ever used by application code. That said, it is available from an application context too, accessible through ApplicationContext's ApplicationContext.getAutowireCapableBeanFactory()
method.
You may also implement the BeanFactoryAware
interface, which exposes the internal BeanFactory even when running in an ApplicationContext, to get access to an AutowireCapableBeanFactory: simply cast the passed-in BeanFactory to AutowireCapableBeanFactory.
AutowireCapableBeanFactory这个接口一般在applicationContext的内部是较少使用的,它的功能主要是为了装配applicationContext管理之外的Bean。
参考:Spring中AutowireCapableBeanFactory的使用