接口 ApplicationEventMulticaster
public interface ApplicationEventMulticaster
Interface to be implemented by objects that can manage a number ofApplicationListener
objects and publish events to them.An
ApplicationEventPublisher
, typically a SpringApplicationContext
, can use anApplicationEventMulticaster
as a delegate for actually publishing events.- 作者:
- Rod Johnson, Juergen Hoeller, Stephane Nicoll
- 另请参阅:
ApplicationListener
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 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.
方法详细资料
addApplicationListener
void addApplicationListener(ApplicationListener<?> listener)
Add a listener to be notified of all events.- 参数:
listener
- the listener to add
addApplicationListenerBean
void addApplicationListenerBean(String listenerBeanName)
Add a listener bean to be notified of all events.- 参数:
listenerBeanName
- the name of the listener bean to add
removeApplicationListener
void removeApplicationListener(ApplicationListener<?> listener)
Remove a listener from the notification list.- 参数:
listener
- the listener to remove
removeApplicationListenerBean
void removeApplicationListenerBean(String listenerBeanName)
Remove a listener bean from the notification list.- 参数:
listenerBeanName
- the name of the listener bean to remove
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.
multicastEvent
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.- 参数:
event
- the event to multicast
multicastEvent
void multicastEvent(ApplicationEvent event, @Nullable ResolvableType eventType)
Multicast the given application event to appropriate listeners.If the
eventType
isnull
, a default type is built based on theevent
instance.- 参数:
event
- the event to multicasteventType
- the type of event (can benull
)- 从以下版本开始:
- 4.2