public class EventRedirector extends BasicEventDispatcher
RedirectedEvent
instances, so they
can be easily recognized from normal direct events. If an original event
wrapped in the RedirectedEvent
is consumed by any of the child
dispatchers, it won't be sent by the EventRedirector
to the rest of
the original dispatch chain.
The child dispatchers can also be instances of EventRedirector
and
might receive both, the normal events (from other sources) and the redirected
events from the parent EventRedirector
. If a RedirectedEvent
is received, it is forwarded to the child event dispatchers without any
additional wrapping.
For this hierarchical arrangement of EventRedirector
instances the
class defines the handleRedirectedEvent
method, which is called with
a received redirected event, after the event has been forwarded to the child
dispatchers. By default this method is empty, but can be overridden in
derived classes to define specific handling of these redirected events.
Modifier and Type | Field and Description |
---|---|
private EventDispatchChainImpl |
eventDispatchChain |
private java.util.List<EventDispatcher> |
eventDispatchers |
private java.lang.Object |
eventSource |
Constructor and Description |
---|
EventRedirector(java.lang.Object eventSource)
Constructs a new
EventRedirector . |
Modifier and Type | Method and Description |
---|---|
void |
addEventDispatcher(EventDispatcher eventDispatcher) |
Event |
dispatchCapturingEvent(Event event) |
protected void |
handleRedirectedEvent(java.lang.Object eventSource,
Event event)
Called when a redirected event is received by this instance.
|
private void |
redirectEvent(Event event) |
void |
removeEventDispatcher(EventDispatcher eventDispatcher) |
dispatchBubblingEvent, dispatchEvent, getNextDispatcher, getPreviousDispatcher, insertNextDispatcher
private final EventDispatchChainImpl eventDispatchChain
private final java.util.List<EventDispatcher> eventDispatchers
private final java.lang.Object eventSource
public EventRedirector(java.lang.Object eventSource)
EventRedirector
.eventSource
- the object for which to redirect the events
(RedirectedEvent
event source)protected void handleRedirectedEvent(java.lang.Object eventSource, Event event)
eventSource
- the object from which the event has been redirectedevent
- the event which has been redirectedpublic final void addEventDispatcher(EventDispatcher eventDispatcher)
public final void removeEventDispatcher(EventDispatcher eventDispatcher)
public final Event dispatchCapturingEvent(Event event)
dispatchCapturingEvent
in class BasicEventDispatcher
private void redirectEvent(Event event)