|
|
|
@ -167,7 +167,7 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
|
|
|
|
|
String factoryName = BeanFactory.FACTORY_BEAN_PREFIX + name;
|
|
|
|
|
if (this.beanFactory.isFactoryBean(factoryName)) {
|
|
|
|
|
Class<?> factoryBeanGeneric = getFactoryBeanGeneric(this.beanFactory,
|
|
|
|
|
beanDefinition, name);
|
|
|
|
|
beanDefinition);
|
|
|
|
|
this.beanTypes.put(name, factoryBeanGeneric);
|
|
|
|
|
this.beanTypes.put(factoryName,
|
|
|
|
|
this.beanFactory.getType(factoryName));
|
|
|
|
@ -216,13 +216,12 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
|
|
|
|
|
* generics in its method signature.
|
|
|
|
|
* @param beanFactory the source bean factory
|
|
|
|
|
* @param definition the bean definition
|
|
|
|
|
* @param name the name of the bean
|
|
|
|
|
* @return the generic type of the {@link FactoryBean} or {@code null}
|
|
|
|
|
*/
|
|
|
|
|
private Class<?> getFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory,
|
|
|
|
|
BeanDefinition definition, String name) {
|
|
|
|
|
BeanDefinition definition) {
|
|
|
|
|
try {
|
|
|
|
|
return doGetFactoryBeanGeneric(beanFactory, definition, name);
|
|
|
|
|
return doGetFactoryBeanGeneric(beanFactory, definition);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) {
|
|
|
|
|
return null;
|
|
|
|
@ -230,11 +229,11 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Class<?> doGetFactoryBeanGeneric(ConfigurableListableBeanFactory beanFactory,
|
|
|
|
|
BeanDefinition definition, String name)
|
|
|
|
|
BeanDefinition definition)
|
|
|
|
|
throws Exception, ClassNotFoundException, LinkageError {
|
|
|
|
|
if (StringUtils.hasLength(definition.getFactoryBeanName())
|
|
|
|
|
&& StringUtils.hasLength(definition.getFactoryMethodName())) {
|
|
|
|
|
return getConfigurationClassFactoryBeanGeneric(beanFactory, definition, name);
|
|
|
|
|
return getConfigurationClassFactoryBeanGeneric(beanFactory, definition);
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.hasLength(definition.getBeanClassName())) {
|
|
|
|
|
return getDirectFactoryBeanGeneric(beanFactory, definition);
|
|
|
|
@ -243,8 +242,8 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Class<?> getConfigurationClassFactoryBeanGeneric(
|
|
|
|
|
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition,
|
|
|
|
|
String name) throws Exception {
|
|
|
|
|
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition)
|
|
|
|
|
throws Exception {
|
|
|
|
|
Method method = getFactoryMethod(beanFactory, definition);
|
|
|
|
|
Class<?> generic = ResolvableType.forMethodReturnType(method)
|
|
|
|
|
.as(FactoryBean.class).resolveGeneric();
|
|
|
|
@ -305,8 +304,8 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Class<?> getDirectFactoryBeanGeneric(
|
|
|
|
|
ConfigurableListableBeanFactory beanFactory,
|
|
|
|
|
BeanDefinition definition) throws ClassNotFoundException, LinkageError {
|
|
|
|
|
ConfigurableListableBeanFactory beanFactory, BeanDefinition definition)
|
|
|
|
|
throws ClassNotFoundException, LinkageError {
|
|
|
|
|
Class<?> factoryBeanClass = ClassUtils.forName(definition.getBeanClassName(),
|
|
|
|
|
beanFactory.getBeanClassLoader());
|
|
|
|
|
Class<?> generic = ResolvableType.forClass(factoryBeanClass).as(FactoryBean.class)
|
|
|
|
|