Introspect FactoryBean class declaration if no early instantiation possible

Issue: SPR-15125
This commit is contained in:
Juergen Hoeller
2017-01-16 12:00:38 +01:00
parent e88e8f1d09
commit 32fc855dd1
2 changed files with 73 additions and 25 deletions

View File

@@ -2237,7 +2237,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();
@@ -2249,6 +2249,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;
@@ -3586,6 +3600,10 @@ public class AutowiredAnnotationBeanPostProcessorTests {
public boolean isSingleton() {
return true;
}
public static SelfInjectingFactoryBean create() {
return new SelfInjectingFactoryBean();
}
}
}