fipaos.util
Class Monitor

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--fipaos.util.Monitor
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
MultiThreadedMonitor

public class Monitor
extends java.lang.Thread

This class provides a generic mechanism for forwarding objects from one thread to another in order to decouple parts of a system. A Queue must be passed to a Monitor upon construction, and it monitors this for objects to forward. When there is an object in the queue it is passed to the MonitorListener registered with the Monitor


Inner Class Summary
protected static class Monitor.MonitorListenerTest
           
 
Field Summary
protected  MonitorListener _target
          The target MonitorListener
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Monitor(Queue queue, MonitorListener ml)
          Constructor - starts threads running
Monitor(Queue queue, MonitorListener ml, int priority)
          Constructor - starts threads running
 
Method Summary
 void halt()
          Invoked when this should exit cleanly
static void main(java.lang.String[] args)
          Test harness for Monitor class
 void run()
          Run method - continuously checks for incomming messages, and passes them on to the MonitorListener implementations associated with this
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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
 

Field Detail

_target

protected MonitorListener _target
The target MonitorListener
Constructor Detail

Monitor

public Monitor(Queue queue,
               MonitorListener ml)
Constructor - starts threads running
Parameters:
queue - The queue that should be used for buffering waiting objects
ml - The MonitorListener to forward objects to

Monitor

public Monitor(Queue queue,
               MonitorListener ml,
               int priority)
Constructor - starts threads running
Parameters:
queue - The queue that should be used for buffering waiting objects
ml - The MonitorListener to forward objects to
Method Detail

run

public void run()
Run method - continuously checks for incomming messages, and passes them on to the MonitorListener implementations associated with this
Overrides:
run in class java.lang.Thread

halt

public void halt()
Invoked when this should exit cleanly

main

public static void main(java.lang.String[] args)
Test harness for Monitor class