spring-framework/org.springframework.context
Chris Beams 95b1dbadb0 Register nested @Configuration classes automatically
The following is now possible:

@Configuration
public class AppConfig {
    @Inject DataSource dataSource;

    @Bean
    public MyBean myBean() {
        return new MyBean(dataSource);
    }

    @Configuration
    static class DatabaseConfig {
        @Bean
        DataSource dataSource() {
            return new EmbeddedDatabaseBuilder().build();
        }
    }
}

public static void main(String... args) {
    AnnotationConfigApplicationContext ctx =
        new AnnotationConfigApplicationContext(AppConfig.class);
    ctx.getBean(MyBean.class);     // works
    ctx.getBean(DataSource.class); // works
}

Notice that the @Import annotation was not used and that only AppConfig
was registered against the context. By virtue of the fact that
DatabaseConfig is a member class of AppConfig, it is automatically
registered when AppConfig is registered. This avoids an awkward and
redundant @Import annotation when the relationship is already implicitly
clear.

See @Configuration Javadoc for details.

Issue: SPR-8186
2011-05-21 01:20:33 +00:00
..
.settings Merge 3.1.0 development branch into trunk 2010-10-25 19:48:20 +00:00
src Register nested @Configuration classes automatically 2011-05-21 01:20:33 +00:00
.classpath moved cache abstraction from context.support to context 2011-02-07 17:41:25 +00:00
.project revised cache abstraction 2011-05-18 17:43:13 +00:00
.springBeans Remove "Feature" support introduced in 3.1 M1 2011-05-06 19:03:52 +00:00
build.xml + upgrade to AspectJ 1.6.8 2010-02-04 11:46:21 +00:00
context.iml moved cache abstraction from context.support to context 2011-02-07 17:41:25 +00:00
ivy.xml moved cache abstraction from context.support to context 2011-02-07 17:41:25 +00:00
pom.xml Sync pom.xml deps with ivy.xml changes since 3.0.5 2011-02-09 06:56:53 +00:00
template.mf SPR-6416, initial commit for the conversation management 2011-04-12 13:21:18 +00:00