Interface ApplicationEventMulticaster
- All Known Implementing Classes:
AbstractApplicationEventMulticaster
,SimpleApplicationEventMulticaster
public interface ApplicationEventMulticaster
Interface to be implemented by objects that can manage a number of
ApplicationListener
objects and publish events to them.
An ApplicationEventPublisher
, typically
a Spring ApplicationContext
, can use an
ApplicationEventMulticaster
as a delegate for actually publishing events.
- Author:
- Rod Johnson, Juergen Hoeller, Stephane Nicoll
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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
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 theApplicationListener
interface directly).void
removeApplicationListeners
(Predicate<ApplicationListener<?>> predicate) Remove all matching listeners from the set of registeredApplicationListener
instances (which includes adapter classes such asApplicationListenerMethodAdapter
, e.g.
-
Method Details
-
addApplicationListener
Add a listener to be notified of all events.- Parameters:
listener
- the listener to add- See Also:
-
addApplicationListenerBean
Add a listener bean to be notified of all events.- Parameters:
listenerBeanName
- the name of the listener bean to add- See Also:
-
removeApplicationListener
Remove a listener from the notification list.- Parameters:
listener
- the listener to remove- See Also:
-
removeApplicationListenerBean
Remove a listener bean from the notification list.- Parameters:
listenerBeanName
- the name of the listener bean to remove- See Also:
-
removeApplicationListeners
Remove all matching listeners from the set of registeredApplicationListener
instances (which includes adapter classes such asApplicationListenerMethodAdapter
, e.g. for annotatedEventListener
methods).Note: This just applies to instance registrations, not to listeners registered by bean name.
- Parameters:
predicate
- the predicate to identify listener instances to remove, e.g. checkingSmartApplicationListener.getListenerId()
- Since:
- 5.3.5
- See Also:
-
removeApplicationListenerBeans
Remove all matching listener beans from the set of registered listener bean names (referring to bean classes which in turn implement theApplicationListener
interface directly).Note: This just applies to bean name registrations, not to programmatically registered
ApplicationListener
instances.- Parameters:
predicate
- the predicate to identify listener bean names to remove- Since:
- 5.3.5
- See Also:
-
removeAllListeners
void removeAllListeners()Remove all listeners registered with this multicaster.After a remove call, the multicaster will perform no action on event notification until new listeners are registered.
- See Also:
-
multicastEvent
Multicast the given application event to appropriate listeners.Consider using
multicastEvent(ApplicationEvent, ResolvableType)
if possible as it provides better support for generics-based events.- Parameters:
event
- the event to multicast
-
multicastEvent
Multicast the given application event to appropriate listeners.If the
eventType
isnull
, a default type is built based on theevent
instance.- Parameters:
event
- the event to multicasteventType
- the type of event (can benull
)- Since:
- 4.2
-