From f6a341e79fd666ed4450bf1138a84b84a185cd6e Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Mon, 3 Feb 2014 09:58:33 -0800 Subject: [PATCH] Don't consider sources as Initializer or Listener Update SpringApplication so that source objects are no longer considered as ApplicationListeners or ApplicationContextInitializer. --- .../boot/SpringApplication.java | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index e5f8eab4a3f..965b5ed7487 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -304,9 +304,6 @@ public class SpringApplication { ApplicationEventMulticaster multicaster = createApplicationEventMulticaster(); try { - Set sources = getSources(); - registerListenerAndInitializerSources(multicaster, sources); - // Allow logging and stuff to initialize very early multicaster.multicastEvent(new ApplicationStartedEvent(this, args)); @@ -319,17 +316,14 @@ public class SpringApplication { multicaster.multicastEvent(new ApplicationEnvironmentPreparedEvent(this, args, environment)); - // Sources might have changed when environment was applied - sources = getSources(); + // Load the sources (might have changed when environment was applied) + Set sources = getSources(); Assert.notEmpty(sources, "Sources must not be empty"); if (this.showBanner) { printBanner(); } - // Some sources might be listeners - registerListenerAndInitializerSources(multicaster, sources); - // Create, load, refresh and run the ApplicationContext context = createApplicationContext(); registerApplicationEventMulticaster(context, multicaster); @@ -391,18 +385,6 @@ public class SpringApplication { } } - private void registerListenerAndInitializerSources( - ApplicationEventMulticaster multicaster, Set sources) { - for (Object object : sources) { - if (object instanceof ApplicationListener) { - multicaster.addApplicationListener((ApplicationListener) object); - } - if (object instanceof ApplicationContextInitializer) { - addInitializers((ApplicationContextInitializer) object); - } - } - } - private void registerApplicationEventMulticaster( ConfigurableApplicationContext context, ApplicationEventMulticaster multicaster) {