|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2018 the original author or authors. |
| 2 | + * Copyright 2002-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
18 | 18 |
|
19 | 19 | import org.springframework.context.ApplicationEvent;
|
20 | 20 | import org.springframework.context.ApplicationListener;
|
21 |
| -import org.springframework.core.Ordered; |
22 | 21 | import org.springframework.core.ResolvableType;
|
23 |
| -import org.springframework.lang.Nullable; |
24 | 22 |
|
25 | 23 | /**
|
26 | 24 | * Extended variant of the standard {@link ApplicationListener} interface,
|
27 | 25 | * exposing further metadata such as the supported event and source type.
|
28 | 26 | *
|
29 | 27 | * <p>As of Spring Framework 4.2, this interface supersedes the Class-based
|
30 | 28 | * {@link SmartApplicationListener} with full handling of generic event types.
|
| 29 | + * As of 5.3.5, it formally extends {@link SmartApplicationListener}, adapting |
| 30 | + * {@link #supportsEventType(Class)} to {@link #supportsEventType(ResolvableType)} |
| 31 | + * with a default method. |
31 | 32 | *
|
32 | 33 | * @author Stephane Nicoll
|
| 34 | + * @author Juergen Hoeller |
33 | 35 | * @since 4.2
|
34 | 36 | * @see SmartApplicationListener
|
35 | 37 | * @see GenericApplicationListenerAdapter
|
36 | 38 | */
|
37 |
| -public interface GenericApplicationListener extends ApplicationListener<ApplicationEvent>, Ordered { |
| 39 | +public interface GenericApplicationListener extends SmartApplicationListener { |
38 | 40 |
|
39 | 41 | /**
|
40 |
| - * Determine whether this listener actually supports the given event type. |
41 |
| - * @param eventType the event type (never {@code null}) |
42 |
| - */ |
43 |
| - boolean supportsEventType(ResolvableType eventType); |
44 |
| - |
45 |
| - /** |
46 |
| - * Determine whether this listener actually supports the given source type. |
47 |
| - * <p>The default implementation always returns {@code true}. |
48 |
| - * @param sourceType the source type, or {@code null} if no source |
| 42 | + * Overrides {@link SmartApplicationListener#supportsEventType(Class)} with |
| 43 | + * delegation to {@link #supportsEventType(ResolvableType)}. |
49 | 44 | */
|
50 |
| - default boolean supportsSourceType(@Nullable Class<?> sourceType) { |
51 |
| - return true; |
| 45 | + @Override |
| 46 | + default boolean supportsEventType(Class<? extends ApplicationEvent> eventType) { |
| 47 | + return supportsEventType(ResolvableType.forClass(eventType)); |
52 | 48 | }
|
53 | 49 |
|
54 | 50 | /**
|
55 |
| - * Determine this listener's order in a set of listeners for the same event. |
56 |
| - * <p>The default implementation returns {@link #LOWEST_PRECEDENCE}. |
| 51 | + * Determine whether this listener actually supports the given event type. |
| 52 | + * @param eventType the event type (never {@code null}) |
57 | 53 | */
|
58 |
| - @Override |
59 |
| - default int getOrder() { |
60 |
| - return LOWEST_PRECEDENCE; |
61 |
| - } |
| 54 | + boolean supportsEventType(ResolvableType eventType); |
62 | 55 |
|
63 | 56 | }
|
0 commit comments