Example usage for org.springframework.beans.factory.config SmartInstantiationAwareBeanPostProcessor getEarlyBeanReference

List of usage examples for org.springframework.beans.factory.config SmartInstantiationAwareBeanPostProcessor getEarlyBeanReference

Introduction

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

Prototype

default Object getEarlyBeanReference(Object bean, String beanName) throws BeansException 

Source Link

Document

Obtain a reference for early access to the specified bean, typically for the purpose of resolving a circular reference.

Usage

From source file:org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.java

/**
 * Obtain a reference for early access to the specified bean,
 * typically for the purpose of resolving a circular reference.
 * @param beanName the name of the bean (for error handling purposes)
 * @param mbd the merged bean definition for the bean
 * @param bean the raw bean instance//from www . j ava 2 s .  c om
 * @return the object to expose as bean reference
 */
protected Object getEarlyBeanReference(String beanName, RootBeanDefinition mbd, Object bean) {
    Object exposedObject = bean;
    if (!mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) {
        for (BeanPostProcessor bp : getBeanPostProcessors()) {
            if (bp instanceof SmartInstantiationAwareBeanPostProcessor) {
                SmartInstantiationAwareBeanPostProcessor ibp = (SmartInstantiationAwareBeanPostProcessor) bp;
                exposedObject = ibp.getEarlyBeanReference(exposedObject, beanName);
            }
        }
    }
    return exposedObject;
}