Enhydra 5.1 API

org.enhydra.servlet.debug
Class DebugManager

java.lang.Object
  |
  +--org.enhydra.servlet.debug.DebugManager

public class DebugManager
extends java.lang.Object

Servlet debug manager for monitoring servlet I/O. An instance of this object monitors a single servlet instance. A fixed-sized queue of servlet transaction records is maintained. As a transaction is completed by the servlet, a record is added to the end of the queue. If the queue has reached its maximum size, an element is removed from the head of the queue. Applications wishing to monitor servlet transactions registers with this object and is called when objects are added or removed from the queue. Calling on removal is necessary as one of the main goals of this class is to support presentations that display a list of transaction records. A unique id number is associated with each transaction record. The transaction record ids are sequencially allocated, one with a large number occured after one with a smaller number.

Since:
2.0
Version:
$Revision: 1.1 $
Author:
Mark Diekhans

Field Summary
protected  ServletRecordQueue recordQueue
          Queue of transaction records.
 
Constructor Summary
DebugManager(java.lang.String servletId, int queueSize, boolean saveResponseData)
          Construct an new servlet debug manager and associate it with a servlet.
 
Method Summary
 void addTransactionCallback(ServletRecordCallback callback, boolean catchUp)
          Registered to be called when a servlet transaction is queued.
protected  void addTransactionRecord(ServletTransactionRecord transactionRecord)
          Add a servlet transaction to the end of the queue.
 void clearRecordQueue()
          Clear all records from the queue.
 void disable()
          Disable recording servlet transactions.
 void enable()
          Enable recording servlet transactions.
 java.lang.String getServlet()
          Get the servlet associated with this object.
 ServletTransactionRecord getTransactionRecord(int transactionId)
          Find a servlet transaction record by id.
 boolean isEnabled()
          Determine if servlets monitoring is enabled.
 void removeTranactionCallback(ServletRecordCallback callback)
          Remove transaction callback that was created with addTransactionCallback.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

recordQueue

protected ServletRecordQueue recordQueue
Queue of transaction records. This is protected so that subclasses may access the queue.

Constructor Detail

DebugManager

public DebugManager(java.lang.String servletId,
                    int queueSize,
                    boolean saveResponseData)
Construct an new servlet debug manager and associate it with a servlet. Servlet monitoring is initially disabled.

Parameters:
servletId - symbolic servlet identifier of the servlet to manage.
queueSize - maximum number of servlet transaction records that can be queued at a given time.
saveResponseData - Should we save a copy of the data written to the socket for each transaction? Could use up alot of memory.
Method Detail

enable

public void enable()
            throws ConnectionMethodException
Enable recording servlet transactions. This adds a filter to the filter manager, and then adds the filter to all channels that map to the servlet.

Throws:
ConnectionMethodException - If there is an error getting the connection methods and channels, or adding the filter.

disable

public void disable()
             throws ConnectionMethodException
Disable recording servlet transactions. This removes the filter from all the channels, then removes the filter from the filter manager.

Throws:
ConnectionMethodException - If there is an error getting the connection methods and channels, or adding the filter.

isEnabled

public boolean isEnabled()
Determine if servlets monitoring is enabled.

Returns:
true if enabled, false if disabled.

getServlet

public java.lang.String getServlet()
Get the servlet associated with this object.

Returns:
the servlet id.

addTransactionCallback

public void addTransactionCallback(ServletRecordCallback callback,
                                   boolean catchUp)
Registered to be called when a servlet transaction is queued.

Parameters:
callback - The object to invoke when a transaction object is available.
catchUp - Pass in true if you want an initial series of transactionRecordAddEvent() calls, reflecting the current set of transactions stored in the queue. Wanring: if this is set to true, and there are transactions in the queue, then transactionRecordAddEvent() will be called before this function returns.

removeTranactionCallback

public void removeTranactionCallback(ServletRecordCallback callback)
Remove transaction callback that was created with addTransactionCallback.

Parameters:
callback - object to delete from callback list.

getTransactionRecord

public ServletTransactionRecord getTransactionRecord(int transactionId)
Find a servlet transaction record by id.

Parameters:
transactionId - unique number identifying the desired transaction record.
Returns:
a transaction record or null if the transaction is no longer in the queue.

addTransactionRecord

protected void addTransactionRecord(ServletTransactionRecord transactionRecord)
Add a servlet transaction to the end of the queue. Use by the servlet filters.

Parameters:
transactionRecord - the record to add to the queue.

clearRecordQueue

public void clearRecordQueue()
Clear all records from the queue.


Enhydra 5.1 API