AbstractRefreshableConfigApplicationContext源码解析

1. 整体认识

AbstractRefreshableApplicationContext子类,用于添加对指定配置位置的通用处理。直白一点就是加载容器刷新是的配置文件的通用操作。

至于加载配置文件的通用操作,看下图,该类的两个子类,都是基于xml配置文件,将会有各自的定制的读取配置文件操作,所以该类提供的是读取配置文件通用操作,提供拓展点。
在这里插入图片描述
该类继承了AbstractRefreshableApplicationContext和实现了BeanNameAware和InitializingBean接口。
来了解一下这两个接口:

1.1 BeanNameAware

在bean工厂中通过bean名称知道bean

public interface BeanNameAware extends Aware {
   

	/**
	 * 在创建此bean的bean工厂中设置bean的名称
	 */
	void setBeanName(String name);
}

1.2 InitializingBean

由Bean实现的接口,需要在BeanFactory设置BeanFactory所有属性后作出反应的bean

public interface InitializingBean {
   

	/**
	 * Invoked by the containing {@code BeanFactory} after it has set all bean properties
	 * and satisfied {@link BeanFactoryAware}, {@code ApplicationContextAware} etc.
	 * <p>This method allows the bean instance to perform validation of its overall
	 * configuration and final initialization when all bean properties have been set.
	 * @throws Exception in the event of misconfiguration (such as failure to set an
	 * essential property) or if initialization fails for any other reason
	 * ~~~~~~~~~~~~~~~~~~~~~~
	 * 在包含BeanFactory设置了所有bean属性并满足BeanFactoryAware ,ApplicationContextAware等
	 * 之后调用。
	 * 设置所有bean属性后,此方法允许bean实例执行其整体配置的验证和最终初始化
	 * ~~~~~~~~~~~~~~~~~~~~~~
	 */
	void afterPropertiesSet() throws Exception;

}

2. 具体认识

2.1 属性

@Nullable
	// 配置文件路径集合
	private String[
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值