|
|
|
@ -33,11 +33,14 @@ import org.springframework.beans.factory.CannotLoadBeanClassException;
|
|
|
|
|
import org.springframework.beans.factory.FactoryBean;
|
|
|
|
|
import org.springframework.beans.factory.ListableBeanFactory;
|
|
|
|
|
import org.springframework.beans.factory.SmartInitializingSingleton;
|
|
|
|
|
import org.springframework.beans.factory.annotation.AnnotatedBeanDefinition;
|
|
|
|
|
import org.springframework.beans.factory.config.BeanDefinition;
|
|
|
|
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
|
|
|
|
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
|
|
|
|
import org.springframework.beans.factory.support.RootBeanDefinition;
|
|
|
|
|
import org.springframework.core.ResolvableType;
|
|
|
|
|
import org.springframework.core.type.MethodMetadata;
|
|
|
|
|
import org.springframework.core.type.StandardMethodMetadata;
|
|
|
|
|
import org.springframework.util.ClassUtils;
|
|
|
|
|
import org.springframework.util.ReflectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
@ -108,12 +111,7 @@ abstract class BeanTypeRegistry {
|
|
|
|
|
private Class<?> getConfigurationClassFactoryBeanGeneric(
|
|
|
|
|
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition,
|
|
|
|
|
String name) throws Exception {
|
|
|
|
|
BeanDefinition factoryDefinition = beanFactory.getBeanDefinition(definition
|
|
|
|
|
.getFactoryBeanName());
|
|
|
|
|
Class<?> factoryClass = ClassUtils.forName(factoryDefinition.getBeanClassName(),
|
|
|
|
|
beanFactory.getBeanClassLoader());
|
|
|
|
|
Method method = ReflectionUtils.findMethod(factoryClass,
|
|
|
|
|
definition.getFactoryMethodName());
|
|
|
|
|
Method method = getFactoryMethod(beanFactory, definition);
|
|
|
|
|
Class<?> generic = ResolvableType.forMethodReturnType(method)
|
|
|
|
|
.as(FactoryBean.class).resolveGeneric();
|
|
|
|
|
if ((generic == null || generic.equals(Object.class))
|
|
|
|
@ -124,6 +122,24 @@ abstract class BeanTypeRegistry {
|
|
|
|
|
return generic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Method getFactoryMethod(ConfigurableListableBeanFactory beanFactory,
|
|
|
|
|
BeanDefinition definition) throws Exception {
|
|
|
|
|
if (definition instanceof AnnotatedBeanDefinition) {
|
|
|
|
|
MethodMetadata factoryMethodMetadata = ((AnnotatedBeanDefinition) definition)
|
|
|
|
|
.getFactoryMethodMetadata();
|
|
|
|
|
if (factoryMethodMetadata instanceof StandardMethodMetadata) {
|
|
|
|
|
return ((StandardMethodMetadata) factoryMethodMetadata)
|
|
|
|
|
.getIntrospectedMethod();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
BeanDefinition factoryDefinition = beanFactory.getBeanDefinition(definition
|
|
|
|
|
.getFactoryBeanName());
|
|
|
|
|
Class<?> factoryClass = ClassUtils.forName(factoryDefinition.getBeanClassName(),
|
|
|
|
|
beanFactory.getBeanClassLoader());
|
|
|
|
|
return ReflectionUtils
|
|
|
|
|
.findMethod(factoryClass, definition.getFactoryMethodName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Class<?> getDirectFactoryBeanGeneric(
|
|
|
|
|
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition,
|
|
|
|
|
String name) throws ClassNotFoundException, LinkageError {
|
|
|
|
|