AutowireCapableBeanFactory接口方法詳解

1、<T> T createBean(Class<T> beanClass) throws BeansException;

??Fully create a new bean instance of the given class.
??由某類型的.class創(chuàng)造一個(gè)bean。


2、void autowireBean(Object existingBean) throws BeansException;

??Populate the given bean instance through applying after-instantiation callbacks and bean property post-processing (e.g. for annotation-driven injection).
??在bean實(shí)例化和屬性設(shè)置完畢之后,填充對(duì)應(yīng)的bean instance


3、Object configureBean(Object existingBean, String beanName) throws BeansException;

??Configure the given raw bean: autowiring bean properties, applying bean property values, applying factory callbacks such as setBeanName and setBeanFactory, and also applying all bean post processors (including ones which might wrap the given raw bean).
??配置參數(shù)中給出的raw bean,自動(dòng)配置bean的屬性,包括對(duì)屬性賦值,設(shè)置好工廠類的回調(diào)函數(shù)(setBeanName、SetBeanFactory)。還有就是調(diào)用所有的post processors(包括那些對(duì)raw bean的包裝操作)


4、Object createBean(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws BeansException;

??Fully create a new bean instance of the given class with the specified autowire strategy. All constants defined in this interface are supported here.
??Performs full initialization of the bean, including all applicable BeanPostProcessors. This is effectively a superset of what autowire provides, adding initializeBean behavior.
??這是創(chuàng)建一個(gè)新的bean 實(shí)例的整個(gè)操作過(guò)程,參數(shù)描述了新的bean的class和其配置策略。在這個(gè)interface中定義的所有的常量,在這個(gè)方法中都可以使用。
??初始化一個(gè)bean的整個(gè)過(guò)程,包括所有可以適用的BeanPostProcessors。這是一個(gè)有效的***(最后一句真的不會(huì)翻譯了)


5、Object autowire(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws BeansException;

??Instantiate a new bean instance of the given class with the specified autowire strategy. All constants defined in this interface are supported here. Can also be invoked with AUTOWIRE_NO in order to just apply before-instantiation callbacks (e.g. for annotation-driven injection).
??Does not apply standard BeanPostProcessors callbacks or perform any further initialization of the bean. This interface offers distinct, fine-grained operations for those purposes, for example initializeBean. However, InstantiationAwareBeanPostProcessor callbacks are applied, if applicable to the construction of the instance.
??根據(jù)參數(shù)中指定的autowire(注入)方式,實(shí)例化一個(gè)由參數(shù)中類的新的bean??梢允褂眠@個(gè)借口中定義的所有常量。還可以在回調(diào)之前用AUTOWIRE_NO為順序來(lái)調(diào)用。
??對(duì)一個(gè)bean不用標(biāo)準(zhǔn)的BeanPostProcessors回調(diào)方法或者實(shí)現(xiàn)更多的初始化操作。這個(gè)為這個(gè)目的接口提供獨(dú)特的細(xì)粒度的操作方法,舉個(gè)初始化bean的例子來(lái)說(shuō),如果一個(gè)實(shí)例適用,就調(diào)用InstantiationAwareBeanPostProcessor。


6、void autowireBeanProperties(Object existingBean, int autowireMode, boolean dependencyCheck) throws BeansException;

??Autowire the bean properties of the given bean instance by name or type. Can also be invoked with AUTOWIRE_NO in order to just apply after-instantiation callbacks (e.g. for annotation-driven injection).
??根據(jù)名字或者類型自動(dòng)注入?yún)?shù)中指定的bean實(shí)例的屬性。同時(shí)可以由AUTOWIRE_NO來(lái)對(duì)實(shí)例化后回調(diào)進(jìn)行排序。


7、void applyBeanPropertyValues(Object existingBean, String beanName) throws BeansException;

??Apply the property values of the bean definition with the given name to the given bean instance. The bean definition can either define a fully self-contained bean, reusing its property values, or just property values meant to be used for existing bean instances.
??對(duì)由名字和bean實(shí)例指定的bean進(jìn)行屬性復(fù)制操作。bean定義的屬性可以是單獨(dú)使用、重復(fù)使用、或者是屬性值表示bean實(shí)例可以使用。


未完待續(xù)。。。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 文章作者:Tyan博客:noahsnail.com 3.4 Dependencies A typical ente...
    SnailTyan閱讀 4,504評(píng)論 2 7
  • Spring Cloud為開(kāi)發(fā)人員提供了快速構(gòu)建分布式系統(tǒng)中一些常見(jiàn)模式的工具(例如配置管理,服務(wù)發(fā)現(xiàn),斷路器,智...
    卡卡羅2017閱讀 136,641評(píng)論 19 139
  • org.springframework.beans: org.springframework.beans.fact...
    過(guò)河卒sc閱讀 668評(píng)論 1 1
  • 這段時(shí)間,心情無(wú)比的糟糕。 12月18日中午,孩子在上學(xué)途中,有一老者倒在她自行車后端。孩子在一無(wú)名女子拉住,把責(zé)...
    梧桐花開(kāi)0209閱讀 1,012評(píng)論 0 0
  • 我今天主動(dòng)找李書(shū)磊聊天了,感覺(jué)挺好的。覺(jué)得他很矮,不爽,可是他很可愛(ài),和自己很投脾氣,一看就知道是好朋友。可是現(xiàn)在...
    愛(ài)源閱讀 160評(píng)論 0 0

友情鏈接更多精彩內(nèi)容