AbstractRefreshableApplicationContext源码解析

整体认识

在这里插入图片描述
先来看一下整体架构图。
从该类的名字可以看出来,是为了容器刷新而存在的
该类名称:可刷新的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;
	}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值