Commit 41e60371 authored by Stephane Nicoll's avatar Stephane Nicoll

Merge pull request #9628 from satamas:master

* pr/9628:
  Polish "Narrow the event types ConfigFileApplicationListener supports"
  Narrow the event types ConfigFileApplicationListener supports
parents c75d78a6 26b27d41
...@@ -46,9 +46,9 @@ import org.springframework.boot.env.EnvironmentPostProcessor; ...@@ -46,9 +46,9 @@ import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.boot.env.PropertySourcesLoader; import org.springframework.boot.env.PropertySourcesLoader;
import org.springframework.boot.logging.DeferredLog; import org.springframework.boot.logging.DeferredLog;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ConfigurationClassPostProcessor; import org.springframework.context.annotation.ConfigurationClassPostProcessor;
import org.springframework.context.event.SmartApplicationListener;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.convert.ConversionService; import org.springframework.core.convert.ConversionService;
...@@ -102,7 +102,7 @@ import org.springframework.validation.BindException; ...@@ -102,7 +102,7 @@ import org.springframework.validation.BindException;
* @author Eddú Meléndez * @author Eddú Meléndez
*/ */
public class ConfigFileApplicationListener implements EnvironmentPostProcessor, public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
ApplicationListener<ApplicationEvent>, Ordered { SmartApplicationListener, Ordered {
private static final String DEFAULT_PROPERTIES = "defaultProperties"; private static final String DEFAULT_PROPERTIES = "defaultProperties";
...@@ -151,6 +151,17 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor, ...@@ -151,6 +151,17 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
private final ConversionService conversionService = new DefaultConversionService(); private final ConversionService conversionService = new DefaultConversionService();
@Override
public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
return ApplicationEnvironmentPreparedEvent.class.isAssignableFrom(eventType) ||
ApplicationPreparedEvent.class.isAssignableFrom(eventType);
}
@Override
public boolean supportsSourceType(Class<?> aClass) {
return true;
}
@Override @Override
public void onApplicationEvent(ApplicationEvent event) { public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ApplicationEnvironmentPreparedEvent) { if (event instanceof ApplicationEnvironmentPreparedEvent) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment