Browse Source

Polish "Narrow the event types ConfigFileApplicationListener supports"

Closes gh-9628
pull/9654/head
Stephane Nicoll 9 years ago
parent
commit
26b27d41e7
  1. 23
      spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java

23
spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java

@ -62,7 +62,6 @@ import org.springframework.core.io.DefaultResourceLoader; @@ -62,7 +62,6 @@ import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ResourceUtils;
import org.springframework.util.StringUtils;
@ -152,6 +151,17 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor, @@ -152,6 +151,17 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
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
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ApplicationEnvironmentPreparedEvent) {
@ -277,17 +287,6 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor, @@ -277,17 +287,6 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
this.names = names;
}
@Override
public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
return ApplicationEnvironmentPreparedEvent.class.isAssignableFrom(eventType) ||
ApplicationPreparedEvent.class.isAssignableFrom(eventType);
}
@Override
public boolean supportsSourceType(@Nullable Class<?> aClass) {
return true;
}
/**
* {@link BeanFactoryPostProcessor} to re-order our property sources below any
* {@code @PropertySource} items added by the {@link ConfigurationClassPostProcessor}.

Loading…
Cancel
Save