Example usage for org.springframework.beans.factory.support RootBeanDefinition isLazyInit

List of usage examples for org.springframework.beans.factory.support RootBeanDefinition isLazyInit

Introduction

In this page you can find the example usage for org.springframework.beans.factory.support RootBeanDefinition isLazyInit.

Prototype

@Override
public boolean isLazyInit() 

Source Link

Document

Return whether this bean should be lazily initialized, i.e.

Usage

From source file:org.sakaiproject.util.NoisierDefaultListableBeanFactory.java

public void preInstantiateSingletons() throws BeansException {
    if (logger.isDebugEnabled()) {
        logger.debug("Pre-instantiating singletons in factory [" + this + "]");
    }/*from  w w  w .  java  2  s.c  om*/

    // The superclass's variable by this name is declared private.
    String[] beanDefinitionNames = getBeanDefinitionNames();
    String beanName = null; // Remember in case of an exception
    try {
        //         for (Iterator it = this.beanDefinitionNames.iterator(); it.hasNext();) {
        for (int i = 0; i < beanDefinitionNames.length; i++) {
            beanName = beanDefinitionNames[i];
            if (!containsSingleton(beanName) && containsBeanDefinition(beanName)) {
                RootBeanDefinition bd = getMergedBeanDefinition(beanName, false);
                if (!bd.isAbstract() && bd.isSingleton() && !bd.isLazyInit()) {
                    if (bd.hasBeanClass() && FactoryBean.class.isAssignableFrom(bd.getBeanClass())) {
                        FactoryBean factory = (FactoryBean) getBean(FACTORY_BEAN_PREFIX + beanName);
                        if (factory.isSingleton()) {
                            getBean(beanName);
                        }
                    } else {
                        getBean(beanName);
                    }
                }
            }
        }
    } catch (BeansException ex) {
        // Destroy already created singletons to avoid dangling resources.
        logger.error(
                "Failed to preinstantiate the singleton named " + beanName + ". Destroying all Spring beans.",
                ex);
        try {
            destroySingletons();
        } catch (Throwable ex2) {
            logger.error(
                    "Pre-instantiating singletons failed, " + "and couldn't destroy already created singletons",
                    ex2);
        }
        throw ex;
    }
}