org.openbandy.event
Class EventDispatcher

java.lang.Object
  extended by org.openbandy.event.EventDispatcher

public class EventDispatcher
extends java.lang.Object

The EventDispatcher combines every EventSink that absorbs a certain type of Event. By using the corresponding EventDispatcher, the EventService does not have to iterate through the list of subscribed sinks, as it can delegate this task to a suitable dispatcher.

(c) Copyright Philipp Bolliger 2007, ALL RIGHTS RESERVED.

Version:
1.0
Author:
Philipp Bolliger (philipp@bolliger.name)

Constructor Summary
EventDispatcher(java.lang.String eventShortClassName)
           
 
Method Summary
 void addSink(EventSink eventSink, EventFilter filter)
          Put the event sink and the related event filter under this EventDispatcher's control.
 void dispatchEvent(Event event)
          Dispatch the given event to all registered event sinks.
 java.lang.String getEventShortClassName()
          Return the short class name of the event type that is controlled by this EventDispatcher
 void informLostSource()
          Inform all registered event sinks that the corresponding event source is gone.
 boolean isEmpty()
          Check whether this EventDispatcher controls any sinks.
 boolean removeSink(EventSink eventSink)
          Relieve an event sink from this EventDispatcher's control.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventDispatcher

public EventDispatcher(java.lang.String eventShortClassName)
Method Detail

getEventShortClassName

public java.lang.String getEventShortClassName()
Return the short class name of the event type that is controlled by this EventDispatcher

Returns:
Short class name of the controlled event type

addSink

public void addSink(EventSink eventSink,
                    EventFilter filter)
Put the event sink and the related event filter under this EventDispatcher's control.

Parameters:
eventSink - Reference to the EventSink to add
filter - Reference to the EventFilter to add

removeSink

public boolean removeSink(EventSink eventSink)
Relieve an event sink from this EventDispatcher's control.

Parameters:
eventSink - Reference to the EventSink that shall be released.
Returns:
True if successfull, false, else

isEmpty

public boolean isEmpty()
Check whether this EventDispatcher controls any sinks.

Returns:
True if no sinks are added, false else

dispatchEvent

public void dispatchEvent(Event event)
Dispatch the given event to all registered event sinks.

Parameters:
event - Event to dispatch

informLostSource

public void informLostSource()
Inform all registered event sinks that the corresponding event source is gone.