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

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

Introduction

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

Prototype

@Nullable
default Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName)
        throws BeansException 

Source Link

Document

Determine the candidate constructors to use for the given bean.

Usage

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

/**
 * Determine candidate constructors to use for the given bean, checking all registered
 * {@link SmartInstantiationAwareBeanPostProcessor SmartInstantiationAwareBeanPostProcessors}.
 * @param beanClass the raw class of the bean
 * @param beanName the name of the bean//from w w w  . java  2 s.  c o  m
 * @return the candidate constructors, or {@code null} if none specified
 * @throws org.springframework.beans.BeansException in case of errors
 * @see org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor#determineCandidateConstructors
 */
@Nullable
protected Constructor<?>[] determineConstructorsFromBeanPostProcessors(@Nullable Class<?> beanClass,
        String beanName) throws BeansException {

    if (beanClass != null && hasInstantiationAwareBeanPostProcessors()) {
        for (BeanPostProcessor bp : getBeanPostProcessors()) {
            if (bp instanceof SmartInstantiationAwareBeanPostProcessor) {
                SmartInstantiationAwareBeanPostProcessor ibp = (SmartInstantiationAwareBeanPostProcessor) bp;
                Constructor<?>[] ctors = ibp.determineCandidateConstructors(beanClass, beanName);
                if (ctors != null) {
                    return ctors;
                }
            }
        }
    }
    return null;
}