net.chaosserver.jtunes.event
Class JTunesApplicationEventHandler

java.lang.Object
  |
  +--net.chaosserver.jtunes.event.JTunesApplicationEventHandler

public class JTunesApplicationEventHandler
extends Object

Main application EventHandler and bus. This class follows the singleton pattern as there is only one in the system. Application events are fired into the handler and it will distribute all to all registered listeners in the same thread.


Field Summary
protected  Set applicationEventListeners
          Holds a set of all listeners to the application.
 
Method Summary
 void addJTunesApplicationEventListener(JTunesApplicationEventListener applicationEventListener)
          Adds an application listener to the system.
static JTunesApplicationEventHandler create()
          Creates the event handler.
 void fireEvent(JTunesApplicationEvent evt)
          Fires an event to all of the listeners in the current thread.
static JTunesApplicationEventHandler getInstance()
          Gets the singleton instance of the JTunesApplicationEventHandler.
 Set getJTunesApplicationEventListeners()
          Gets the set of all JTunesApplicationEventListeners in the system.
 void removeJTunesApplicationEventListener(JTunesApplicationEventListener applicationEventListener)
          Removes an application listener from the handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

applicationEventListeners

protected Set applicationEventListeners
Holds a set of all listeners to the application.

Method Detail

create

public static JTunesApplicationEventHandler create()
Creates the event handler. This method should be called once at the launch of the application. It is used to remove a synchronized check on each call to the getInstance() method.

Returns:
the newly created instance of the JTunesApplicationEventHandler

getInstance

public static JTunesApplicationEventHandler getInstance()
Gets the singleton instance of the JTunesApplicationEventHandler.

Returns:
the singleton instance of the JTunesApplicationEventHandler

fireEvent

public void fireEvent(JTunesApplicationEvent evt)
Fires an event to all of the listeners in the current thread. This method will return when all listeners have been notified and take action.

Parameters:
evt - the event to fire

addJTunesApplicationEventListener

public void addJTunesApplicationEventListener(JTunesApplicationEventListener applicationEventListener)
Adds an application listener to the system.

Parameters:
applicationEventListener - the listener to add

getJTunesApplicationEventListeners

public Set getJTunesApplicationEventListeners()
Gets the set of all JTunesApplicationEventListeners in the system.

Returns:
the set of all JTunesApplicationEventListener in the system

removeJTunesApplicationEventListener

public void removeJTunesApplicationEventListener(JTunesApplicationEventListener applicationEventListener)
Removes an application listener from the handler.

Parameters:
applicationEventListener - listener to remove


Copyright ?? 20030801