public class DefaultEventBus extends Object implements 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 shared/imported (even though Guava is Apache 2.0 licensed and could have
been used).
This implementation is thread-safe and may be used concurrently.Constructor and Description |
---|
DefaultEventBus() |
Modifier and Type | Method and Description |
---|---|
EventListenerResolver |
getEventListenerResolver() |
void |
publish(Object event)
Publishes the specified event to an event subsystem that will deliver events to relevant
Subscribe rs. |
void |
register(Object instance)
Registers all event handler methods on the specified instance to receive relevant events.
|
void |
setEventListenerResolver(EventListenerResolver eventListenerResolver) |
void |
unregister(Object instance)
Unregisters all previously-registered event handler methods on the specified instance.
|
public DefaultEventBus()
public EventListenerResolver getEventListenerResolver()
public void setEventListenerResolver(EventListenerResolver eventListenerResolver)
public void publish(Object event)
EventBus
Subscribe
rs.public void register(Object instance)
EventBus
EventBus
implementation, typically by using an
EventListenerResolver
(e.g. AnnotationEventListenerResolver
).public void unregister(Object instance)
EventBus
unregister
in interface EventBus
instance
- the previouslyCopyright © 2004–2019 The Apache Software Foundation. All rights reserved.