整体认识
先来看一下整体架构图。
从该类的名字可以看出来,是为了容器刷新而存在的
该类名称:可刷新的ApllicationContext容器抽象类。
每次刷新容器要干的事就是重新将bean注册到容器中,至于以哪样的策略来实现bean注册,这要具体看Spring如何实现的。其子类唯一实现的方法就是loadBeanDefinitions()方法。
具体认识
1. 属性
@Nullable
// 是否允许bean定义被同名的bean定义覆盖
private Boolean allowBeanDefinitionOverriding;
// 是否允许循环引用标志位
@Nullable
private Boolean allowCircularReferences;
/** Bean factory for this context. */
// 当前容器Bean工厂
@Nullable
private volatile DefaultListableBeanFactory beanFactory;
两个标志的set方法,两个标志的默认是都是true,这里不再赘述。
/**
* Set whether it should be allowed to override bean definitions by registering
* a different definition with the same name, automatically replacing the former.
* If not, an exception will be thrown. Default is "true".
* @see org.springframework.beans.factory.support.DefaultListableBeanFactory#setAllowBeanDefinitionOverriding
*/
public void setAllowBeanDefinitionOverriding(boolean allowBeanDefinitionOverriding) {
this.allowBeanDefinitionOverriding = allowBeanDefinitionOverriding;
}
/**
* Set whether to allow circular references between beans - and automatically
* try to resolve them.
* <p>Default is "true". Turn this off to throw an exception when encountering
* a circular reference, disallowing them completely.
* @see org.springframework.beans.factory.support.DefaultListableBeanFactory#setAllowCircularReferences
*/
public void setAllowCircularReferences(boolean allowCircularReferences) {
this.allowCircularReferences = allowCircularReferences;
}