public class GenericApplicationListenerAdapter extends java.lang.Object implements GenericApplicationListener, SmartApplicationListener
GenericApplicationListener
adapter that determines supported event types
through introspecting the generically declared type of the target listener.ApplicationListener.onApplicationEvent(E)
Modifier and Type | Field and Description |
---|---|
private ResolvableType |
declaredEventType |
private ApplicationListener<ApplicationEvent> |
delegate |
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
GenericApplicationListenerAdapter(ApplicationListener<?> delegate)
Create a new GenericApplicationListener for the given delegate.
|
Modifier and Type | Method and Description |
---|---|
int |
getOrder()
Get the order value of this object.
|
void |
onApplicationEvent(ApplicationEvent event)
Handle an application event.
|
private static ResolvableType |
resolveDeclaredEventType(ApplicationListener<ApplicationEvent> listener) |
(package private) static ResolvableType |
resolveDeclaredEventType(java.lang.Class<?> listenerType) |
boolean |
supportsEventType(java.lang.Class<? extends ApplicationEvent> eventType)
Determine whether this listener actually supports the given event type.
|
boolean |
supportsEventType(ResolvableType eventType)
Determine whether this listener actually supports the given event type.
|
boolean |
supportsSourceType(java.lang.Class<?> sourceType)
Determine whether this listener actually supports the given source type.
|
private final ApplicationListener<ApplicationEvent> delegate
private final ResolvableType declaredEventType
public GenericApplicationListenerAdapter(ApplicationListener<?> delegate)
delegate
- the delegate listener to be invokedpublic void onApplicationEvent(ApplicationEvent event)
ApplicationListener
onApplicationEvent
in interface ApplicationListener<ApplicationEvent>
event
- the event to respond topublic boolean supportsEventType(ResolvableType eventType)
GenericApplicationListener
supportsEventType
in interface GenericApplicationListener
public boolean supportsEventType(java.lang.Class<? extends ApplicationEvent> eventType)
SmartApplicationListener
supportsEventType
in interface SmartApplicationListener
public boolean supportsSourceType(java.lang.Class<?> sourceType)
GenericApplicationListener
supportsSourceType
in interface GenericApplicationListener
supportsSourceType
in interface SmartApplicationListener
public int getOrder()
Ordered
Higher values are interpreted as lower priority. As a consequence,
the object with the lowest value has the highest priority (somewhat
analogous to Servlet load-on-startup
values).
Same order values will result in arbitrary sort positions for the affected objects.
getOrder
in interface Ordered
Ordered.HIGHEST_PRECEDENCE
,
Ordered.LOWEST_PRECEDENCE
static ResolvableType resolveDeclaredEventType(java.lang.Class<?> listenerType)
private static ResolvableType resolveDeclaredEventType(ApplicationListener<ApplicationEvent> listener)