日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

AutowireCapableBeanFactory接口

發布時間:2023/12/10 编程问答 47 豆豆
生活随笔 收集整理的這篇文章主要介紹了 AutowireCapableBeanFactory接口 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

AutowireCapableBeanFactory在BeanFactory基礎上實現了對存在實例的管理.可以使用這個接口集成其它框架,捆綁并填充并不由Spring管理生命周期并已存在的實例.像集成WebWork的Actions 和Tapestry Page就很實用.

一般應用開發者不會使用這個接口,所以像ApplicationContext這樣的外觀實現類不會實現這個接口,如果真手癢癢可以通過ApplicationContext的getAutowireCapableBeanFactory接口獲取.

AutowireCapableBeanFactory源碼 具體:

1、總共5個靜態不可變常量來指明裝配策略,其中一個常量被Spring3.0廢棄、一個常量表示沒有自動裝配,另外3個常量指明不同的裝配策略——根據名稱、根據類型、根據構造方法。

2、8個跟自動裝配有關的方法,實在是繁雜,具體的意義我們研究類的時候再分辨吧。

3、2個執行BeanPostProcessors的方法。

4、2個分解指定依賴的方法

總結:這個工廠接口繼承自BeanFacotory,它擴展了自動裝配的功能,根據類定義BeanDefinition裝配Bean、執行前、后處理器等。

/*** Extension of the {@link org.springframework.beans.factory.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.** <p>This subinterface of BeanFactory is not meant to be used in normal* application code: stick to {@link org.springframework.beans.factory.BeanFactory}* or {@link org.springframework.beans.factory.ListableBeanFactory} for* typical use cases.** <p>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.** <p>Note that this interface is not implemented by* {@link org.springframework.context.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* {@link org.springframework.context.ApplicationContext#getAutowireCapableBeanFactory()}* method.** <p>You may also implement the {@link org.springframework.beans.factory.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.** @author Juergen Hoeller* @since 04.12.2003* @see org.springframework.beans.factory.BeanFactoryAware* @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory* @see org.springframework.context.ApplicationContext#getAutowireCapableBeanFactory()*/ public interface AutowireCapableBeanFactory extends BeanFactory {/*** Constant that indicates no externally defined autowiring. Note that* BeanFactoryAware etc and annotation-driven injection will still be applied.* @see #createBean* @see #autowire* @see #autowireBeanProperties*/// 這個常量表明工廠沒有自動裝配的Beanint AUTOWIRE_NO = 0;/*** Constant that indicates autowiring bean properties by name* (applying to all bean property setters).* @see #createBean* @see #autowire* @see #autowireBeanProperties*/// 表明根據名稱自動裝配int AUTOWIRE_BY_NAME = 1;/*** Constant that indicates autowiring bean properties by type* (applying to all bean property setters).* @see #createBean* @see #autowire* @see #autowireBeanProperties*/// 表明根據類型自動裝配int AUTOWIRE_BY_TYPE = 2;/*** Constant that indicates autowiring the greediest constructor that* can be satisfied (involves resolving the appropriate constructor).* @see #createBean* @see #autowire*/// 表明根據構造方法快速裝配int AUTOWIRE_CONSTRUCTOR = 3;/*** Constant that indicates determining an appropriate autowire strategy* through introspection of the bean class.* @see #createBean* @see #autowire* @deprecated as of Spring 3.0: If you are using mixed autowiring strategies,* prefer annotation-based autowiring for clearer demarcation of autowiring needs.*/@Deprecated// 表明通過Bean的class的內部來自動裝配(有沒翻譯錯...)Spring3.0被棄用。int AUTOWIRE_AUTODETECT = 4;//-------------------------------------------------------------------------// Typical methods for creating and populating external bean instances// 創建和填充外部bean實例的典型方法//-------------------------------------------------------------------------/*** Fully create a new bean instance of the given class.* <p>Performs full initialization of the bean, including all applicable* {@link BeanPostProcessor BeanPostProcessors}.* <p>Note: This is intended for creating a fresh instance, populating annotated* fields and methods as well as applying all standard bean initialization callbacks.* It does <i>not</> imply traditional by-name or by-type autowiring of properties;* use {@link #createBean(Class, int, boolean)} for those purposes.* @param beanClass the class of the bean to create* @return the new bean instance* @throws BeansException if instantiation or wiring failed*/<T> T createBean(Class<T> beanClass) throws BeansException;/*** Populate the given bean instance through applying after-instantiation callbacks* and bean property post-processing (e.g. for annotation-driven injection).* <p>Note: This is essentially intended for (re-)populating annotated fields and* methods, either for new instances or for deserialized instances. It does* <i>not</i> imply traditional by-name or by-type autowiring of properties;* use {@link #autowireBeanProperties} for those purposes.* @param existingBean the existing bean instance* @throws BeansException if wiring failed*/// 使用autowireBeanProperties裝配屬性void autowireBean(Object existingBean) throws BeansException;/*** Configure the given raw bean: autowiring bean properties, applying* bean property values, applying factory callbacks such as {@code setBeanName}* and {@code setBeanFactory}, and also applying all bean post processors* (including ones which might wrap the given raw bean).* <p>This is effectively a superset of what {@link #initializeBean} provides,* fully applying the configuration specified by the corresponding bean definition.* <b>Note: This method requires a bean definition for the given name!</b>* @param existingBean the existing bean instance* @param beanName the name of the bean, to be passed to it if necessary* (a bean definition of that name has to be available)* @return the bean instance to use, either the original or a wrapped one* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException* if there is no bean definition with the given name* @throws BeansException if the initialization failed* @see #initializeBean*/// 自動裝配屬性,填充屬性值,使用諸如setBeanName,setBeanFactory這樣的工廠回調填充屬性,最好還要調用post processorObject configureBean(Object existingBean, String beanName) throws BeansException;/*** Resolve the specified dependency against the beans defined in this factory.* @param descriptor the descriptor for the dependency* @param beanName the name of the bean which declares the present dependency* @return the resolved object, or {@code null} if none found* @throws BeansException if dependency resolution failed*/Object resolveDependency(DependencyDescriptor descriptor, String beanName) throws BeansException;//-------------------------------------------------------------------------// Specialized methods for fine-grained control over the bean lifecycle// 在bean的生命周期進行細粒度控制的專門方法//-------------------------------------------------------------------------/*** Fully create a new bean instance of the given class with the specified* autowire strategy. All constants defined in this interface are supported here.* <p>Performs full initialization of the bean, including all applicable* {@link BeanPostProcessor BeanPostProcessors}. This is effectively a superset* of what {@link #autowire} provides, adding {@link #initializeBean} behavior.* @param beanClass the class of the bean to create* @param autowireMode by name or type, using the constants in this interface* @param dependencyCheck whether to perform a dependency check for objects* (not applicable to autowiring a constructor, thus ignored there)* @return the new bean instance* @throws BeansException if instantiation or wiring failed* @see #AUTOWIRE_NO* @see #AUTOWIRE_BY_NAME* @see #AUTOWIRE_BY_TYPE* @see #AUTOWIRE_CONSTRUCTOR*/// 會執行bean完整的初始化,包括BeanPostProcessors和initializeBeanObject createBean(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 {@code AUTOWIRE_NO} in order to just apply* before-instantiation callbacks (e.g. for annotation-driven injection).* <p>Does <i>not</i> apply standard {@link BeanPostProcessor BeanPostProcessors}* callbacks or perform any further initialization of the bean. This interface* offers distinct, fine-grained operations for those purposes, for example* {@link #initializeBean}. However, {@link InstantiationAwareBeanPostProcessor}* callbacks are applied, if applicable to the construction of the instance.* @param beanClass the class of the bean to instantiate* @param autowireMode by name or type, using the constants in this interface* @param dependencyCheck whether to perform a dependency check for object* references in the bean instance (not applicable to autowiring a constructor,* thus ignored there)* @return the new bean instance* @throws BeansException if instantiation or wiring failed* @see #AUTOWIRE_NO* @see #AUTOWIRE_BY_NAME* @see #AUTOWIRE_BY_TYPE* @see #AUTOWIRE_CONSTRUCTOR* @see #AUTOWIRE_AUTODETECT* @see #initializeBean* @see #applyBeanPostProcessorsBeforeInitialization* @see #applyBeanPostProcessorsAfterInitialization*/Object autowire(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws BeansException;/*** Autowire the bean properties of the given bean instance by name or type.* Can also be invoked with {@code AUTOWIRE_NO} in order to just apply* after-instantiation callbacks (e.g. for annotation-driven injection).* <p>Does <i>not</i> apply standard {@link BeanPostProcessor BeanPostProcessors}* callbacks or perform any further initialization of the bean. This interface* offers distinct, fine-grained operations for those purposes, for example* {@link #initializeBean}. However, {@link InstantiationAwareBeanPostProcessor}* callbacks are applied, if applicable to the configuration of the instance.* @param existingBean the existing bean instance* @param autowireMode by name or type, using the constants in this interface* @param dependencyCheck whether to perform a dependency check for object* references in the bean instance* @throws BeansException if wiring failed* @see #AUTOWIRE_BY_NAME* @see #AUTOWIRE_BY_TYPE* @see #AUTOWIRE_NO*/void autowireBeanProperties(Object existingBean, int autowireMode, boolean dependencyCheck)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.* <p>This method does <i>not</i> autowire bean properties; it just applies* explicitly defined property values. Use the {@link #autowireBeanProperties}* method to autowire an existing bean instance.* <b>Note: This method requires a bean definition for the given name!</b>* <p>Does <i>not</i> apply standard {@link BeanPostProcessor BeanPostProcessors}* callbacks or perform any further initialization of the bean. This interface* offers distinct, fine-grained operations for those purposes, for example* {@link #initializeBean}. However, {@link InstantiationAwareBeanPostProcessor}* callbacks are applied, if applicable to the configuration of the instance.* @param existingBean the existing bean instance* @param beanName the name of the bean definition in the bean factory* (a bean definition of that name has to be available)* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException* if there is no bean definition with the given name* @throws BeansException if applying the property values failed* @see #autowireBeanProperties*/void applyBeanPropertyValues(Object existingBean, String beanName) throws BeansException;/*** Initialize the given raw bean, applying factory callbacks* such as {@code setBeanName} and {@code setBeanFactory},* also applying all bean post processors (including ones which* might wrap the given raw bean).* <p>Note that no bean definition of the given name has to exist* in the bean factory. The passed-in bean name will simply be used* for callbacks but not checked against the registered bean definitions.* @param existingBean the existing bean instance* @param beanName the name of the bean, to be passed to it if necessary* (only passed to {@link BeanPostProcessor BeanPostProcessors})* @return the bean instance to use, either the original or a wrapped one* @throws BeansException if the initialization failed*/Object initializeBean(Object existingBean, String beanName) throws BeansException;/*** Apply {@link BeanPostProcessor BeanPostProcessors} to the given existing bean* instance, invoking their {@code postProcessBeforeInitialization} methods.* The returned bean instance may be a wrapper around the original.* @param existingBean the new bean instance* @param beanName the name of the bean* @return the bean instance to use, either the original or a wrapped one* @throws BeansException if any post-processing failed* @see BeanPostProcessor#postProcessBeforeInitialization*/Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName)throws BeansException;/*** Apply {@link BeanPostProcessor BeanPostProcessors} to the given existing bean* instance, invoking their {@code postProcessAfterInitialization} methods.* The returned bean instance may be a wrapper around the original.* @param existingBean the new bean instance* @param beanName the name of the bean* @return the bean instance to use, either the original or a wrapped one* @throws BeansException if any post-processing failed* @see BeanPostProcessor#postProcessAfterInitialization*/Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName)throws BeansException;/*** Destroy the given bean instance (typically coming from {@link #createBean}),* applying the {@link org.springframework.beans.factory.DisposableBean} contract as well as* registered {@link DestructionAwareBeanPostProcessor DestructionAwareBeanPostProcessors}.* <p>Any exception that arises during destruction should be caught* and logged instead of propagated to the caller of this method.* @param existingBean the bean instance to destroy*/void destroyBean(Object existingBean);/*** Resolve the specified dependency against the beans defined in this factory.* @param descriptor the descriptor for the dependency* @param beanName the name of the bean which declares the present dependency* @param autowiredBeanNames a Set that all names of autowired beans (used for* resolving the present dependency) are supposed to be added to* @param typeConverter the TypeConverter to use for populating arrays and* collections* @return the resolved object, or {@code null} if none found* @throws BeansException if dependency resolution failed*/Object resolveDependency(DependencyDescriptor descriptor, String beanName,Set<String> autowiredBeanNames, TypeConverter typeConverter) throws BeansException;}

總結

以上是生活随笔為你收集整理的AutowireCapableBeanFactory接口的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲成年人影院 | 男生脱女生衣服 | 欧美日韩99| 啪啪五月天| 日本电影一区 | 色在线视频 | 伊人激情综合网 | 亚洲4438 | 美国毛片网站 | 午夜偷拍视频 | 另类ts人妖一区二区三区 | 91久久中文字幕 | av男人的天堂av | 日韩熟女精品一区二区三区 | 欧洲一二三区 | 国产一线av | 欧美少妇性生活 | 视频一区国产 | 欧美一区二区三区久久成人精品 | 欧美日本另类 | 国产激情视频在线 | www.在线观看网站 | 艳妇av| 天天艹av | 国产奶头好大揉着好爽视频 | av黄色在线观看 | 国产精品刺激 | 麻豆视频成人 | 日韩国产精品一区二区三区 | 91亚瑟 | 国产在线区 | 青草超碰 | 1024国产在线| 色哟哟无码精品一区二区三区 | 爱爱小视频免费看 | 亚洲精品免费在线观看 | 欧美婷婷精品激情 | 亚洲欧美综合另类自拍 | 精品久久久久久久久久久久久久久久久 | 国产福利在线观看 | 九色激情网 | 日韩va亚洲va欧美va久久 | 亚洲精品女人 | 欧美wwwwww| 精品一区二区三区在线免费观看 | 夜夜草天天草 | 福利视频免费看 | 亚洲激情在线观看 | 免费在线看视频 | 波多野结衣日韩 | 一二三av | 男人的天堂视频在线观看 | 少妇特黄一区二区三区 | 亚洲午夜久久久 | 九九视频免费在线观看 | 中文字幕高清av | 伊人久久影视 | 国产在线精品视频 | 国产成人精品一区二三区 | 国产97色在线 | 日韩 | 超碰97观看| 日韩av高清在线播放 | 亚洲国产精品无码久久 | 亚洲一区二区蜜桃 | 中文字幕成人在线视频 | 欧美啪啪一区 | 欧美区一区二 | 日本中文字幕免费观看 | 91热爆视频| 男人爆操女人 | 国产精品一区av | 古装做爰无遮挡三级聊斋艳谭 | 国产男女在线 | 午夜在线观看av | 高潮白浆女日韩av免费看 | 无码乱人伦一区二区亚洲 | 日韩经典在线观看 | 综合久久网| 新婚之夜玷污岳丰满少妇在线观看 | 农村一级毛片 | 国语一区二区 | 国产又大又黄视频 | 国产美女视频91 | 久久久亚洲av波多野结衣 | 麻豆视频免费在线观看 | 成人免费性生活视频 | 成人依依 | 国产妇女乱一性一交 | 清草视频| 无码熟妇人妻av | xx69欧美 | 欧美××××黑人××性爽 | 亚洲天堂网一区二区 | 成人18在线 | 美女视频黄是免费 | 天堂在线中文字幕 | 久久爱99 | 午夜爱爱免费视频 | 午夜激情影视 |