类 AbstractApplicationEventMulticaster
ApplicationEventMulticaster interface,
providing the basic listener registration facility.
Doesn't permit multiple instances of the same listener by default, as it keeps listeners in a linked Set. The collection class used to hold ApplicationListener objects can be overridden through the "collectionClass" bean property.
Implementing ApplicationEventMulticaster's actual ApplicationEventMulticaster.multicastEvent(cn.taketoday.context.ApplicationEvent) method
is left to subclasses. SimpleApplicationEventMulticaster simply multicasts
all events to all registered listeners, invoking them in the calling thread.
Alternative implementations could be more sophisticated in those respects.
- 从以下版本开始:
- 4.0
- 作者:
- Juergen Hoeller, Stephane Nicoll, Harry Yang
- 另请参阅:
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidaddApplicationListener(ApplicationListener listener) Add a listener to be notified of all events.voidaddApplicationListenerBean(String listenerBeanName) Add a listener bean to be notified of all events.protected Collection<ApplicationListener<?>>Return a Collection containing all ApplicationListeners.protected Collection<ApplicationListener<?>>getApplicationListeners(ApplicationEvent event, cn.taketoday.core.ResolvableType eventType) Return a Collection of ApplicationListeners matching the given event type.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. for annotatedEventListenermethods).voidsetBeanClassLoader(ClassLoader classLoader) voidsetBeanFactory(BeanFactory beanFactory) protected booleansupportsEvent(ApplicationListener<?> listener, cn.taketoday.core.ResolvableType eventType, Class<?> sourceType) Determine whether the given listener supports the given event.protected booleansupportsEvent(Class<?> listenerType, cn.taketoday.core.ResolvableType eventType) Filter a listener early through checking its generically declared event type before trying to instantiate it.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.context.event.ApplicationEventMulticaster
multicastEvent, multicastEvent
-
构造器详细资料
-
AbstractApplicationEventMulticaster
public AbstractApplicationEventMulticaster()
-
-
方法详细资料
-
setBeanClassLoader
- 指定者:
setBeanClassLoader在接口中BeanClassLoaderAware
-
setBeanFactory
- 指定者:
setBeanFactory在接口中BeanFactoryAware
-
addApplicationListener
从接口复制的说明:ApplicationEventMulticasterAdd a listener to be notified of all events.- 指定者:
addApplicationListener在接口中ApplicationEventMulticaster- 参数:
listener- the listener to add- 另请参阅:
-
addApplicationListenerBean
从接口复制的说明:ApplicationEventMulticasterAdd a listener bean to be notified of all events.- 指定者:
addApplicationListenerBean在接口中ApplicationEventMulticaster- 参数:
listenerBeanName- the name of the listener bean to add- 另请参阅:
-
removeApplicationListener
从接口复制的说明:ApplicationEventMulticasterRemove a listener from the notification list.- 指定者:
removeApplicationListener在接口中ApplicationEventMulticaster- 参数:
listener- the listener to remove- 另请参阅:
-
removeApplicationListenerBean
从接口复制的说明:ApplicationEventMulticasterRemove a listener bean from the notification list.- 指定者:
removeApplicationListenerBean在接口中ApplicationEventMulticaster- 参数:
listenerBeanName- the name of the listener bean to remove- 另请参阅:
-
removeApplicationListeners
从接口复制的说明:ApplicationEventMulticasterRemove 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.
- 指定者:
removeApplicationListeners在接口中ApplicationEventMulticaster- 参数:
predicate- the predicate to identify listener instances to remove, e.g. checkingSmartApplicationListener.getListenerId()- 另请参阅:
-
removeApplicationListenerBeans
从接口复制的说明:ApplicationEventMulticasterRemove 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.- 指定者:
removeApplicationListenerBeans在接口中ApplicationEventMulticaster- 参数:
predicate- the predicate to identify listener bean names to remove- 另请参阅:
-
removeAllListeners
public void removeAllListeners()从接口复制的说明:ApplicationEventMulticasterRemove all listeners registered with this multicaster.After a remove call, the multicaster will perform no action on event notification until new listeners are registered.
-
getApplicationListeners
Return a Collection containing all ApplicationListeners.- 返回:
- a Collection of ApplicationListeners
- 另请参阅:
-
getApplicationListeners
protected Collection<ApplicationListener<?>> getApplicationListeners(ApplicationEvent event, cn.taketoday.core.ResolvableType eventType) Return a Collection of ApplicationListeners matching the given event type. Non-matching listeners get excluded early.- 参数:
event- the event to be propagated. Allows for excluding non-matching listeners early, based on cached matching information.eventType- the event type- 返回:
- a Collection of ApplicationListeners
- 另请参阅:
-
supportsEvent
Filter a listener early through checking its generically declared event type before trying to instantiate it.If this method returns
truefor a given listener as a first pass, the listener instance will get retrieved and fully evaluated through asupportsEvent(ApplicationListener, ResolvableType, Class)call afterwards.- 参数:
listenerType- the listener's type as determined by the BeanFactoryeventType- the event type to check- 返回:
- whether the given listener should be included in the candidates for the given event type
-
supportsEvent
protected boolean supportsEvent(ApplicationListener<?> listener, cn.taketoday.core.ResolvableType eventType, @Nullable Class<?> sourceType) Determine whether the given listener supports the given event.The default implementation detects the
SmartApplicationListenerandGenericApplicationListenerinterfaces. In case of a standardApplicationListener, aGenericApplicationListenerAdapterwill be used to introspect the generically declared type of the target listener.- 参数:
listener- the target listener to checkeventType- the event type to check againstsourceType- the source type to check against- 返回:
- whether the given listener should be included in the candidates for the given event type
-