Example usage for org.springframework.beans.factory.config BeanDefinition getScope

List of usage examples for org.springframework.beans.factory.config BeanDefinition getScope

Introduction

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

Prototype

@Nullable
String getScope();

Source Link

Document

Return the name of the current target scope for this bean, or null if not known yet.

Usage

From source file:org.springframework.cloud.context.scope.GenericScope.java

public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {

    beanFactory.registerScope(name, this);
    setSerializationId(beanFactory);// ww w.java 2 s .  co m

    this.beanFactory = beanFactory;

    evaluationContext = new StandardEvaluationContext();
    evaluationContext.addPropertyAccessor(new BeanFactoryAccessor());

    if (!autoProxy) {
        // No need to try and create proxies
        return;
    }

    Assert.state(beanFactory instanceof BeanDefinitionRegistry,
            "BeanFactory was not a BeanDefinitionRegistry, so RefreshScope cannot be used.");
    BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;

    for (String beanName : beanFactory.getBeanDefinitionNames()) {
        BeanDefinition definition = beanFactory.getBeanDefinition(beanName);
        // Replace this or any of its inner beans with scoped proxy if it
        // has this scope
        boolean scoped = name.equals(definition.getScope());
        Scopifier scopifier = new Scopifier(registry, name, proxyTargetClass, scoped);
        scopifier.visitBeanDefinition(definition);
        if (scoped) {
            createScopedProxy(beanName, definition, registry, proxyTargetClass);
        }
    }

}