com.tivoli.twg.libs
Class QueueBatch

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

public class QueueBatch
extends java.lang.Object

QueueBatch 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.


Nested Class Summary
 class QueueBatch.QueueServer
           
 
Constructor Summary
QueueBatch()
          Constructor for QueueBatch.
QueueBatch(java.lang.String qName)
          Constructor for QueueBatch.
QueueBatch(java.lang.String qName, int threadCount)
          Constructor for QueueBatch.
QueueBatch(java.lang.String qName, int threadCount, boolean on_demand)
          Constructor for QueueBatch.
QueueBatch(java.lang.String qName, int threadCount, boolean on_demand, int idle_time)
          Constructor for QueueBatch.
QueueBatch(java.lang.String qName, int threadCount, boolean on_demand, int idle_time, int threadPriority)
          Constructor for QueueBatch.
 
Method Summary
 void decQueuedCount()
          Decrement the queued count with synchronized protection.
 long elements()
          Return number of elements on queue.
 void enqueue(QueueElement element)
          This method adds a QueueElement to QueueBatch's queue.
 void finalize()
          finalize method to clean up when things are done
 long getQueuedCount()
          Decrement the queued count with synchronized protection.
 int getThreadPriority()
          Return the current thread priority for all of our threads.
 void incQueuedCount()
          Increment the queued count with synchronized protection.
 boolean remove(QueueElement element)
          This method removes the specified QueueElement from the queue.
 void setCatchProcessingExceptions(boolean b)
          finalize method to clean up when things are done
 void setThreadPriority(int priority)
          Change the thread priority for all of our threads.
 void waitForIdle()
          Wait for the queue to be done processing all elements.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueueBatch

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


QueueBatch

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

Parameters:
qName - String used to label the single worker thread.

QueueBatch

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

Parameters:
qName - String used to label each worker thread.
threadCount - Number of worker threads to create. One is substituted if threadCount <= 0.

QueueBatch

public QueueBatch(java.lang.String qName,
                  int threadCount,
                  boolean on_demand)
Constructor for QueueBatch.

Parameters:
qName - String used to label each worker thread.
threadCount - Number of worker threads to create. One is substituted if threadCount <= 0.
on_demand - if threads should be created and deleted on demand

QueueBatch

public QueueBatch(java.lang.String qName,
                  int threadCount,
                  boolean on_demand,
                  int idle_time)
Constructor for QueueBatch.

Parameters:
qName - String used to label each worker thread.
threadCount - Number of worker threads to create. One is substituted if threadCount <= 0.
on_demand - if threads should be created and deleted on demand
idle_time - idle wait time before threads die (msec)

QueueBatch

public QueueBatch(java.lang.String qName,
                  int threadCount,
                  boolean on_demand,
                  int idle_time,
                  int threadPriority)
Constructor for QueueBatch.

Parameters:
qName - String used to label each worker thread.
threadCount - Number of worker threads to create. One is substituted if threadCount <= 0.
on_demand - if threads should be created and deleted on demand
idle_time - idle wait time before threads die (msec)
threadPriority - Priority of worker theads.
Throws:
java.lang.IllegalArgumentException - If the priority is not in the range MIN_PRIORITY to MAX_PRIORITY.
Method Detail

setCatchProcessingExceptions

public void setCatchProcessingExceptions(boolean b)
finalize method to clean up when things are done


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)
This method adds a QueueElement to QueueBatch's queue. The new element is placed in the queue in FIFO order.

Parameters:
element - QueueElement object to be added to the queue.

remove

public boolean remove(QueueElement element)
This method removes the specified QueueElement from the queue. If multiple like elements are enqueued, only the oldest element element is removed.

Parameters:
element - QueueElement object to be removed from the queue.
Returns:
TRUE: object was found and removed. FALSE: Object was not found.

incQueuedCount

public void incQueuedCount()
Increment the queued count with synchronized protection.


decQueuedCount

public void decQueuedCount()
Decrement the queued count with synchronized protection.


getQueuedCount

public long getQueuedCount()
Decrement the queued count with synchronized protection.

Returns:
current number of queued elements

waitForIdle

public void waitForIdle()
Wait for the queue to be done processing all elements.


setThreadPriority

public void setThreadPriority(int priority)
Change the thread priority for all of our threads.

Parameters:
priority - Thread priority to set the threads to, between MIN_PRIORITY and MAX_PRIORITY, inclusively.

getThreadPriority

public int getThreadPriority()
Return the current thread priority for all of our threads.


elements

public long elements()
Return number of elements on queue.