org.iperg.part.core
Class IpEventManager

java.lang.Object
  extended by java.lang.Thread
      extended by org.iperg.part.core.IpEventManager
All Implemented Interfaces:
java.lang.Runnable

public class IpEventManager
extends java.lang.Thread

The IpEventManager class specifies a platform manager that is responsible for dispatching events to their destinations. The platform provides a singelton event manager instance which can be retrieved using the getInstance method:

 IpEventManager mgr = IpEventManager.getInstance();

Events can be dispatched to their destinations using the dispatch method. This will cause the handleEvent method of the event handler identified by the event's destination attribute to be invoked. If the destination attribute is null, the event will be dispatched to the application's event handler set via the setEventHandler method of the IpLocalProcess singleton instance.

The event manager uses a separate dispatch thread to dispatch events to event handlers. This means that when a thread calls the dispatch method, the event is not immediately dispatched to the appropriate handler. Instead, the event is added to a queue of events managed by the event manager. Later, when the manager's dispatch thread wakes up, it removes events from the queue and deliveres them to the correct event handler.

Version:
1.0.0 Initial version
Author:
Olov Stahl - olovs@sics.se

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
 void dispatch(IpEvent event)
          Dispatch an event.
static IpEventManager getInstance()
          The main access method to retrieve the singleton event manager instance.
 void run()
          Event dispatching thread's run method.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getInstance

public static IpEventManager getInstance()
The main access method to retrieve the singleton event manager instance.

Returns:
The event manager singleton instance

dispatch

public void dispatch(IpEvent event)
Dispatch an event. Platform managers are given a chance to handle the event immediately. If no manager wish to handle the event, it is stored in the manager's event queue and will be dispatched when the manager's event dispacthing thread wakes up.

Parameters:
event - The event to be dispatched

run

public void run()
Event dispatching thread's run method. Continuously dispatches queue events to the application and also ticks platform managers.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread