Introspect FactoryBean class declaration if no early instantiation possible
Issue: SPR-15125
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user