HierarchicalBeanFactory接口解读

HierarchicalBeanFactory接口解读

HierarchicalBeanFactory介绍

HierarchicalBeanFactory是BeanFactory接口的子接口,也是BeanFactory三大直系接口之一,主要是为了实现了Bean工厂的分层。

HierarchicalBeanFactory源码

HierarchicalBeanFactory十分简单,就是在BeanFactory的基础上加了父容器的访问功能,可通过 ConfigurableBeanFactory 的 setParentBeanFactory 方法设置父容器,主要是为了实现了Bean工厂的分层。

public interface HierarchicalBeanFactory extends BeanFactory {

	/**
	 * Return the parent bean factory, or {@code null} if there is none.
	 */
	@Nullable
	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
	 */
	boolean containsLocalBean(String name);

}
ainsLocalBean(String name);

}
posted @   鸭梨的药丸哥  阅读(41)  评论(0编辑  收藏  举报  
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示