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[