Merge pull request #9628 from satamas:master
* pr/9628: Polish "Narrow the event types ConfigFileApplicationListener supports" Narrow the event types ConfigFileApplicationListener supports
This commit is contained in:
commit
41e6037173
|
|
@ -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;
|
||||||
* @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,
|
||||||
|
|
||||||
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) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue