org.apache.wicket.protocol.http
Class AbstractRequestLogger

java.lang.Object
  extended by org.apache.wicket.protocol.http.AbstractRequestLogger
All Implemented Interfaces:
IRequestLogger
Direct Known Subclasses:
RequestLogger

public abstract class AbstractRequestLogger
extends java.lang.Object
implements IRequestLogger

Base class that collects request and session information for request logging to enable rich information about the events that transpired during a single request. Typical HTTPD and/or Servlet container log files are unusable for determining what happened in the application since they contain the requested URLs of the form http://example.com/app?wicket:interface:0:0:0, which doesn't convey any useful information. Requestloggers can show which page was the target of the request, and which page was rendered as a response, and anything else: resources, Ajax request, etc.

The information in the log files can take any format, depending on the request logger implementation: currently Wicket supports two formats: a legacy, log4j compatible format, and a JSON format.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.wicket.protocol.http.IRequestLogger
IRequestLogger.ISessionLogInfo, IRequestLogger.RequestData, IRequestLogger.SessionData
 
Constructor Summary
AbstractRequestLogger()
          Construct.
 
Method Summary
protected  void addRequest(IRequestLogger.RequestData rd)
           
protected static java.lang.String formatDate(java.util.Date date)
          Thread-safely formats the passed date in format 'yyyy-MM-dd hh:mm:ss,SSS' with GMT timezone
 long getAverageRequestTime()
           
 int getCurrentActiveRequestCount()
           
protected  IRequestLogger.RequestData getCurrentRequest()
           
 IRequestLogger.SessionData[] getLiveSessions()
           
 int getPeakActiveRequestCount()
           
 int getPeakSessions()
           
 java.util.List<IRequestLogger.RequestData> getRequests()
          This method returns a List of the current requests that are in mem.
 long getRequestsPerMinute()
           
 int getTotalCreatedSessions()
           
protected abstract  void log(IRequestLogger.RequestData rd, IRequestLogger.SessionData sd)
           
 void logEventTarget(IRequestHandler requestHandler)
          Sets the target that was the event target for the current request
 void logRequestedUrl(java.lang.String url)
          Logs the URL that was requested by the browser.
 void logResponseTarget(IRequestHandler requestHandler)
          Sets the target that was the response target for the current request
 void objectCreated(java.lang.Object value)
          Called to monitor additions of objects in the ISessionStore
 void objectRemoved(java.lang.Object value)
          Called to monitor removals of objects out of the ISessionStore
 void objectUpdated(java.lang.Object value)
          Called to monitor updates of objects in the ISessionStore
 void requestTime(long timeTaken)
          This method is called when the request is over.
 void sessionCreated(java.lang.String sessionId)
          called when the session is created and has an id.
 void sessionDestroyed(java.lang.String sessionId)
          Method used to cleanup a livesession when the session was invalidated by the webcontainer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRequestLogger

public AbstractRequestLogger()
Construct.

Method Detail

getCurrentActiveRequestCount

public int getCurrentActiveRequestCount()
Specified by:
getCurrentActiveRequestCount in interface IRequestLogger
Returns:
The current active requests

getPeakActiveRequestCount

public int getPeakActiveRequestCount()
Specified by:
getPeakActiveRequestCount in interface IRequestLogger
Returns:
The peak active requests

getLiveSessions

public IRequestLogger.SessionData[] getLiveSessions()
Specified by:
getLiveSessions in interface IRequestLogger
Returns:
Collection of live Sessions Data

getPeakSessions

public int getPeakSessions()
Specified by:
getPeakSessions in interface IRequestLogger
Returns:
The peak sessions counter

getRequests

public java.util.List<IRequestLogger.RequestData> getRequests()
Description copied from interface: IRequestLogger
This method returns a List of the current requests that are in mem. This is a readonly list.

Specified by:
getRequests in interface IRequestLogger
Returns:
Collection of the current requests

getTotalCreatedSessions

public int getTotalCreatedSessions()
Specified by:
getTotalCreatedSessions in interface IRequestLogger
Returns:
The total created sessions counter

objectCreated

public void objectCreated(java.lang.Object value)
Description copied from interface: IRequestLogger
Called to monitor additions of objects in the ISessionStore

Specified by:
objectCreated in interface IRequestLogger
Parameters:
value - the object being created/added

objectRemoved

public void objectRemoved(java.lang.Object value)
Description copied from interface: IRequestLogger
Called to monitor removals of objects out of the ISessionStore

Specified by:
objectRemoved in interface IRequestLogger
Parameters:
value - the object being removed

objectUpdated

public void objectUpdated(java.lang.Object value)
Description copied from interface: IRequestLogger
Called to monitor updates of objects in the ISessionStore

Specified by:
objectUpdated in interface IRequestLogger
Parameters:
value - the object being updated

requestTime

public void requestTime(long timeTaken)
Description copied from interface: IRequestLogger
This method is called when the request is over. This will set the total time a request takes and cleans up the current request data.

Specified by:
requestTime in interface IRequestLogger
Parameters:
timeTaken - the time taken in milliseconds

sessionCreated

public void sessionCreated(java.lang.String sessionId)
Description copied from interface: IRequestLogger
called when the session is created and has an id. (for http it means that the http session is created)

Specified by:
sessionCreated in interface IRequestLogger
Parameters:
sessionId - the session id

sessionDestroyed

public void sessionDestroyed(java.lang.String sessionId)
Description copied from interface: IRequestLogger
Method used to cleanup a livesession when the session was invalidated by the webcontainer

Specified by:
sessionDestroyed in interface IRequestLogger
Parameters:
sessionId - the session id

getCurrentRequest

protected IRequestLogger.RequestData getCurrentRequest()

log

protected abstract void log(IRequestLogger.RequestData rd,
                            IRequestLogger.SessionData sd)

addRequest

protected void addRequest(IRequestLogger.RequestData rd)

getAverageRequestTime

public long getAverageRequestTime()
Specified by:
getAverageRequestTime in interface IRequestLogger
Returns:
The average request time.

getRequestsPerMinute

public long getRequestsPerMinute()
Specified by:
getRequestsPerMinute in interface IRequestLogger
Returns:
The number of requests per minute.

logEventTarget

public void logEventTarget(IRequestHandler requestHandler)
Description copied from interface: IRequestLogger
Sets the target that was the event target for the current request

Specified by:
logEventTarget in interface IRequestLogger
Parameters:
requestHandler - the event target

logRequestedUrl

public void logRequestedUrl(java.lang.String url)
Description copied from interface: IRequestLogger
Logs the URL that was requested by the browser.

Specified by:
logRequestedUrl in interface IRequestLogger
Parameters:
url - the requested URL

logResponseTarget

public void logResponseTarget(IRequestHandler requestHandler)
Description copied from interface: IRequestLogger
Sets the target that was the response target for the current request

Specified by:
logResponseTarget in interface IRequestLogger
Parameters:
requestHandler - the response target

formatDate

protected static java.lang.String formatDate(java.util.Date date)
Thread-safely formats the passed date in format 'yyyy-MM-dd hh:mm:ss,SSS' with GMT timezone

Parameters:
date - the date to format
Returns:
the formatted date


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.