public abstract class ScopedEventBus extends Object implements EventBus, Serializable
EventBus that publishes events with one specific EventScope.
A scoped event bus can also have a parent event bus, in which case all events published on the parent bus will propagate to the scoped event bus as well.| Modifier and Type | Class and Description |
|---|---|
static class |
ScopedEventBus.DefaultApplicationEventBus
Default implementation of
EventBus.ApplicationEventBus. |
static class |
ScopedEventBus.DefaultSessionEventBus
Default implementation of
EventBus.SessionEventBus. |
static class |
ScopedEventBus.DefaultUIEventBus
Default implementation of
EventBus.UIEventBus. |
static class |
ScopedEventBus.DefualtViewEventBus
Default implementation of
EventBus.ViewEventBus. |
EventBus.ApplicationEventBus, EventBus.SessionEventBus, EventBus.UIEventBus, EventBus.ViewEventBus| Constructor and Description |
|---|
ScopedEventBus(EventScope scope) |
ScopedEventBus(EventScope scope,
EventBus parentEventBus) |
| Modifier and Type | Method and Description |
|---|---|
protected EventBus |
getParentEventBus()
Gets the parent of this event bus.
|
EventScope |
getScope()
Gets the scope of the events published on this event bus.
|
<T> void |
publish(EventScope scope,
Object sender,
T payload)
Publishes the specified payload on the event bus, or any of its parent buses, depending on the event scope.
|
<T> void |
publish(EventScope scope,
String topic,
Object sender,
T payload)
Publishes the specified payload on the event bus, or any of its parent buses, depending on the event scope.
|
<T> void |
publish(Object sender,
T payload)
Publishes the specified payload on the event bus, using the scope of this particular event bus.
|
<T> void |
publish(String topic,
Object sender,
T payload)
Publishes the specified payload on the event bus, using the scope of this particular event bus.
|
<T> void |
subscribe(EventBusListener<T> listener)
Subscribes the specified listener to the event bus, including propagated events from parent event buses.
|
<T> void |
subscribe(EventBusListener<T> listener,
boolean includingPropagatingEvents)
Subscribes the specified listener to the event bus.
|
void |
subscribe(Object listener)
Subscribes the specified listener to the event bus.
|
void |
subscribe(Object listener,
boolean includingPropagatingEvents)
Subscribes the specified listener to the event bus.
|
String |
toString() |
<T> void |
unsubscribe(EventBusListener<T> listener)
Unsubscribes the specified listener from the event bus.
|
void |
unsubscribe(Object listener)
Unsubscribes the specified listener (and all its listener methods) from the event bus.
|
public ScopedEventBus(EventScope scope)
scope - the scope of the events that this event bus handles.public ScopedEventBus(EventScope scope, EventBus parentEventBus)
scope - the scope of the events that this event bus handles.parentEventBus - the parent event bus to use, may be null;public EventScope getScope()
EventBusgetScope in interface EventBusnull.Event.getScope()public <T> void publish(Object sender, T payload)
EventBuspublish in interface EventBusT - the type of the payload.sender - the object that published the event, never null.payload - the payload of the event to publish, never null.EventBus.getScope()public <T> void publish(String topic, Object sender, T payload)
EventBuspublish in interface EventBusT - the type of the payload.topic - the topic of the event to publish, never null.sender - the object that published the event, never null.payload - the payload of the event to publish, never null.EventBus.getScope()public <T> void publish(EventScope scope, Object sender, T payload) throws UnsupportedOperationException
EventBuspublish in interface EventBusT - the type of the payload;scope - the scope of the event, never null.sender - the object that published the event, never null.payload - the payload of the event to publish, never null.UnsupportedOperationException - if the payload could not be published with the specified scope.EventBus.publish(Object, Object)public <T> void publish(EventScope scope, String topic, Object sender, T payload) throws UnsupportedOperationException
EventBuspublish in interface EventBusT - the type of the payload;scope - the scope of the event, never null.topic - the topic of the event to publish, never null.sender - the object that published the event, never null.payload - the payload of the event to publish, never null.UnsupportedOperationException - if the payload could not be published with the specified scope.EventBus.publish(Object, Object)public <T> void subscribe(EventBusListener<T> listener)
EventBussubscribe(listener, true).subscribe in interface EventBusT - the type of payload the listener is interested in.listener - the listener to subscribe, never null.EventBus.unsubscribe(EventBusListener)public <T> void subscribe(EventBusListener<T> listener, boolean includingPropagatingEvents)
EventBussubscribe in interface EventBusT - the type of payload the listener is interested in.listener - the listener to subscribe, never null.includingPropagatingEvents - true to notify the listener of events that have propagated from the chain of parent event buses, false to only notify the listeners of events that are directly published on this event bus.EventBus.unsubscribe(EventBusListener)public void subscribe(Object listener)
EventBusEventBusListener interface,
but must contain one or more methods that are annotated with the EventBusListenerMethod interface and conform to one of these method
signatures: myMethodName(Event<MyPayloadType>) or myMethodName(MyPayloadType). The event bus will analyse the payload type of the listener methods to determine
which events the different methods are interested in receiving. This is the same as calling subscribe(listener, true).public void subscribe(Object listener, boolean includingPropagatingEvents)
EventBusEventBusListener interface,
but must contain one or more methods that are annotated with the EventBusListenerMethod interface and conform to one of these method
signatures: myMethodName(Event<MyPayloadType>) or myMethodName(MyPayloadType). The event bus will analyse the payload type of the listener methods to determine
which events the different methods are interested in receiving.subscribe in interface EventBuslistener - the listener to subscribe, never null.includingPropagatingEvents - true to notify the listener of events that have propagated from the chain of parent event buses, false to only notify the listeners of events that are directly published on this event bus.EventBus.unsubscribe(Object)public <T> void unsubscribe(EventBusListener<T> listener)
EventBusunsubscribe in interface EventBusT - the type of the payload.listener - the listener to unsubscribe, never null.EventBus.subscribe(EventBusListener),
EventBus.subscribe(EventBusListener, boolean)public void unsubscribe(Object listener)
EventBusunsubscribe in interface EventBuslistener - the listener to unsubscribe, never null.EventBus.subscribe(Object),
EventBus.subscribe(Object, boolean)protected EventBus getParentEventBus()
null if this event bus has no parent.Copyright © 2016. All rights reserved.