E
- the specific ApplicationEvent
subclass to listen to@FunctionalInterface public interface ApplicationListener<E extends ApplicationEvent> extends EventListener
Based on the standard java.util.EventListener
interface
for the Observer design pattern.
As of Spring 3.0, an ApplicationListener
can generically declare
the event type that it is interested in. When registered with a Spring
ApplicationContext
, events will be filtered accordingly, with the
listener getting invoked for matching event objects only.
ApplicationEvent
,
ApplicationEventMulticaster
,
SmartApplicationListener
,
GenericApplicationListener
,
EventListener
Modifier and Type | Method and Description |
---|---|
static <T> ApplicationListener<PayloadApplicationEvent<T>> |
forPayload(Consumer<T> consumer)
Create a new
ApplicationListener for the given payload consumer. |
void |
onApplicationEvent(E event)
Handle an application event.
|
void onApplicationEvent(E event)
event
- the event to respond tostatic <T> ApplicationListener<PayloadApplicationEvent<T>> forPayload(Consumer<T> consumer)
ApplicationListener
for the given payload consumer.T
- the type of the event payloadconsumer
- the event payload consumerApplicationListener
instancePayloadApplicationEvent