Skip to content

Commit 41e6037

Browse files
committed
Merge pull request #9628 from satamas:master
* pr/9628: Polish "Narrow the event types ConfigFileApplicationListener supports" Narrow the event types ConfigFileApplicationListener supports
2 parents c75d78a + 26b27d4 commit 41e6037

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
import org.springframework.boot.env.PropertySourcesLoader;
4747
import org.springframework.boot.logging.DeferredLog;
4848
import org.springframework.context.ApplicationEvent;
49-
import org.springframework.context.ApplicationListener;
5049
import org.springframework.context.ConfigurableApplicationContext;
5150
import org.springframework.context.annotation.ConfigurationClassPostProcessor;
51+
import org.springframework.context.event.SmartApplicationListener;
5252
import org.springframework.core.Ordered;
5353
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
5454
import org.springframework.core.convert.ConversionService;
@@ -102,7 +102,7 @@
102102
* @author Eddú Meléndez
103103
*/
104104
public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
105-
ApplicationListener<ApplicationEvent>, Ordered {
105+
SmartApplicationListener, Ordered {
106106

107107
private static final String DEFAULT_PROPERTIES = "defaultProperties";
108108

@@ -151,6 +151,17 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
151151

152152
private final ConversionService conversionService = new DefaultConversionService();
153153

154+
@Override
155+
public boolean supportsEventType(Class<? extends ApplicationEvent> eventType) {
156+
return ApplicationEnvironmentPreparedEvent.class.isAssignableFrom(eventType) ||
157+
ApplicationPreparedEvent.class.isAssignableFrom(eventType);
158+
}
159+
160+
@Override
161+
public boolean supportsSourceType(Class<?> aClass) {
162+
return true;
163+
}
164+
154165
@Override
155166
public void onApplicationEvent(ApplicationEvent event) {
156167
if (event instanceof ApplicationEnvironmentPreparedEvent) {

0 commit comments

Comments
 (0)