Interface ApplicationEventMulticaster
- All Known Implementing Classes:
AbstractApplicationEventMulticaster,SimpleApplicationEventMulticaster
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 TypeMethodDescriptionvoidaddApplicationListener(ApplicationListener<?> listener) Add a listener to be notified of all events.voidaddApplicationListenerBean(String listenerBeanName) Add a listener bean to be notified of all events.voidmulticastEvent(ApplicationEvent event) Multicast the given application event to appropriate listeners.voidmulticastEvent(ApplicationEvent event, ResolvableType eventType) Multicast the given application event to appropriate listeners.voidRemove all listeners registered with this multicaster.voidremoveApplicationListener(ApplicationListener<?> listener) Remove a listener from the notification list.voidremoveApplicationListenerBean(String listenerBeanName) Remove a listener bean from the notification list.voidremoveApplicationListenerBeans(Predicate<String> predicate) Remove all matching listener beans from the set of registered listener bean names (referring to bean classes which in turn implement theApplicationListenerinterface directly).voidremoveApplicationListeners(Predicate<ApplicationListener<?>> predicate) Remove all matching listeners from the set of registeredApplicationListenerinstances (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 registeredApplicationListenerinstances (which includes adapter classes such asApplicationListenerMethodAdapter, e.g. for annotatedEventListenermethods).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 theApplicationListenerinterface directly).Note: This just applies to bean name registrations, not to programmatically registered
ApplicationListenerinstances.- 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.If a matching
ApplicationListenerdoes not support asynchronous execution, it must be run within the calling thread of this multicast call.- Parameters:
event- the event to multicast- See Also:
-
multicastEvent
Multicast the given application event to appropriate listeners.If the
eventTypeisnull, a default type is built based on theeventinstance.If a matching
ApplicationListenerdoes not support asynchronous execution, it must be run within the calling thread of this multicast call.- Parameters:
event- the event to multicasteventType- the type of event (can benull)- Since:
- 4.2
- See Also:
-