HierarchicalBeanFactory接口
生活随笔
收集整理的這篇文章主要介紹了
HierarchicalBeanFactory接口
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
HierarchicalBeanFactory 提供父容器的訪問功能.至于父容器的設(shè)置,需要找ConfigurableBeanFactory的setParentBeanFactory(接口把設(shè)置跟獲取給拆開了!).
HierarchicalBeanFactory源碼具體:
1、第一個方法返回本Bean工廠的父工廠。這個方法實現(xiàn)了工廠的分層。
2、第二個方法判斷本地工廠是否包含這個Bean(忽略其他所有父工廠)。這也是分層思想的體現(xiàn)。
總結(jié):這個工廠接口非常簡單,實現(xiàn)了Bean工廠的分層。這個工廠接口也是繼承自BeanFacotory,也是一個二級接口,相對于父接口,它只擴展了一個重要的功能——工廠分層。
/*** Sub-interface implemented by bean factories that can be part* of a hierarchy.** <p>The corresponding {@code setParentBeanFactory} method for bean* factories that allow setting the parent in a configurable* fashion can be found in the ConfigurableBeanFactory interface.** @author Rod Johnson* @author Juergen Hoeller* @since 07.07.2003* @see org.springframework.beans.factory.config.ConfigurableBeanFactory#setParentBeanFactory*/ public interface HierarchicalBeanFactory extends BeanFactory {/*** Return the parent bean factory, or {@code null} if there is none.*/// // 返回本Bean工廠的父工廠BeanFactory getParentBeanFactory();/*** Return whether the local bean factory contains a bean of the given name,* ignoring beans defined in ancestor contexts.* <p>This is an alternative to {@code containsBean}, ignoring a bean* of the given name from an ancestor bean factory.* @param name the name of the bean to query* @return whether a bean with the given name is defined in the local factory* @see BeanFactory#containsBean*/// 本地工廠(容器)是否包含這個Beanboolean containsLocalBean(String name);}總結(jié)
以上是生活随笔為你收集整理的HierarchicalBeanFactory接口的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 不只是槓杆原理~~细说油压煞车
- 下一篇: HierarchicalBeanFact