Interface GenericApplicationListener
- All Superinterfaces:
ApplicationListener<ApplicationEvent>
,EventListener
,Ordered
,SmartApplicationListener
- All Known Implementing Classes:
ApplicationListenerMethodAdapter
,GenericApplicationListenerAdapter
,SourceFilteringListener
,TransactionalApplicationListenerMethodAdapter
Extended variant of the standard
ApplicationListener
interface,
exposing further metadata such as the supported event and source type.
As of Spring Framework 4.2, this interface supersedes the Class-based
SmartApplicationListener
with full handling of generic event types.
As of 5.3.5, it formally extends SmartApplicationListener
, adapting
supportsEventType(Class)
to supportsEventType(ResolvableType)
with a default method.
- Since:
- 4.2
- Author:
- Stephane Nicoll, Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E extends ApplicationEvent>
GenericApplicationListenerforEventType
(Class<E> eventType, Consumer<E> consumer) Create a newApplicationListener
for the given event type.default boolean
supportsEventType
(Class<? extends ApplicationEvent> eventType) OverridesSmartApplicationListener.supportsEventType(Class)
with delegation tosupportsEventType(ResolvableType)
.boolean
supportsEventType
(ResolvableType eventType) Determine whether this listener actually supports the given event type.Methods inherited from interface org.springframework.context.ApplicationListener
onApplicationEvent, supportsAsyncExecution
Methods inherited from interface org.springframework.context.event.SmartApplicationListener
getListenerId, getOrder, supportsSourceType
-
Method Details
-
supportsEventType
OverridesSmartApplicationListener.supportsEventType(Class)
with delegation tosupportsEventType(ResolvableType)
.- Specified by:
supportsEventType
in interfaceSmartApplicationListener
- Parameters:
eventType
- the event type (nevernull
)
-
supportsEventType
Determine whether this listener actually supports the given event type.- Parameters:
eventType
- the event type (nevernull
)
-
forEventType
static <E extends ApplicationEvent> GenericApplicationListener forEventType(Class<E> eventType, Consumer<E> consumer) Create a newApplicationListener
for the given event type.- Type Parameters:
E
- the specificApplicationEvent
subclass to listen to- Parameters:
eventType
- the event to listen toconsumer
- the consumer to invoke when a matching event is fired- Returns:
- a corresponding
ApplicationListener
instance - Since:
- 6.1.3
-