Example usage for org.springframework.beans.factory.config ConfigurableListableBeanFactory freezeConfiguration

List of usage examples for org.springframework.beans.factory.config ConfigurableListableBeanFactory freezeConfiguration

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config ConfigurableListableBeanFactory freezeConfiguration.

Prototype

void freezeConfiguration();

Source Link

Document

Freeze all bean definitions, signalling that the registered bean definitions will not be modified or post-processed any further.

Usage

From source file:org.springframework.context.support.AbstractApplicationContext.java

/**
 * Finish the initialization of this context's bean factory,
 * initializing all remaining singleton beans.
 *//*w w  w  .ja  va  2 s . c om*/
protected void finishBeanFactoryInitialization(ConfigurableListableBeanFactory beanFactory) {
    // Initialize conversion service for this context.
    if (beanFactory.containsBean(CONVERSION_SERVICE_BEAN_NAME)
            && beanFactory.isTypeMatch(CONVERSION_SERVICE_BEAN_NAME, ConversionService.class)) {
        beanFactory.setConversionService(
                beanFactory.getBean(CONVERSION_SERVICE_BEAN_NAME, ConversionService.class));
    }

    // Register a default embedded value resolver if no bean post-processor
    // (such as a PropertyPlaceholderConfigurer bean) registered any before:
    // at this point, primarily for resolution in annotation attribute values.
    if (!beanFactory.hasEmbeddedValueResolver()) {
        beanFactory.addEmbeddedValueResolver(strVal -> getEnvironment().resolvePlaceholders(strVal));
    }

    // Initialize LoadTimeWeaverAware beans early to allow for registering their transformers early.
    String[] weaverAwareNames = beanFactory.getBeanNamesForType(LoadTimeWeaverAware.class, false, false);
    for (String weaverAwareName : weaverAwareNames) {
        getBean(weaverAwareName);
    }

    // Stop using the temporary ClassLoader for type matching.
    beanFactory.setTempClassLoader(null);

    // Allow for caching all bean definition metadata, not expecting further changes.
    beanFactory.freezeConfiguration();

    // Instantiate all remaining (non-lazy-init) singletons.
    beanFactory.preInstantiateSingletons();
}