org.springframework.context.event

## 类 AbstractApplicationEventMulticaster

- java.lang.Object
- - org.springframework.context.event.AbstractApplicationEventMulticaster

- 所有已实现的接口:
    org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware, ApplicationEventMulticaster
  直接已知子类:
    SimpleApplicationEventMulticaster

      public abstract class AbstractApplicationEventMulticaster
      extends Object
      implements ApplicationEventMulticaster, org.springframework.beans.factory.BeanClassLoaderAware, org.springframework.beans.factory.BeanFactoryAware

  Abstract implementation of the `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(org.springframework.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.

  从以下版本开始:
    1.2.3
  作者:
    Juergen Hoeller, Stephane Nicoll
  另请参阅:
    `getApplicationListeners(ApplicationEvent, ResolvableType)`, `SimpleApplicationEventMulticaster`

- - ### 构造器概要

    构造器
    构造器和说明
    `AbstractApplicationEventMulticaster()`

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `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.
    `protected Collection<ApplicationListener<?>>` | `getApplicationListeners()` Return a Collection containing all ApplicationListeners.
    `protected Collection<ApplicationListener<?>>` | `getApplicationListeners(ApplicationEvent event, org.springframework.core.ResolvableType eventType)` Return a Collection of ApplicationListeners matching the given event type.
    `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.
    `void` | `setBeanClassLoader(ClassLoader classLoader)`
    `void` | `setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)`
    `protected boolean` | `supportsEvent(ApplicationListener<?> listener, org.springframework.core.ResolvableType eventType, Class<?> sourceType)` Determine whether the given listener supports the given event.
    `protected boolean` | `supportsEvent(Class<?> listenerType, org.springframework.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`

    - ### 从接口继承的方法 org.springframework.context.event.ApplicationEventMulticaster

      `multicastEvent, multicastEvent`

- - ### 构造器详细资料

    - #### AbstractApplicationEventMulticaster

          public AbstractApplicationEventMulticaster()

  - ### 方法详细资料

    - #### setBeanClassLoader

          public void setBeanClassLoader(ClassLoader classLoader)

      指定者:
        `setBeanClassLoader` 在接口中 `org.springframework.beans.factory.BeanClassLoaderAware`

    - #### setBeanFactory

          public void setBeanFactory(org.springframework.beans.factory.BeanFactory beanFactory)

      指定者:
        `setBeanFactory` 在接口中 `org.springframework.beans.factory.BeanFactoryAware`

    - #### addApplicationListener

          public void addApplicationListener(ApplicationListener<?> listener)

      从接口复制的说明: `ApplicationEventMulticaster`
      Add a listener to be notified of all events.
      指定者:
        `addApplicationListener` 在接口中 `ApplicationEventMulticaster`
      参数:
        `listener` - the listener to add

    - #### addApplicationListenerBean

          public void addApplicationListenerBean(String listenerBeanName)

      从接口复制的说明: `ApplicationEventMulticaster`
      Add a listener bean to be notified of all events.
      指定者:
        `addApplicationListenerBean` 在接口中 `ApplicationEventMulticaster`
      参数:
        `listenerBeanName` - the name of the listener bean to add

    - #### removeApplicationListener

          public void removeApplicationListener(ApplicationListener<?> listener)

      从接口复制的说明: `ApplicationEventMulticaster`
      Remove a listener from the notification list.
      指定者:
        `removeApplicationListener` 在接口中 `ApplicationEventMulticaster`
      参数:
        `listener` - the listener to remove

    - #### removeApplicationListenerBean

          public void removeApplicationListenerBean(String listenerBeanName)

      从接口复制的说明: `ApplicationEventMulticaster`
      Remove a listener bean from the notification list.
      指定者:
        `removeApplicationListenerBean` 在接口中 `ApplicationEventMulticaster`
      参数:
        `listenerBeanName` - the name of the listener bean to add

    - #### removeAllListeners

          public void removeAllListeners()

      从接口复制的说明: `ApplicationEventMulticaster`
      Remove all listeners registered with this multicaster.

      After a remove call, the multicaster will perform no action on event notification until new listeners are being registered.

      指定者:
        `removeAllListeners` 在接口中 `ApplicationEventMulticaster`

    - #### getApplicationListeners

          protected Collection<ApplicationListener<?>> getApplicationListeners()

      Return a Collection containing all ApplicationListeners.
      返回:
        a Collection of ApplicationListeners
      另请参阅:
        `ApplicationListener`

    - #### getApplicationListeners

          protected Collection<ApplicationListener<?>> getApplicationListeners(ApplicationEvent event,
                                                                               org.springframework.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
      另请参阅:
        `ApplicationListener`

    - #### supportsEvent

          protected boolean supportsEvent(Class<?> listenerType,
                                          org.springframework.core.ResolvableType eventType)

      Filter a listener early through checking its generically declared event type before trying to instantiate it.

      If this method returns `true` for a given listener as a first pass, the listener instance will get retrieved and fully evaluated through a `supportsEvent(ApplicationListener, ResolvableType, Class)` call afterwards.

      参数:
        `listenerType` - the listener's type as determined by the BeanFactory
        `eventType` - 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,
                                          org.springframework.core.ResolvableType eventType,
                                          @Nullable
                                          Class<?> sourceType)

      Determine whether the given listener supports the given event.

      The default implementation detects the `SmartApplicationListener` and `GenericApplicationListener` interfaces. In case of a standard `ApplicationListener`, a `GenericApplicationListenerAdapter` will be used to introspect the generically declared type of the target listener.

      参数:
        `listener` - the target listener to check
        `eventType` - the event type to check against
        `sourceType` - the source type to check against
      返回:
        whether the given listener should be included in the candidates for the given event type