Package org.springframework.context
Interface ApplicationListener<E extends ApplicationEvent>
- Type Parameters:
E- the specificApplicationEventsubclass to listen to
- All Superinterfaces:
EventListener
- All Known Subinterfaces:
GenericApplicationListener,SmartApplicationListener,TransactionalApplicationListener<E>
- All Known Implementing Classes:
ApplicationListenerMethodAdapter,DefaultSimpUserRegistry,ExecutorConfigurationSupport,GenericApplicationListenerAdapter,JmsListenerEndpointRegistry,MultiServerUserRegistry,ResourceUrlProvider,ResourceUrlProvider,ScheduledAnnotationBeanPostProcessor,ScheduledExecutorFactoryBean,SimpleAsyncTaskScheduler,SourceFilteringListener,ThreadPoolExecutorFactoryBean,ThreadPoolTaskExecutor,ThreadPoolTaskScheduler,TransactionalApplicationListenerAdapter,TransactionalApplicationListenerMethodAdapter,UserRegistryMessageHandler
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface ApplicationListener<E extends ApplicationEvent>
extends EventListener
Interface to be implemented by application event listeners.
Based on the standard EventListener interface for the
Observer design pattern.
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.
- Author:
- Rod Johnson, Juergen Hoeller
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ApplicationListener<PayloadApplicationEvent<T>>forPayload(Consumer<T> consumer) Create a newApplicationListenerfor the given payload consumer.voidonApplicationEvent(E event) Handle an application event.default booleanReturn whether this listener supports asynchronous execution.
-
Method Details
-
onApplicationEvent
Handle an application event.- Parameters:
event- the event to respond to
-
supportsAsyncExecution
default boolean supportsAsyncExecution()Return whether this listener supports asynchronous execution.- Returns:
trueif this listener instance can be executed asynchronously depending on the multicaster configuration (the default), orfalseif it needs to immediately run within the original thread which published the event- Since:
- 6.1
- See Also:
-
forPayload
Create a newApplicationListenerfor the given payload consumer.- Type Parameters:
T- the type of the event payload- Parameters:
consumer- the event payload consumer- Returns:
- a corresponding
ApplicationListenerinstance - Since:
- 5.3
- See Also:
-