|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2017 the original author or authors. |
| 2 | + * Copyright 2002-2018 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.
|
|
24 | 24 |
|
25 | 25 | /**
|
26 | 26 | * Extended variant of the standard {@link ApplicationListener} interface,
|
27 |
| - * exposing further metadata such as the supported event type. |
| 27 | + * exposing further metadata such as the supported event and source type. |
28 | 28 | *
|
29 |
| - * <p>As of Spring Framework 4.2, supersedes {@link SmartApplicationListener} with |
30 |
| - * proper handling of generics-based event. |
| 29 | + * <p>As of Spring Framework 4.2, this interface supersedes the Class-based |
| 30 | + * {@link SmartApplicationListener} with full handling of generic event types. |
31 | 31 | *
|
32 | 32 | * @author Stephane Nicoll
|
33 | 33 | * @since 4.2
|
| 34 | + * @see SmartApplicationListener |
| 35 | + * @see GenericApplicationListenerAdapter |
34 | 36 | */
|
35 | 37 | public interface GenericApplicationListener extends ApplicationListener<ApplicationEvent>, Ordered {
|
36 | 38 |
|
37 | 39 | /**
|
38 | 40 | * Determine whether this listener actually supports the given event type.
|
| 41 | + * @param eventType the event type (never {@code null}) |
39 | 42 | */
|
40 | 43 | boolean supportsEventType(ResolvableType eventType);
|
41 | 44 |
|
42 | 45 | /**
|
43 | 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 |
44 | 49 | */
|
45 |
| - boolean supportsSourceType(@Nullable Class<?> sourceType); |
| 50 | + default boolean supportsSourceType(@Nullable Class<?> sourceType) { |
| 51 | + return true; |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * Determine this listener's order in a set of listeners for the same event. |
| 56 | + * <p>The default implementation returns {@link #LOWEST_PRECEDENCE}. |
| 57 | + */ |
| 58 | + @Override |
| 59 | + default int getOrder() { |
| 60 | + return LOWEST_PRECEDENCE; |
| 61 | + } |
46 | 62 |
|
47 | 63 | }
|
0 commit comments