org.springframework.context.event

## Interface ApplicationEventMulticaster

- All Known Implementing Classes:
    AbstractApplicationEventMulticaster, SimpleApplicationEventMulticaster

      public interface ApplicationEventMulticaster

  Interface to be implemented by objects that can manage a number of `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:
    `ApplicationListener`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `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).
    `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.

- - ### Method Detail

    - #### addApplicationListener

          void addApplicationListener(ApplicationListener<?> listener)

      Add a listener to be notified of all events.
      Parameters:
        `listener` - the listener to add
      See Also:
        `removeApplicationListener(ApplicationListener)`, `removeApplicationListeners(Predicate)`

    - #### addApplicationListenerBean

          void addApplicationListenerBean(String listenerBeanName)

      Add a listener bean to be notified of all events.
      Parameters:
        `listenerBeanName` - the name of the listener bean to add
      See Also:
        `removeApplicationListenerBean(String)`, `removeApplicationListenerBeans(Predicate)`

    - #### removeApplicationListener

          void removeApplicationListener(ApplicationListener<?> listener)

      Remove a listener from the notification list.
      Parameters:
        `listener` - the listener to remove
      See Also:
        `addApplicationListener(ApplicationListener)`, `removeApplicationListeners(Predicate)`

    - #### removeApplicationListenerBean

          void removeApplicationListenerBean(String listenerBeanName)

      Remove a listener bean from the notification list.
      Parameters:
        `listenerBeanName` - the name of the listener bean to remove
      See Also:
        `addApplicationListenerBean(String)`, `removeApplicationListenerBeans(Predicate)`

    - #### removeApplicationListeners

          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` - the predicate to identify listener instances to remove, e.g. checking `SmartApplicationListener.getListenerId()`
      Since:
        5.3.5
      See Also:
        `addApplicationListener(ApplicationListener)`, `removeApplicationListener(ApplicationListener)`

    - #### removeApplicationListenerBeans

          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` - the predicate to identify listener bean names to remove
      Since:
        5.3.5
      See Also:
        `addApplicationListenerBean(String)`, `removeApplicationListenerBean(String)`

    - #### 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:
        `removeApplicationListeners(Predicate)`

    - #### 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.

      Parameters:
        `event` - the event to multicast

    - #### multicastEvent

          void multicastEvent(ApplicationEvent event,
                              @Nullable
                              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.

      Parameters:
        `event` - the event to multicast
        `eventType` - the type of event (can be `null`)
      Since:
        4.2