Polishing

This commit is contained in:
Juergen Hoeller
2013-12-10 13:26:52 +01:00
parent d6e84631f5
commit be63c07b2e
3 changed files with 10 additions and 15 deletions

View File

@@ -743,11 +743,8 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
// Try to obtain the FactoryBean's object type without instantiating it at all.
BeanDefinition fbDef = getBeanDefinition(factoryBeanName);
if (fbDef instanceof AbstractBeanDefinition && ((AbstractBeanDefinition) fbDef).hasBeanClass()) {
Class<?> fbClass = ((AbstractBeanDefinition) fbDef).getBeanClass();
if (ClassUtils.isCglibProxyClass(fbClass)) {
// CGLIB subclass methods hide generic parameters. look at the superclass.
fbClass = fbClass.getSuperclass();
}
// CGLIB subclass methods hide generic parameters; look at the original user class.
Class<?> fbClass = ClassUtils.getUserClass(((AbstractBeanDefinition) fbDef).getBeanClass());
// Find the given factory method, taking into account that in the case of
// @Bean methods, there may be parameters present.
ReflectionUtils.doWithMethods(fbClass,
@@ -820,12 +817,11 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @return the FactoryBean instance, or {@code null} to indicate
* that we couldn't obtain a shortcut FactoryBean instance
*/
@SuppressWarnings("unchecked")
private FactoryBean<Object> getSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) {
private FactoryBean<?> getSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) {
synchronized (getSingletonMutex()) {
BeanWrapper bw = this.factoryBeanInstanceCache.get(beanName);
if (bw != null) {
return (FactoryBean<Object>) bw.getWrappedInstance();
return (FactoryBean<?>) bw.getWrappedInstance();
}
if (isSingletonCurrentlyInCreation(beanName)) {
return null;
@@ -845,7 +841,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
// Finished partial creation of this bean.
afterSingletonCreation(beanName);
}
FactoryBean<Object> fb = getFactoryBean(beanName, instance);
FactoryBean<?> fb = getFactoryBean(beanName, instance);
if (bw != null) {
this.factoryBeanInstanceCache.put(beanName, bw);
}
@@ -862,7 +858,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
* @return the FactoryBean instance, or {@code null} to indicate
* that we couldn't obtain a shortcut FactoryBean instance
*/
private FactoryBean<Object> getNonSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) {
private FactoryBean<?> getNonSingletonFactoryBeanForTypeCheck(String beanName, RootBeanDefinition mbd) {
if (isPrototypeCurrentlyInCreation(beanName)) {
return null;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -192,13 +192,12 @@ public abstract class FactoryBeanRegistrySupport extends DefaultSingletonBeanReg
* @return the bean instance as FactoryBean
* @throws BeansException if the given bean cannot be exposed as a FactoryBean
*/
@SuppressWarnings("unchecked")
protected FactoryBean<Object> getFactoryBean(String beanName, Object beanInstance) throws BeansException {
protected FactoryBean<?> getFactoryBean(String beanName, Object beanInstance) throws BeansException {
if (!(beanInstance instanceof FactoryBean)) {
throw new BeanCreationException(beanName,
"Bean instance of type [" + beanInstance.getClass() + "] is not a FactoryBean");
}
return (FactoryBean<Object>) beanInstance;
return (FactoryBean<?>) beanInstance;
}
/**