Reverted enhanceFactoryBean revision in 4.1.x (making it 4.2 only)

Issue: SPR-12915
Issue: SPR-13095
This commit is contained in:
Juergen Hoeller
2015-06-11 17:53:26 +02:00
parent 3227007816
commit 063a720ac0
2 changed files with 4 additions and 32 deletions

View File

@@ -289,7 +289,7 @@ class ConfigurationClassEnhancer {
}
else {
// It is a candidate FactoryBean - go ahead with enhancement
return enhanceFactoryBean(factoryBean, beanFactory, beanName);
return enhanceFactoryBean(factoryBean.getClass(), beanFactory, beanName);
}
}
@@ -365,11 +365,11 @@ class ConfigurationClassEnhancer {
* instance directly. If a FactoryBean instance is fetched through the container via &-dereferencing,
* it will not be proxied. This too is aligned with the way XML configuration works.
*/
private Object enhanceFactoryBean(final Object factoryBean, final ConfigurableBeanFactory beanFactory,
private Object enhanceFactoryBean(Class<?> fbClass, final ConfigurableBeanFactory beanFactory,
final String beanName) throws InstantiationException, IllegalAccessException {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(factoryBean.getClass());
enhancer.setSuperclass(fbClass);
enhancer.setUseFactory(false);
enhancer.setNamingPolicy(SpringNamingPolicy.INSTANCE);
enhancer.setCallback(new MethodInterceptor() {
@@ -378,7 +378,7 @@ class ConfigurationClassEnhancer {
if (method.getName().equals("getObject") && args.length == 0) {
return beanFactory.getBean(beanName);
}
return proxy.invoke(factoryBean, args);
return proxy.invokeSuper(obj, args);
}
});
return enhancer.create();