Lookup methods work on configuration classes as well

Issue: SPR-15316
This commit is contained in:
Juergen Hoeller
2017-03-07 13:51:43 +01:00
parent 8b741508a6
commit fc2e635c05
2 changed files with 24 additions and 3 deletions

View File

@@ -270,13 +270,13 @@ class ConfigurationClassEnhancer {
@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
Field field = obj.getClass().getDeclaredField(BEAN_FACTORY_FIELD);
Field field = ReflectionUtils.findField(obj.getClass(), BEAN_FACTORY_FIELD);
Assert.state(field != null, "Unable to find generated BeanFactory field");
field.set(obj, args[0]);
// Does the actual (non-CGLIB) superclass actually implement BeanFactoryAware?
// Does the actual (non-CGLIB) superclass implement BeanFactoryAware?
// If so, call its setBeanFactory() method. If not, just exit.
if (BeanFactoryAware.class.isAssignableFrom(obj.getClass().getSuperclass())) {
if (BeanFactoryAware.class.isAssignableFrom(ClassUtils.getUserClass(obj.getClass().getSuperclass()))) {
return proxy.invokeSuper(obj, args);
}
return null;