Spring源碼分析-IOC之HierarchicalBeanFactory

HierarchicalBeanFactory繼承自BeanFactory,也就是在BeanFactory定義的功能基礎上增加了對parentFactory的支持,這裏只提供父容器的訪問功能,至於父容器的設置在ConfigurableBeanFactory中設置,ConfigurableBeanFactory繼承了HierarchicalBeanFactory,具體代碼如下:

/**
 * 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
 */
//註釋中已經說明setParentBeanFactory方法在ConfigurableBeanFactory中
public interface HierarchicalBeanFactory extends BeanFactory {

	//返回一個父類日期如果不存在的話返回null
	BeanFactory getParentBeanFactory();

	//判斷本地工廠容器中是否存在指定的bean
	boolean containsLocalBean(String name);

}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章