Top Description Methods
org.springframework.context.event

public Interface ApplicationEventMulticaster

Known Direct Implementers
org.springframework.context.event.AbstractApplicationEventMulticaster
Imports
java.util.function.Predicate, org.springframework.context.ApplicationEvent, .ApplicationListener, org.springframework.core.ResolvableType, org.springframework.lang.Nullable

Interface to be implemented by objects that can manage a number of ApplicationListener objects and publish events to them.

An org.springframework.context.ApplicationEventPublisher, typically a Spring org.springframework.context.ApplicationContext, can use an ApplicationEventMulticaster as a delegate for actually publishing events.

Authors
Rod Johnson, Juergen Hoeller, Stephane Nicoll
See Also
ApplicationListener

Method Summary

Modifier and TypeMethod and Description
public void
addApplicationListener(ApplicationListener<?>
the listener to add
listener
)

Add a listener to be notified of all events.

public void
addApplicationListenerBean(String
the name of the listener bean to add
listenerBeanName
)

Add a listener bean to be notified of all events.

public void
multicastEvent(ApplicationEvent
the event to multicast
event
)

Multicast the given application event to appropriate listeners.

public void
multicastEvent(ApplicationEvent
the event to multicast
event
,
ResolvableType
the type of event (can be null)
eventType
)

Multicast the given application event to appropriate listeners.

public void
removeAllListeners()

Remove all listeners registered with this multicaster.

public void
removeApplicationListener(ApplicationListener<?>
the listener to remove
listener
)

Remove a listener from the notification list.

public void
removeApplicationListenerBean(String
the name of the listener bean to remove
listenerBeanName
)

Remove a listener bean from the notification list.

public void
removeApplicationListenerBeans(Predicate<String>
the predicate to identify listener bean names to remove
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).

public void
removeApplicationListeners(Predicate<ApplicationListener<?>>
the predicate to identify listener instances to remove, e.g. checking SmartApplicationListener#getListenerId()
predicate
)

Remove all matching listeners from the set of registered ApplicationListener instances (which includes adapter classes such as ApplicationListenerMethodAdapter, e.g. for annotated EventListener methods).

Method Detail

addApplicationListenerback to summary
public void addApplicationListener(ApplicationListener<?> listener)

Add a listener to be notified of all events.

Parameters
listener:ApplicationListener<?>

the listener to add

See Also
removeApplicationListener(ApplicationListener), removeApplicationListeners(Predicate)
addApplicationListenerBeanback to summary
public void addApplicationListenerBean(String listenerBeanName)

Add a listener bean to be notified of all events.

Parameters
listenerBeanName:String

the name of the listener bean to add

See Also
removeApplicationListenerBean(String), removeApplicationListenerBeans(Predicate)
multicastEventback to summary
public void multicastEvent(ApplicationEvent event)

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 ApplicationListener does not support asynchronous execution, it must be run within the calling thread of this multicast call.

Parameters
event:ApplicationEvent

the event to multicast

See Also
ApplicationListener#supportsAsyncExecution()
multicastEventback to summary
public void multicastEvent(ApplicationEvent event, ResolvableType eventType)

Multicast the given application event to appropriate listeners.

If the eventType is null, a default type is built based on the event instance.

If a matching ApplicationListener does not support asynchronous execution, it must be run within the calling thread of this multicast call.

Parameters
event:ApplicationEvent

the event to multicast

eventType:ResolvableType

the type of event (can be null)

Since
4.2
See Also
ApplicationListener#supportsAsyncExecution()
removeAllListenersback to summary
public 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
removeApplicationListeners(Predicate)
removeApplicationListenerback to summary
public void removeApplicationListener(ApplicationListener<?> listener)

Remove a listener from the notification list.

Parameters
listener:ApplicationListener<?>

the listener to remove

See Also
addApplicationListener(ApplicationListener), removeApplicationListeners(Predicate)
removeApplicationListenerBeanback to summary
public void removeApplicationListenerBean(String listenerBeanName)

Remove a listener bean from the notification list.

Parameters
listenerBeanName:String

the name of the listener bean to remove

See Also
addApplicationListenerBean(String), removeApplicationListenerBeans(Predicate)
removeApplicationListenerBeansback to summary
public 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).

Note

This just applies to bean name registrations, not to programmatically registered ApplicationListener instances.

Parameters
predicate:Predicate<String>

the predicate to identify listener bean names to remove

Since
5.3.5
See Also
addApplicationListenerBean(String), removeApplicationListenerBean(String)
removeApplicationListenersback to summary
public 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. for annotated EventListener methods).

Note

This just applies to instance registrations, not to listeners registered by bean name.

Parameters
predicate:Predicate<ApplicationListener<?>>

the predicate to identify listener instances to remove, e.g. checking SmartApplicationListener#getListenerId()

Since
5.3.5
See Also
addApplicationListener(ApplicationListener), removeApplicationListener(ApplicationListener)