前言-阅读源码有利于陶冶情操,本文承接前文Spring源码情操陶冶-AbstractApplicationContext
约束:
- 本文指定
contextClass
为默认的XmlWebApplicationContext
- 从属
AbstractApplicationContext#refresh
方法
AbstractApplicationContext#prepareRefresh
代码清单如下
protected void prepareRefresh() {
//设置刷新开始时间
this.startupDate = System.currentTimeMillis();
//设置ApplicationContext的激活状态为true
synchronized (this.activeMonitor) {
this.active = true;
}
if (logger.isInfoEnabled()) {
logger.info("Refreshing " + this);
}
// Initialize any placeholder property sources in the context environment
initPropertySources();
// Validate that all properties marked as required are resolvable
// see ConfigurablePropertyResolver#setRequiredProperties
getEnvironment().validateRequiredProperties();
}
如官方注释所示,上述预刷新方法主要是设置refresh操作的起始时间、active=true、并且初始化属性资源的校验(此处可忽略,无任何操作)
下节预告
Spring源码情操陶冶-AbstractApplicationContext#obtainFreshBeanFactory