atg.nucleus.logging
Class QueueingLogger

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.nucleus.logging.QueueingLogger
All Implemented Interfaces:
atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, LogListener, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class QueueingLogger
extends GenericService
implements LogListener

The QueueingLogger is made to sit on top of a single LogListener, queueing log events so they don't actually get written out to the LogListener until a more convenient time. This is done by putting the log events into a GovernorQueue. A single underlying LogListener for writing queued log events is used instead of using the list of LogListeners added via the addLogEventListener() method because QueueingLogger messages may not necessarily want to be written directly out, but queued as well. Adding a QueueingLogger to it's own list of log event listeners is a valid (and probably desirous) configuration. For convenient's sake, the QueueingLogger also has a switch for turning the queue on and off. When off, the log events will be written straight through to the underlying LogListener, bypassing the queue.

See Also:
GovernorQueue

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 LogListener mFinalLogListener
          The underlying LogListener.
 LoggingQueue mQueue
          The logging queue.
 boolean mQueueing
          Whether or not log events should be queued.
 int mQueueMaxNormalSize
          The queue size threshold at which the thread ceases to run at its normal priority and becomes active.
 int mQueueMinActiveSize
          The queue size threshold at which the thread ceases to be active.
 
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
QueueingLogger()
          Constructs an uninitialized QueueingLogger.
 
Method Summary
 void doStartService()
          This is called after the service has been created, added to the Registry, and configured.
 void doStopService()
          This is called when the service is to be stopped.
 LogListener getFinalLogListener()
          Returns the underlying LogListener to which queued log events are being written to.
 boolean getQueueing()
          Returns whether queueing on or off.
 int getQueueMaxNormalSize()
          Returns the queue size threshold at which the thread ceases to run at its normal priority and becomes active.
 int getQueueMinActiveSize()
          Returns the queue size threshold at which the thread ceases to be active.
 void logEvent(LogEvent pLogEvent)
          Logs the given log event.
 void setFinalLogListener(LogListener pLogListener)
          Sets the underlying LogListener to which queued log events will be written to.
 void setQueueing(boolean pQueueing)
          Turn queueing on or off.
 void setQueueMaxNormalSize(int pQueueMaxNormalSize)
          Sets the queue size threshold at which the thread ceases to run at its normal priority and becomes active.
 void setQueueMinActiveSize(int pQueueMinActiveSize)
          Sets the queue size threshold at which the thread ceases to be active.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, 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, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, 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


mQueueing

public boolean mQueueing
Whether or not log events should be queued.


mQueueMinActiveSize

public int mQueueMinActiveSize
The queue size threshold at which the thread ceases to be active.


mQueueMaxNormalSize

public int mQueueMaxNormalSize
The queue size threshold at which the thread ceases to run at its normal priority and becomes active.


mFinalLogListener

public LogListener mFinalLogListener
The underlying LogListener.


mQueue

public LoggingQueue mQueue
The logging queue.

Constructor Detail

QueueingLogger

public QueueingLogger()
Constructs an uninitialized QueueingLogger.

Method Detail

setQueueing

public void setQueueing(boolean pQueueing)
Turn queueing on or off. A value of true turns queueing on. A value of false turns queueing off. When turning off, messages already in the queue will be flushed from the queue (written out).

Parameters:
pQueueing - flag if queuing is on

setQueueMinActiveSize

public void setQueueMinActiveSize(int pQueueMinActiveSize)
Sets the queue size threshold at which the thread ceases to be active.

Parameters:
pQueueMinActiveSize - the minimum threshhold

setQueueMaxNormalSize

public void setQueueMaxNormalSize(int pQueueMaxNormalSize)
Sets the queue size threshold at which the thread ceases to run at its normal priority and becomes active.

Parameters:
pQueueMaxNormalSize - the maximum threshhold

setFinalLogListener

public void setFinalLogListener(LogListener pLogListener)
Sets the underlying LogListener to which queued log events will be written to.

Parameters:
pLogListener - the log listener

getQueueing

public boolean getQueueing()
Returns whether queueing on or off.

Returns:
boolean true if queueing is on
false if queueing is off

getQueueMinActiveSize

public int getQueueMinActiveSize()
Returns the queue size threshold at which the thread ceases to be active.

Returns:
int

getQueueMaxNormalSize

public int getQueueMaxNormalSize()
Returns the queue size threshold at which the thread ceases to run at its normal priority and becomes active.

Returns:
int

getFinalLogListener

public LogListener getFinalLogListener()
Returns the underlying LogListener to which queued log events are being written to.


doStartService

public void doStartService()
                    throws ServiceException
This is called after the service has been created, added to the Registry, and configured. This method should start any processes required to run the service.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if an error occurred during the operation

doStopService

public void doStopService()
                   throws ServiceException
This is called when the service is to be stopped. The service should stop any processes that it started, basically performing the opposite function as startService(). The service should also release any resources it has. After this method is called, Nucleus may choose to discard the service.

Overrides:
doStopService in class GenericService
Throws:
ServiceException - if an error occurred during the operation

logEvent

public void logEvent(LogEvent pLogEvent)
Logs the given log event. The log event gets added to a queue for writing out at a convenient time.

Specified by:
logEvent in interface LogListener
Parameters:
pLogEvent - the log event