Spring - IoC 源码分析:AbstractApplicationContext - prepareRefresh()

in TCEHJava with 0 comment
    protected void prepareRefresh() {
        // 记录启动时间
        // Switch to active.
        this.startupDate = System.currentTimeMillis();
        this.closed.set(false);
        // 设置活动标识
        this.active.set(true);

        if (logger.isDebugEnabled()) {
            if (logger.isTraceEnabled()) {
                logger.trace("Refreshing " + this);
            }
            else {
                logger.debug("Refreshing " + getDisplayName());
            }
        }
        // 初始化上下文环境中的占位属性源。
        // Initialize any placeholder property sources in the context environment.
        initPropertySources();

        // Validate that all properties marked as required are resolvable:
        // see ConfigurablePropertyResolver#setRequiredProperties
        // 验证所有按要求标记的属性是否可解析
        getEnvironment().validateRequiredProperties();

        // 存储预刷新应用程序监听器
        // Store pre-refresh ApplicationListeners...
        if (this.earlyApplicationListeners == null) {
            this.earlyApplicationListeners = new LinkedHashSet<>(this.applicationListeners);
        }
        else {
            // Reset local application listeners to pre-refresh state.
            // 将本地应用程序监听器重置为预刷新状态
            this.applicationListeners.clear();
            this.applicationListeners.addAll(this.earlyApplicationListeners);
        }

        // Allow for the collection of early ApplicationEvents,
        // to be published once the multicaster is available...
        // 允许收集早期应用程序事件,后续事件多播器可发布事件
        this.earlyApplicationEvents = new LinkedHashSet<>();
    }