Class ScopedEventBus
java.lang.Object
org.vaadin.spring.events.internal.ScopedEventBus
- All Implemented Interfaces:
Serializable,EventBus
- Direct Known Subclasses:
ScopedEventBus.DefaultApplicationEventBus,ScopedEventBus.DefaultSessionEventBus,ScopedEventBus.DefaultUIEventBus,ScopedEventBus.DefualtViewEventBus
Implementation of
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.- Author:
- Petter Holmström (petter@vaadin.com)
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDefault implementation ofEventBus.ApplicationEventBus.static classDefault implementation ofEventBus.SessionEventBus.static classDefault implementation ofEventBus.UIEventBus.static classDefault implementation ofEventBus.ViewEventBus.Nested classes/interfaces inherited from interface org.vaadin.spring.events.EventBus
EventBus.ApplicationEventBus, EventBus.SessionEventBus, EventBus.UIEventBus, EventBus.ViewEventBus -
Constructor Summary
ConstructorsConstructorDescriptionScopedEventBus(EventScope scope) ScopedEventBus(EventScope scope, EventBus parentEventBus) -
Method Summary
Modifier and TypeMethodDescriptionprotected EventBusGets the parent of this event bus.getScope()Gets the scope of the events published on this event bus.<T> voidPublishes the specified payload on the event bus, using the scope of this particular event bus.<T> voidPublishes the specified payload on the event bus, using the scope of this particular event bus.<T> voidpublish(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> voidpublish(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.voidSubscribes the specified listener to the event bus.voidSubscribes the specified listener to the event bus.voidSubscribes the topic interested listener to the event bus.<T> voidsubscribe(EventBusListener<T> listener) Subscribes the specified listener to the event bus, including propagated events from parent event buses.<T> voidsubscribe(EventBusListener<T> listener, boolean includingPropagatingEvents) Subscribes the specified listener to the event bus.<T> voidsubscribe(EventBusListener<T> listener, String topic) Subscribes the topic interested listener to the event bus, including propagated events from parent event buses.voidsubscribeWithWeakReference(Object listener) Same asEventBus.subscribe(Object), but uses a weak reference to store the listener internally.voidsubscribeWithWeakReference(Object listener, boolean includingPropagatingEvents) Same asEventBus.subscribe(Object, boolean), but uses a weak reference to store the listener internally.voidsubscribeWithWeakReference(Object listener, String topic) Same asEventBus.subscribe(Object, String), but uses a weak reference to store the listener internally.<T> voidsubscribeWithWeakReference(EventBusListener<T> listener) Same asEventBus.subscribe(EventBusListener), but uses a weak reference to store the listener internally.<T> voidsubscribeWithWeakReference(EventBusListener<T> listener, boolean includingPropagatingEvents) Same asEventBus.subscribe(EventBusListener, boolean), but uses a weak reference to store the listener internally.<T> voidsubscribeWithWeakReference(EventBusListener<T> listener, String topic) Same asEventBus.subscribe(EventBusListener, String), but uses a weak reference to store the listener internally.toString()voidunsubscribe(Object listener) Unsubscribes the specified listener (and all its listener methods) from the event bus.<T> voidunsubscribe(EventBusListener<T> listener) Unsubscribes the specified listener from the event bus.
-
Constructor Details
-
ScopedEventBus
- Parameters:
scope- the scope of the events that this event bus handles.
-
ScopedEventBus
- Parameters:
scope- the scope of the events that this event bus handles.parentEventBus- the parent event bus to use, may benull;
-
-
Method Details
-
getScope
Description copied from interface:EventBusGets the scope of the events published on this event bus. -
publish
Description copied from interface:EventBusPublishes the specified payload on the event bus, using the scope of this particular event bus. -
publish
Description copied from interface:EventBusPublishes the specified payload on the event bus, using the scope of this particular event bus. The topic specifies which listeners will be notified. -
publish
public <T> void publish(EventScope scope, Object sender, T payload) throws UnsupportedOperationException Description copied from interface:EventBusPublishes the specified payload on the event bus, or any of its parent buses, depending on the event scope.- Specified by:
publishin interfaceEventBus- Type Parameters:
T- the type of the payload;- Parameters:
scope- the scope of the event, nevernull.sender- the object that published the event, nevernull.payload- the payload of the event to publish, nevernull.- Throws:
UnsupportedOperationException- if the payload could not be published with the specified scope.- See Also:
-
publish
public <T> void publish(EventScope scope, String topic, Object sender, T payload) throws UnsupportedOperationException Description copied from interface:EventBusPublishes the specified payload on the event bus, or any of its parent buses, depending on the event scope. The topic specifies which listeners will be notified.- Specified by:
publishin interfaceEventBus- Type Parameters:
T- the type of the payload;- Parameters:
scope- the scope of the event, nevernull.topic- the topic of the event to publish, nevernull.sender- the object that published the event, nevernull.payload- the payload of the event to publish, nevernull.- Throws:
UnsupportedOperationException- if the payload could not be published with the specified scope.- See Also:
-
subscribe
Description copied from interface:EventBusSubscribes the specified listener to the event bus, including propagated events from parent event buses. The event bus will analyse the payload type of the listener to determine which events it is interested in receiving. This is the same as callingsubscribe(listener, true). -
subscribeWithWeakReference
Description copied from interface:EventBusSame asEventBus.subscribe(EventBusListener), but uses a weak reference to store the listener internally.- Specified by:
subscribeWithWeakReferencein interfaceEventBus
-
subscribe
Description copied from interface:EventBusSubscribes the topic interested listener to the event bus, including propagated events from parent event buses. The event bus will analyse the payload type and topic of the listener to determine which events it is interested in receiving. -
subscribe
Description copied from interface:EventBusSubscribes the specified listener to the event bus. The event bus will analyse the payload type of the listener to determine which events it is interested in receiving.- Specified by:
subscribein interfaceEventBus- Type Parameters:
T- the type of payload the listener is interested in.- Parameters:
listener- the listener to subscribe, nevernull.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.- See Also:
-
subscribeWithWeakReference
Description copied from interface:EventBusSame asEventBus.subscribe(EventBusListener, String), but uses a weak reference to store the listener internally.- Specified by:
subscribeWithWeakReferencein interfaceEventBus
-
subscribeWithWeakReference
public <T> void subscribeWithWeakReference(EventBusListener<T> listener, boolean includingPropagatingEvents) Description copied from interface:EventBusSame asEventBus.subscribe(EventBusListener, boolean), but uses a weak reference to store the listener internally.- Specified by:
subscribeWithWeakReferencein interfaceEventBus
-
subscribe
Description copied from interface:EventBusSubscribes the specified listener to the event bus. The listener need not implement theEventBusListenerinterface, but must contain one or more methods that are annotated with theEventBusListenerMethodinterface and conform to one of these method signatures:myMethodName(Event<MyPayloadType>)ormyMethodName(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 callingsubscribe(listener, true). -
subscribe
Description copied from interface:EventBusSubscribes the topic interested listener to the event bus. The listener need not implement theEventBusListenerinterface, but must contain one or more methods that are annotated with theEventBusListenerMethodinterface and conform to one of these method signatures:myMethodName(Event<MyPayloadType>)ormyMethodName(MyPayloadType). The event bus will analyse the payload type of the listener methods to determine which events the different methods are interested in receiving.
Example:subscribe(Listener.this, "/news"); -
subscribeWithWeakReference
Description copied from interface:EventBusSame asEventBus.subscribe(Object, String), but uses a weak reference to store the listener internally.- Specified by:
subscribeWithWeakReferencein interfaceEventBus
-
subscribeWithWeakReference
Description copied from interface:EventBusSame asEventBus.subscribe(Object), but uses a weak reference to store the listener internally.- Specified by:
subscribeWithWeakReferencein interfaceEventBus
-
subscribe
Description copied from interface:EventBusSubscribes the specified listener to the event bus. The listener need not implement theEventBusListenerinterface, but must contain one or more methods that are annotated with theEventBusListenerMethodinterface and conform to one of these method signatures:myMethodName(Event<MyPayloadType>)ormyMethodName(MyPayloadType). The event bus will analyse the payload type of the listener methods to determine which events the different methods are interested in receiving.- Specified by:
subscribein interfaceEventBus- Parameters:
listener- the listener to subscribe, nevernull.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.- See Also:
-
subscribeWithWeakReference
Description copied from interface:EventBusSame asEventBus.subscribe(Object, boolean), but uses a weak reference to store the listener internally.- Specified by:
subscribeWithWeakReferencein interfaceEventBus
-
unsubscribe
Description copied from interface:EventBusUnsubscribes the specified listener from the event bus. Also works for listeners stored with weak references.- Specified by:
unsubscribein interfaceEventBus- Type Parameters:
T- the type of the payload.- Parameters:
listener- the listener to unsubscribe, nevernull.- See Also:
-
unsubscribe
Description copied from interface:EventBusUnsubscribes the specified listener (and all its listener methods) from the event bus. Also works for listeners stored with weak references.- Specified by:
unsubscribein interfaceEventBus- Parameters:
listener- the listener to unsubscribe, nevernull.- See Also:
-
getParentEventBus
Gets the parent of this event bus. Events published on the parent bus will also propagate to the listeners of this event bus.- Returns:
- the parent event bus, or
nullif this event bus has no parent.
-
toString
-