public interface EventBus
MyEvent myEvent = createMyEvent();
eventBus.publish(myEvent);
The event bus will determine the type of event and then dispatch the event to components that wish to receive
events of that type.
Subscribe annotation.
eventBus.register(myComponent);
Subscribe-annotated method(s) will be invoked as expected.
This design (and its constituent helper components) was largely influenced by
Guava's EventBus
concept, although no code was viewed/copied/imported (even though Guava code is Apache 2.0 licensed and could have
been used).| Modifier and Type | Method and Description |
|---|---|
void |
publish(Object event)
Publishes the specified event to an event subsystem that will deliver events to relevant
Subscribers. |
void |
register(Object subscriber)
Registers all event handler methods on the specified instance to receive relevant events.
|
void |
unregister(Object subscriber)
Unregisters all previously-registered event handler methods on the specified instance.
|
void publish(Object event)
Subscribers.event - The event object to distribute to relevant subscribers.void register(Object subscriber)
EventBus implementation, typically by using an
EventListenerResolver
(e.g. AnnotationEventListenerResolver).subscriber - the object whose event handler methods should be registered to receive events.void unregister(Object subscriber)
subscriber - the previouslyCopyright © 2004–2023 The Apache Software Foundation. All rights reserved.