1、设置容器的启动时间: this.startupDate = System.currentTimeMillis();
2、设置活跃状态为true: this.closed.set(false);
3、设置关闭状态为false: this.active.set(true);
4、获取Environment对象,并加载当前系统的属性值到Environment对象中: getEnvironment().validateRequiredProperties();
-> this.environment = createEnvironment();
-> new StandardEnvironment();
-> public AbstractEnvironment() {
customizePropertySources(this.propertySources);
}
->
/** System environment property source name: {@value}. */
public static final String SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME = "systemEnvironment";
/** JVM system properties property source name: {@value}. */
public static final String SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME = "systemProperties";
@Override
protected void customizePropertySources(MutablePropertySources propertySources) {
propertySources.addLast(
new PropertiesPropertySource(SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, getSystemProperties()));
propertySources.addLast(
new SystemEnvironmentPropertySource(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, getSystemEnvironment()));
}
这里的getEnvironment()方法, 会将 系统环境变量 和 系统属性 提前加载保存到environment的propertySources属性中,方便之后的使用
5、留给子类覆盖,初始化属性资源: initPropertySources();标签:NAME,prepareRefresh,SYSTEM,SOURCE,详解,propertySources,new,PROPERTY,方法 From: https://www.cnblogs.com/superpiter/p/18031488
6、准备监听器和事件的集合对象,默认为空的集合: this.earlyApplicationEvents = new LinkedHashSet<>();