Support for @Order on nested configuration classes

Issue: SPR-15384
This commit is contained in:
Juergen Hoeller
2017-04-04 17:17:03 +02:00
parent e9627a10c7
commit 917207b7ae
3 changed files with 79 additions and 9 deletions

View File

@@ -348,6 +348,18 @@ public class ConfigurationClassPostProcessorTests {
}
}
@Test
public void nestedConfigurationClassesProcessedInCorrectOrder() {
beanFactory.registerBeanDefinition("config", new RootBeanDefinition(ConfigWithOrderedNestedClasses.class));
ConfigurationClassPostProcessor pp = new ConfigurationClassPostProcessor();
pp.postProcessBeanFactory(beanFactory);
Foo foo = beanFactory.getBean(Foo.class);
assertTrue(foo instanceof ExtendedFoo);
Bar bar = beanFactory.getBean(Bar.class);
assertSame(foo, bar.foo);
}
@Test
public void scopedProxyTargetMarkedAsNonAutowireCandidate() {
AutowiredAnnotationBeanPostProcessor bpp = new AutowiredAnnotationBeanPostProcessor();
@@ -833,6 +845,36 @@ public class ConfigurationClassPostProcessorTests {
}
}
@Configuration
static class ConfigWithOrderedNestedClasses {
@Configuration
@Order(1)
static class SingletonBeanConfig {
public @Bean Foo foo() {
return new Foo();
}
public @Bean Bar bar() {
return new Bar(foo());
}
}
@Configuration
@Order(2)
static class OverridingSingletonBeanConfig {
public @Bean ExtendedFoo foo() {
return new ExtendedFoo();
}
public @Bean Bar bar() {
return new Bar(foo());
}
}
}
static class Foo {
}