Example usage for org.springframework.context.support DefaultLifecycleProcessor DefaultLifecycleProcessor

List of usage examples for org.springframework.context.support DefaultLifecycleProcessor DefaultLifecycleProcessor

Introduction

In this page you can find the example usage for org.springframework.context.support DefaultLifecycleProcessor DefaultLifecycleProcessor.

Prototype

DefaultLifecycleProcessor

Source Link

Usage

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

/**
 * Initialize the LifecycleProcessor./*  w w w  . ja v  a2s . c o  m*/
 * Uses DefaultLifecycleProcessor if none defined in the context.
 * @see org.springframework.context.support.DefaultLifecycleProcessor
 */
protected void initLifecycleProcessor() {
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    if (beanFactory.containsLocalBean(LIFECYCLE_PROCESSOR_BEAN_NAME)) {
        this.lifecycleProcessor = beanFactory.getBean(LIFECYCLE_PROCESSOR_BEAN_NAME, LifecycleProcessor.class);
        if (logger.isDebugEnabled()) {
            logger.debug("Using LifecycleProcessor [" + this.lifecycleProcessor + "]");
        }
    } else {
        DefaultLifecycleProcessor defaultProcessor = new DefaultLifecycleProcessor();
        defaultProcessor.setBeanFactory(beanFactory);
        this.lifecycleProcessor = defaultProcessor;
        beanFactory.registerSingleton(LIFECYCLE_PROCESSOR_BEAN_NAME, this.lifecycleProcessor);
        if (logger.isDebugEnabled()) {
            logger.debug("Unable to locate LifecycleProcessor with name '" + LIFECYCLE_PROCESSOR_BEAN_NAME
                    + "': using default [" + this.lifecycleProcessor + "]");
        }
    }
}