Skip to content

Commit

Permalink
Narrow the event types ConfigFileApplicationListener supports
Browse files Browse the repository at this point in the history
  • Loading branch information
satamas authored and snicoll committed Jun 29, 2017
1 parent eb299b9 commit d268572
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
import org.springframework.boot.env.PropertySourcesLoader;
import org.springframework.boot.logging.DeferredLog;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ConfigurationClassPostProcessor;
import org.springframework.context.event.SmartApplicationListener;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
import org.springframework.core.convert.ConversionService;
Expand All @@ -62,6 +62,7 @@
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;
Expand Down Expand Up @@ -102,7 +103,7 @@
* @author Eddú Meléndez
*/
public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
ApplicationListener<ApplicationEvent>, Ordered {
SmartApplicationListener, Ordered {

private static final String DEFAULT_PROPERTIES = "defaultProperties";

Expand Down Expand Up @@ -276,6 +277,17 @@ public void setSearchNames(String names) {
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}.
Expand Down

0 comments on commit d268572

Please sign in to comment.