atg.service.queue
Class EventQueue

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.service.queue.EventQueue
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
DataCollectorQueue, DataListenerQueue, EmailListenerQueue, LogListenerQueue

public abstract class EventQueue
extends GenericService

This is the base class for objects that queue up method calls. This will allow multiple Threads to read from the queue.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
EventQueue()
          Constructs a new EventQueue
 
Method Summary
protected  void addElement()
          Notifies the Queue that the head of the queue has been filled in and added to the queue.
protected abstract  EventQueueElement createElement()
          Constructs a new blank EventQueueElement.
protected abstract  void dispatchElement(EventQueueElement pElem)
          Dispatches a Queue element to be handled.
protected  void dispatchQueueElements()
          This will read and dispatch elements from the Queue in a loop until the service is stopped.
 void doStartService()
          Initializes the service by creating the queue (if it hasn't already been created).
 void doStopService()
          This will shut down the threads reading from the Queue.
 void flushQueue()
          Flush the queue.
protected  boolean getElement(EventQueueElement pElement)
          Reads one element from the queue, copies the element to the specified element, and clears the element.
 int getInitialCapacity()
          Returns the initial capacity of the queue as expressed as the number of elements.
 int getQueuedEventCount()
          Returns the total number of events that were added to the queue
protected  EventQueueElement getQueueHead()
          Returns a pointer to the next element in the queue that will be written.
 int getQueueSize()
          Returns the number of events currently in the queue waiting to be sent to their desintations.
 int getThreadCount()
          Returns the number Threads that will be reading and dispatching from the queue.
 javax.transaction.TransactionManager getTransactionManager()
           
 boolean getTransactionsEnabled()
           
protected  void handleDispatchError(java.lang.Throwable pThrowable)
          This is called when an exception is thrown while dispatching from the queue.
 EventQueueElement[] listQueuedElements()
          Creates and returns a new array containing references to all the elements in the Queue, in the order that they were inserted.
 void setInitialCapacity(int pInitialCapacity)
          Sets the initial capacity of the queue as expressed as the number of elements.
 void setThreadCount(int pThreadCount)
          Sets the number Threads that will be reading and dispatching from the queue.
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
           
 void setTransactionsEnabled(boolean pTransactionsEnabled)
           
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

EventQueue

public EventQueue()
Constructs a new EventQueue

Method Detail

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)

getTransactionsEnabled

public boolean getTransactionsEnabled()

setTransactionsEnabled

public void setTransactionsEnabled(boolean pTransactionsEnabled)

createElement

protected abstract EventQueueElement createElement()
Constructs a new blank EventQueueElement. Subclasses must implement this method.


dispatchElement

protected abstract void dispatchElement(EventQueueElement pElem)
Dispatches a Queue element to be handled. Subclasses must implement this method.


getQueueHead

protected EventQueueElement getQueueHead()
Returns a pointer to the next element in the queue that will be written. This will resize the queue and create new elements if necessary.


addElement

protected void addElement()
Notifies the Queue that the head of the queue has been filled in and added to the queue.


getElement

protected boolean getElement(EventQueueElement pElement)
Reads one element from the queue, copies the element to the specified element, and clears the element. This will block until an element becomes available.

Returns:
true if successful, false if the Queue was stopped

flushQueue

public void flushQueue()
Flush the queue. This method simply waits until the queue is empty.


dispatchQueueElements

protected void dispatchQueueElements()
This will read and dispatch elements from the Queue in a loop until the service is stopped.


handleDispatchError

protected void handleDispatchError(java.lang.Throwable pThrowable)
This is called when an exception is thrown while dispatching from the queue.


listQueuedElements

public EventQueueElement[] listQueuedElements()
Creates and returns a new array containing references to all the elements in the Queue, in the order that they were inserted.


setInitialCapacity

public void setInitialCapacity(int pInitialCapacity)
Sets the initial capacity of the queue as expressed as the number of elements. The queue will resize automatically if necessary.


getInitialCapacity

public int getInitialCapacity()
Returns the initial capacity of the queue as expressed as the number of elements. The queue will resize automatically if necessary.


setThreadCount

public void setThreadCount(int pThreadCount)
Sets the number Threads that will be reading and dispatching from the queue.


getThreadCount

public int getThreadCount()
Returns the number Threads that will be reading and dispatching from the queue.


getQueueSize

public int getQueueSize()
Returns the number of events currently in the queue waiting to be sent to their desintations.


getQueuedEventCount

public int getQueuedEventCount()
Returns the total number of events that were added to the queue


doStartService

public void doStartService()
Initializes the service by creating the queue (if it hasn't already been created). Starts the Threads that read from the queue.

Overrides:
doStartService in class GenericService

doStopService

public void doStopService()
This will shut down the threads reading from the Queue.

Overrides:
doStopService in class GenericService