ADK CVS

tryllian.util.event
Class EventDispatcher

java.lang.Object
  extended bytryllian.util.event.EventDispatcher
All Implemented Interfaces:
java.io.Serializable

public class EventDispatcher
extends java.lang.Object
implements java.io.Serializable

A general event-registration and firing utility. It allows listeners to be added and removed during event dispatching and is thread-safe.

See Also:
Serialized Form

Constructor Summary
EventDispatcher()
          Creates a new EventDispatcher.
EventDispatcher(ExceptionHandler handler)
          Creates an EventDispatcher with an ExceptionHandler installed.
 
Method Summary
 void addListener(java.util.EventListener listener)
          Adds an object as listener.
 void fireEvent(java.util.EventObject event, EventCallback callback)
          Fires an event.
 boolean isEmpty()
          Returns true if no listeners have been registered.
 void removeAllListeners()
          Removes all listeners.
 void removeListener(java.util.EventListener listener)
          Removes an object that was previously registered as a listener from the list.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventDispatcher

public EventDispatcher()
Creates a new EventDispatcher. RuntimeExceptions are not handled. If a runtime exception occurs during event dispatching it is immediately thrown. Event dispatching stops then.


EventDispatcher

public EventDispatcher(ExceptionHandler handler)
Creates an EventDispatcher with an ExceptionHandler installed. If a runtime exception occurs during event dispatching it given to the handler. After handling, event dispatching is resumed.

Parameters:
handler - handles RuntimeExceptions
Method Detail

addListener

public void addListener(java.util.EventListener listener)
Adds an object as listener. Note that this method is not type-safe.

Parameters:
listener - the object that wants to listen to events.

removeListener

public void removeListener(java.util.EventListener listener)
Removes an object that was previously registered as a listener from the list. If it wasn't previously registered, nothing happens.

Parameters:
listener - the object that wants to stop listening

removeAllListeners

public void removeAllListeners()
Removes all listeners.


isEmpty

public boolean isEmpty()
Returns true if no listeners have been registered.


fireEvent

public void fireEvent(java.util.EventObject event,
                      EventCallback callback)
Fires an event.

Parameters:
event - the event to fire
callback - the callback that is used to fire the event

Copyright 2005, Tryllian Solutions B.V.