Example usage for org.springframework.beans.factory.support AbstractBeanDefinition overrideFrom

List of usage examples for org.springframework.beans.factory.support AbstractBeanDefinition overrideFrom

Introduction

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

Prototype

public void overrideFrom(BeanDefinition other) 

Source Link

Document

Override settings in this bean definition (presumably a copied parent from a parent-child inheritance relationship) from the given bean definition (presumably the child).

Usage

From source file:uk.org.ponder.rsac.support.BeanDefUtil.java

static AbstractBeanDefinition getMergedBeanDefinition(ConfigurableListableBeanFactory factory, String beanName,
        BeanDefinition bd) throws BeansException {

    if (!(bd instanceof AbstractBeanDefinition)) {
        throw new IllegalArgumentException("Bean definition " + beanName + " of " + bd.getClass()
                + " which is not descended from AbstractBeanDefinition can not be recognised");
    }/* ww w  .j  a  v a  2s . c  o m*/
    AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
    String parentName = getParentDefinitionName(abd);
    if (parentName == null) {
        return abd;
    } else {
        AbstractBeanDefinition pbd = null;
        if (!beanName.equals(parentName)) {
            pbd = getMergedBeanDefinition(factory, parentName, true);
        } else {
            if (factory.getParentBeanFactory() instanceof ConfigurableListableBeanFactory) {
                ConfigurableListableBeanFactory parentFactory = (ConfigurableListableBeanFactory) factory
                        .getParentBeanFactory();
                pbd = getMergedBeanDefinition(parentFactory, parentName, true);
            } else {
                throw new NoSuchBeanDefinitionException(parentName,
                        "Parent name '" + parentName + "' is equal to bean name '" + beanName
                                + "' - cannot be resolved without an AbstractBeanFactory parent");
            }
        }

        // deep copy with overridden values
        pbd.overrideFrom(abd);
        return pbd;
    }

}