Example usage for org.springframework.beans.factory.annotation AnnotatedGenericBeanDefinition setLazyInit

List of usage examples for org.springframework.beans.factory.annotation AnnotatedGenericBeanDefinition setLazyInit

Introduction

In this page you can find the example usage for org.springframework.beans.factory.annotation AnnotatedGenericBeanDefinition setLazyInit.

Prototype

@Override
public void setLazyInit(boolean lazyInit) 

Source Link

Document

Set whether this bean should be lazily initialized.

Usage

From source file:br.com.caelum.vraptor.ioc.spring.SpringRegistry.java

private void registerOn(Class<?> type, boolean customComponent) {
    AnnotatedGenericBeanDefinition definition = new AnnotatedGenericBeanDefinition(type);
    if (!customComponent) {
        definition.setLazyInit(true);
    }/*w w  w.j ava 2s . c  om*/
    definition.setAutowireMode(AbstractBeanDefinition.AUTOWIRE_NO);
    definition.setPrimary(customComponent);
    definition.setRole(customComponent ? BeanDefinition.ROLE_APPLICATION : BeanDefinition.ROLE_INFRASTRUCTURE);

    String name = beanNameGenerator.generateBeanName(definition, (BeanDefinitionRegistry) beanFactory);
    BeanDefinitionHolder definitionHolder = new BeanDefinitionHolder(definition, name);

    ScopeMetadata scopeMetadata = scopeResolver.resolveScopeMetadata(definition);
    definitionHolder = applyScopeOn(definitionHolder, scopeMetadata);

    BeanDefinitionReaderUtils.registerBeanDefinition(definitionHolder, (BeanDefinitionRegistry) beanFactory);
}