public interface ApplicationEventMulticaster
ApplicationListener
objects and publish events to them.
An ApplicationEventPublisher
, typically
a Spring ApplicationContext
, can use an
ApplicationEventMulticaster
as a delegate for actually publishing events.
ApplicationListener
Modifier and Type | Method and Description |
---|---|
void |
addApplicationListener(ApplicationListener<?> listener)
Add a listener to be notified of all events.
|
void |
addApplicationListenerBean(String listenerBeanName)
Add a listener bean to be notified of all events.
|
void |
multicastEvent(ApplicationEvent event)
Multicast the given application event to appropriate listeners.
|
void |
multicastEvent(ApplicationEvent event,
ResolvableType eventType)
Multicast the given application event to appropriate listeners.
|
void |
removeAllListeners()
Remove all listeners registered with this multicaster.
|
void |
removeApplicationListener(ApplicationListener<?> listener)
Remove a listener from the notification list.
|
void |
removeApplicationListenerBean(String listenerBeanName)
Remove a listener bean from the notification list.
|
void |
removeApplicationListenerBeans(Predicate<String> predicate)
Remove all matching listener beans from the set of registered
listener bean names (referring to bean classes which in turn
implement the
ApplicationListener interface directly). |
void |
removeApplicationListeners(Predicate<ApplicationListener<?>> predicate)
Remove all matching listeners from the set of registered
ApplicationListener instances (which includes adapter classes
such as ApplicationListenerMethodAdapter , e.g. |
void addApplicationListener(ApplicationListener<?> listener)
listener
- the listener to addremoveApplicationListener(ApplicationListener)
,
removeApplicationListeners(Predicate)
void addApplicationListenerBean(String listenerBeanName)
listenerBeanName
- the name of the listener bean to addremoveApplicationListenerBean(String)
,
removeApplicationListenerBeans(Predicate)
void removeApplicationListener(ApplicationListener<?> listener)
listener
- the listener to removeaddApplicationListener(ApplicationListener)
,
removeApplicationListeners(Predicate)
void removeApplicationListenerBean(String listenerBeanName)
listenerBeanName
- the name of the listener bean to removeaddApplicationListenerBean(String)
,
removeApplicationListenerBeans(Predicate)
void removeApplicationListeners(Predicate<ApplicationListener<?>> predicate)
ApplicationListener
instances (which includes adapter classes
such as ApplicationListenerMethodAdapter
, e.g. for annotated
EventListener
methods).
Note: This just applies to instance registrations, not to listeners registered by bean name.
predicate
- the predicate to identify listener instances to remove,
e.g. checking SmartApplicationListener.getListenerId()
addApplicationListener(ApplicationListener)
,
removeApplicationListener(ApplicationListener)
void removeApplicationListenerBeans(Predicate<String> predicate)
ApplicationListener
interface directly).
Note: This just applies to bean name registrations, not to
programmatically registered ApplicationListener
instances.
predicate
- the predicate to identify listener bean names to removeaddApplicationListenerBean(String)
,
removeApplicationListenerBean(String)
void removeAllListeners()
After a remove call, the multicaster will perform no action on event notification until new listeners are registered.
removeApplicationListeners(Predicate)
void multicastEvent(ApplicationEvent event)
Consider using multicastEvent(ApplicationEvent, ResolvableType)
if possible as it provides better support for generics-based events.
event
- the event to multicastvoid multicastEvent(ApplicationEvent event, @Nullable ResolvableType eventType)
If the eventType
is null
, a default type is built
based on the event
instance.
event
- the event to multicasteventType
- the type of event (can be null
)