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);

}

猜你喜欢

转载自blog.csdn.net/cgsyck/article/details/88554535