com.tivoli.twg.libs
Class QueueTimer

java.lang.Object
  extended bycom.tivoli.twg.libs.QueueTimer

public class QueueTimer
extends java.lang.Object

QueueTimer is a class that allows objects that have implemented the "QueueElement" interface to be enqueued based on the time of day. Items on the queue will be "run" when the process's time of day has passed the time of day marked in the enqueued element. The enqueued element must implement a "process" method as described by the "QueueElement" interface. A QueueTimer instance can be constructed with one or more worker threads. The default constructor will create one worker thread.


Constructor Summary
QueueTimer()
          Constructor for QueueTimer.
QueueTimer(java.lang.String qName)
          Constructor for QueueTimer.
QueueTimer(java.lang.String qName, int threadCount)
          Constructor for QueueTimer.
 
Method Summary
 void enqueue(QueueElement element, java.util.Date tod)
          This method adds a QueueElement to QueueTimer's queue.
 void enqueue(QueueElement element, long tod)
          This method adds a QueueElement to QueueTimer's queue.
 void enqueue(QueueElement element, long tod, boolean realTime)
          This method adds a QueueElement to QueueTimer's queue.
 void finalize()
          finalize method to clean up when things are done
 boolean remove(QueueElement element)
          This method removes a QueueElement from the QueueTimer's queue.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueueTimer

public QueueTimer()
Constructor for QueueTimer. This default constructor allocates one worker thread and assigns a generic queue name.


QueueTimer

public QueueTimer(java.lang.String qName)
Constructor for QueueTimer. This default constructor allocates one worker thread.


QueueTimer

public QueueTimer(java.lang.String qName,
                  int threadCount)
Constructor for QueueTimer.

Method Detail

finalize

public void finalize()
              throws java.lang.Throwable
finalize method to clean up when things are done

Throws:
java.lang.Throwable

enqueue

public void enqueue(QueueElement element,
                    long tod,
                    boolean realTime)
This method adds a QueueElement to QueueTimer's queue. The new element is placed in the queue sorted by wake up time/date.

Parameters:
element - QueueElement object to be added to the queue.
tod - The time/date of day when the element's "process" method is to be called.
realTime - TRUE : specified time is actual time/date in mSec the element is to be processed. FALSE: the specified time is the number of mSec from the current time the element is to be processed.

enqueue

public void enqueue(QueueElement element,
                    java.util.Date tod)
This method adds a QueueElement to QueueTimer's queue. The new element is placed in the queue sorted by wake up time/date.

Parameters:
element - QueueElement object to be added to the queue.
tod - Date object representing absolute time/date the element is to be popped.

enqueue

public void enqueue(QueueElement element,
                    long tod)
This method adds a QueueElement to QueueTimer's queue. The new element is placed in the queue sorted by wake up time/date.

Parameters:
element - QueueElement object to be added to the queue.
tod - The time/date of day when the element's "process" method is to be called.

remove

public boolean remove(QueueElement element)
This method removes a QueueElement from the QueueTimer's queue. If the object has been enqueued more than once, the object closest to the head of the queue will be removed.

Parameters:
element - QueueElement object to be removed.
Returns:
TRUE: element was found and removed. FALSE: element was not found in list.