Enhydra 5.1 API

org.enhydra.servlet.filter
Class PrintTransactionFilter

java.lang.Object
  |
  +--org.enhydra.servlet.filter.Filter
        |
        +--org.enhydra.servlet.filter.PrintTransactionFilter

public class PrintTransactionFilter
extends Filter

An implementation of TransactionFilter that logs everything the Servlet does to a given OutputStream. After logging, the calls are passed through.

Author:
Andy John
See Also:
org.enhydra.servlet.filter.TransactionFilter, org.enhydra.servlet.filter.WrapResult, OutputStream

Constructor Summary
PrintTransactionFilter(java.lang.String description, java.lang.String servletPrefix, java.lang.String requestPrefix, java.lang.String responsePrefix, java.io.OutputStream out, boolean logIO)
          Create a new filter.
 
Method Summary
 java.lang.String toString()
          Returns a human-readable description string.
 RequestFilter wrapRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Apply this filter to a Servlet, a request and a response.
 ResponseFilter wrapResponse(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Get the ResponseFilter for this Filter by wrapping the given Response.
 
Methods inherited from class org.enhydra.servlet.filter.Filter
getDescription, getDestroyInterceptor, getInitInterceptor, getServiceInterceptor, registerInterceptors, setDescription, setDestroyInterceptor, setInitInterceptor, setServiceInterceptor, unregisterInterceptors
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrintTransactionFilter

public PrintTransactionFilter(java.lang.String description,
                              java.lang.String servletPrefix,
                              java.lang.String requestPrefix,
                              java.lang.String responsePrefix,
                              java.io.OutputStream out,
                              boolean logIO)
Create a new filter.

Parameters:
description - A human readable description of this filter.
servletPrefix - A String to prepend to the beginning of each logging statement generated by calls to the Servlet.
requestPrefix - A String to prepend to the beginning of each logging statement generated by calls from the Servlet to the request object.
responsePrefix - A String to prepend to the beginning of each logging statement generated by calls from the Servlet to the response object.
out - Where to write the logging information to.
logIO - Should the data read from and written to the net be logged also? Can genereate large quantities of junk if images are being served.
Method Detail

wrapRequest

public RequestFilter wrapRequest(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response)
Apply this filter to a Servlet, a request and a response. Each one is wrapped with a wrapper that passes all calls through, however a log of each call made will be written to the OutputStream passed in to the constructor. The method name, the input parameters, and the results will be logged.

All logging lines will start with the appropriate prefix passed in to the constructor, with an integer appeneded. Each time wrap() is called a unique integer is appended to the prefixes, so you can tell which request's output matches with which result's output.

Overrides:
wrapRequest in class Filter
Parameters:
request - an HttpServletRequest to be wrapped by the filter.
response - an HttpServletResponse that is generally not used, but is available for request-response data coordination.
Returns:
A new Servlet, request and response, stored in a WrapResult object. Each object "wraps around" the original object.
See Also:
org.enhydra.servlet.filter.WrapResult, Servlet, HttpServletRequest, HttpServletResponse

wrapResponse

public ResponseFilter wrapResponse(javax.servlet.http.HttpServletRequest request,
                                   javax.servlet.http.HttpServletResponse response)
Description copied from class: Filter
Get the ResponseFilter for this Filter by wrapping the given Response.

Specified by:
wrapResponse in class Filter
Parameters:
request - an HttpServletRequest that is generally not used, but is available for request-response data coordination.
response - an HttpServletResponse to be wrapped by the filter.
Returns:
a ResponseFilter

toString

public java.lang.String toString()
Returns a human-readable description string. It returns the same string passed in to the constructor.

Overrides:
toString in class Filter
Returns:
A description of this filter.

Enhydra 5.1 API