ApplicationEvent class abstract
An optional base class for application events: it records which object raised the event and when.
An event is a message that one part of an application publishes and
any number of listeners receive. Extending this class is optional: any
object can be published, and the context then wraps it in a
PayloadApplicationEvent. Extend it when listeners need the source
and timestamp; a plain class (or a record) is enough otherwise. The
context's own events (ContextRefreshedEvent, ...) extend it.
// Raised by the shipping service, with the order id.
class OrderShipped extends ApplicationEvent {
OrderShipped(super.source, this.id);
final int id;
}
context.publishEvent(OrderShipped(this, 42));
Spring (Java):
class OrderShipped extends ApplicationEvent {
OrderShipped(Object source, int id) { super(source); this.id = id; }
final int id;
}
context.publishEvent(new OrderShipped(this, 42));
- Implementers
Constructors
- ApplicationEvent(Object source, {DateTime? timestamp})
-
Creates an event raised by
source;timestampdefaults to the current time.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- source → Object
-
The object that raised the event, usually the publishing bean (or
the context, for the context's own events).
final
- timestamp → DateTime
-
When the event was created (not when a listener receives it).
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited