diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationReportLoggingInitializer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationReportLoggingInitializer.java
index e261f2df2c..6ca81f8512 100644
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationReportLoggingInitializer.java
+++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationReportLoggingInitializer.java
@@ -36,10 +36,9 @@ import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
- * {@link ApplicationContextInitializer} and {@link SmartApplicationListener} that writes
- * the {@link AutoConfigurationReport} to the log. Reports are logged at the
- * {@link LogLevel#DEBUG DEBUG} level unless there was a problem, in which case they are
- * the {@link LogLevel#INFO INFO} level is used.
+ * {@link ApplicationContextInitializer} that writes the {@link AutoConfigurationReport}
+ * to the log. Reports are logged at the {@link LogLevel#DEBUG DEBUG} level unless there
+ * was a problem, in which case they are the {@link LogLevel#INFO INFO} level is used.
*
* This initializer is not intended to be shared across multiple application context
* instances.
@@ -49,8 +48,7 @@ import org.springframework.util.StringUtils;
* @author Phillip Webb
*/
public class AutoConfigurationReportLoggingInitializer implements
- ApplicationContextInitializer,
- SmartApplicationListener {
+ ApplicationContextInitializer {
private final Log logger = LogFactory.getLog(getClass());
@@ -58,14 +56,10 @@ public class AutoConfigurationReportLoggingInitializer implements
private AutoConfigurationReport report;
- @Override
- public int getOrder() {
- return Ordered.LOWEST_PRECEDENCE;
- }
-
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
this.applicationContext = applicationContext;
+ applicationContext.addApplicationListener(new AutoConfigurationReportListener());
if (applicationContext instanceof GenericApplicationContext) {
// Get the report early in case the context fails to load
this.report = AutoConfigurationReport.get(this.applicationContext
@@ -73,26 +67,14 @@ public class AutoConfigurationReportLoggingInitializer implements
}
}
- @Override
- public boolean supportsEventType(Class extends ApplicationEvent> type) {
- return ContextRefreshedEvent.class.isAssignableFrom(type)
- || ApplicationFailedEvent.class.isAssignableFrom(type);
- }
-
- @Override
- public boolean supportsSourceType(Class> sourceType) {
- return true;
- }
-
- @Override
- public void onApplicationEvent(ApplicationEvent event) {
+ protected void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ContextRefreshedEvent) {
- if (((ApplicationContextEvent) event).getApplicationContext() == this.applicationContext) {
+ if (((ApplicationContextEvent) event).getApplicationContext() == AutoConfigurationReportLoggingInitializer.this.applicationContext) {
logAutoConfigurationReport();
}
}
else if (event instanceof ApplicationFailedEvent) {
- if (((ApplicationFailedEvent) event).getApplicationContext() == this.applicationContext) {
+ if (((ApplicationFailedEvent) event).getApplicationContext() == AutoConfigurationReportLoggingInitializer.this.applicationContext) {
logAutoConfigurationReport(true);
}
}
@@ -171,4 +153,27 @@ public class AutoConfigurationReportLoggingInitializer implements
}
+ private class AutoConfigurationReportListener implements SmartApplicationListener {
+
+ @Override
+ public int getOrder() {
+ return Ordered.LOWEST_PRECEDENCE;
+ }
+
+ @Override
+ public boolean supportsEventType(Class extends ApplicationEvent> type) {
+ return ContextRefreshedEvent.class.isAssignableFrom(type)
+ || ApplicationFailedEvent.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public boolean supportsSourceType(Class> sourceType) {
+ return true;
+ }
+
+ @Override
+ public void onApplicationEvent(ApplicationEvent event) {
+ AutoConfigurationReportLoggingInitializer.this.onApplicationEvent(event);
+ }
+ }
}
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java
index d96a874247..d30f1b7e11 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/SecurityAutoConfigurationTests.java
@@ -29,7 +29,6 @@ import org.springframework.boot.event.ApplicationPreparedEvent;
import org.springframework.boot.test.EnvironmentTestUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.mock.web.MockServletContext;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.security.authentication.AuthenticationManager;
@@ -124,7 +123,6 @@ public class SecurityAutoConfigurationTests {
AutoConfigurationReportLoggingInitializer initializer = new AutoConfigurationReportLoggingInitializer();
initializer.initialize(context);
context.refresh();
- initializer.onApplicationEvent(new ContextRefreshedEvent(context));
return context;
}
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 9736f2c30b..0be2509be4 100644
--- a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
+++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java
@@ -139,7 +139,6 @@ import org.springframework.web.context.support.StandardServletEnvironment;
*
{@link CharSequence} - A class name, resource handle or package name to loaded as
* appropriate. If the {@link CharSequence} cannot be resolved to class and does not
* resolve to a {@link Resource} that exists it will be considered a {@link Package}.