Example usage for org.springframework.beans.factory.config RuntimeBeanReference RuntimeBeanReference

List of usage examples for org.springframework.beans.factory.config RuntimeBeanReference RuntimeBeanReference

Introduction

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

Prototype

public RuntimeBeanReference(Class<?> beanType, boolean toParent) 

Source Link

Document

Create a new RuntimeBeanReference to a bean of the given type, with the option to mark it as reference to a bean in the parent factory.

Usage

From source file:org.springframework.context.groovy.GroovyBeanDefinitionReader.java

/**
 * This method overrides property retrieval in the scope of the GroovyBeanDefinitionReader to either:
 * /*from w w  w.  j a v  a  2 s  . c  om*/
 * a) Retrieve a variable from the bean builder's binding if it exists
 * b) Retrieve a RuntimeBeanReference for a specific bean if it exists
 * c) Otherwise just delegate to super.getProperty which will resolve properties from the GroovyBeanDefinitionReader itself
 */
public Object getProperty(String name) {

    if (binding.containsKey(name)) {
        return binding.get(name);
    } else {
        if (namespaceHandlers.containsKey(name)) {
            return createDynamicElementReader(name, currentBeanConfig != null);

        }
        if (springConfig.containsBean(name)) {
            BeanConfiguration beanConfig = springConfig.getBeanConfig(name);
            if (beanConfig != null) {
                return new ConfigurableRuntimeBeanReference(name, springConfig.getBeanConfig(name), false);
            } else
                return new RuntimeBeanReference(name, false);
        }
        // this is to deal with the case where the property setter is the last
        // statement in a closure (hence the return value)
        else if (currentBeanConfig != null) {
            if (currentBeanConfig.hasProperty(name))
                return currentBeanConfig.getPropertyValue(name);
            else {
                DeferredProperty dp = deferredProperties.get(currentBeanConfig.getName() + name);
                if (dp != null) {
                    return dp.value;
                } else {
                    return super.getProperty(name);
                }
            }
        } else {
            return super.getProperty(name);
        }
    }
}