ApplicationEventMulticaster class abstract interface

The part of the context that holds the listeners and delivers each published event to those that accept it.

Applications rarely touch it: they publish through the context (or an injected ApplicationEventPublisher) and listen with @EventListener. The context uses a bean named applicationEventMulticaster if one exists, otherwise a SimpleApplicationEventMulticaster. Declare such a bean to change how events are delivered; for asynchronous delivery or an error handler, configuring a SimpleApplicationEventMulticaster is enough. Implement the interface only for a different dispatch strategy.

// A multicaster on its own, outside a context.
final multicaster = SimpleApplicationEventMulticaster()
  ..addApplicationListener(
    ApplicationListenerAdapter.of<String>(log.info),
  );
multicaster.multicastEvent('hello'); // prints "hello"

Spring (Java):

var multicaster = new SimpleApplicationEventMulticaster();
multicaster.addApplicationListener(
    ApplicationListener.forPayload((String text) -> log.info(text)));
multicaster.multicastEvent(new PayloadApplicationEvent<>(this, "hello"));
Implementers

Properties

applicationListeners → List<GenericApplicationListener>
The listeners, in the order they are called.
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addApplicationListener(GenericApplicationListener listener) → void
Adds listener; adding it again moves it to the end of the listeners with the same order.
multicastEvent(Object event) → void
Delivers event to every listener whose supportsEvent accepts it. The context passes events already wrapped: a published object that is not an ApplicationEvent arrives as a PayloadApplicationEvent.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeAllListeners() → void
Removes every listener; the context calls it when it closes.
removeApplicationListener(GenericApplicationListener listener) → void
Removes listener; does nothing if it is not there.
removeApplicationListeners(bool predicate(GenericApplicationListener listener)) → void
Removes every listener predicate accepts, for example those of one bean that is being destroyed (Spring 5.3.5's removeApplicationListeners(Predicate)).
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited