Introspect FactoryBean class declaration if no early instantiation possible

Issue: SPR-15125
(cherry picked from commit 32fc855)
This commit is contained in:
Juergen Hoeller
2017-01-16 12:00:38 +01:00
parent cce84711c6
commit 24ebd15f9c
2 changed files with 73 additions and 25 deletions

View File

@@ -2231,7 +2231,7 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertNotNull(bf.getBean("annotatedBean"));
}
@Test @Ignore // SPR-15125
@Test // SPR-15125
public void testFactoryBeanSelfInjection() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@@ -2243,6 +2243,20 @@ public class AutowiredAnnotationBeanPostProcessorTests {
assertSame(bf.getBean("annotatedBean"), bean.testBean);
}
@Test // SPR-15125
public void testFactoryBeanSelfInjectionViaFactoryMethod() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
bpp.setBeanFactory(bf);
bf.addBeanPostProcessor(bpp);
RootBeanDefinition bd = new RootBeanDefinition(SelfInjectingFactoryBean.class);
bd.setFactoryMethodName("create");
bf.registerBeanDefinition("annotatedBean", bd);
SelfInjectingFactoryBean bean = bf.getBean(SelfInjectingFactoryBean.class);
assertSame(bf.getBean("annotatedBean"), bean.testBean);
}
@Qualifier("integerRepo")
private Repository<?> integerRepositoryQualifierProvider;
@@ -3570,6 +3584,10 @@ public class AutowiredAnnotationBeanPostProcessorTests {
public boolean isSingleton() {
return true;
}
public static SelfInjectingFactoryBean create() {
return new SelfInjectingFactoryBean();
}
}
}