Example usage for org.springframework.beans.factory.config ConfigurableBeanFactory getRegisteredScope

List of usage examples for org.springframework.beans.factory.config ConfigurableBeanFactory getRegisteredScope

Introduction

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

Prototype

@Nullable
Scope getRegisteredScope(String scopeName);

Source Link

Document

Return the Scope implementation for the given scope name, if any.

Usage

From source file:cf.spring.CfComponentConfiguration.java

@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
    if (beanFactory instanceof ConfigurableBeanFactory) {
        final ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;
        expressionResolver = cbf.getBeanExpressionResolver();
        expressionContext = new BeanExpressionContext(cbf,
                cbf.getRegisteredScope(ConfigurableBeanFactory.SCOPE_PROTOTYPE));
    } else {/* w  w w. j av a 2s . c o  m*/
        throw new BeanCreationException(
                getClass().getName() + " can only be used with a " + ConfigurableBeanFactory.class.getName());
    }
}

From source file:cf.spring.servicebroker.ServiceBrokerConfiguration.java

@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
    if (beanFactory instanceof ConfigurableBeanFactory) {
        final ConfigurableBeanFactory cbf = (ConfigurableBeanFactory) beanFactory;
        expressionResolver = new BeanExpressionResolver() {
            @Override/*from   w w  w  . ja  v  a  2  s.c  o m*/
            public Object evaluate(String expression, BeanExpressionContext beanExpressionContext)
                    throws BeansException {
                final Object value = cbf.getBeanExpressionResolver().evaluate(expression, expressionContext);

                return value == null ? null : value.toString();
            }
        };
        expressionContext = new BeanExpressionContext(cbf,
                cbf.getRegisteredScope(ConfigurableBeanFactory.SCOPE_PROTOTYPE));
    } else {
        throw new BeanCreationException(
                getClass().getName() + " can only be used with a " + ConfigurableBeanFactory.class.getName());
    }
}