org.jboss.jsfunit.framework
Class JSFTimer

java.lang.Object
  extended by org.jboss.jsfunit.framework.JSFTimer

public class JSFTimer
extends Object

The JSFTimer collects performance data during a JSF request. It tracks the time for each phase in the JSF Lifecycle and remains accurate even when phases are skipped. To use this class you just need to get the instance with the static getTimer() method. The instance is held in the session. Statistics are reset at the beginning of each JSF request. So you can use this class during the JSF lifecycle or afterwards in a JSFUnit test. To use this class, you must enable the JSFTimerPhaseListener in faces-config.xml.

Since:
1.0
Author:
Stan Silvert
See Also:
JSFTimerPhaseListener

Field Summary
static String REQUEST_KEY
           
 
Method Summary
 long getPhaseTime(javax.faces.event.PhaseId phaseId)
          Returns the amount of time spent during a JSF phase.
static JSFTimer getTimer()
          Get a reference to the JSFTimer.
 long getTotalTime()
          Returns the total time spent in the JSF lifecycle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REQUEST_KEY

public static final String REQUEST_KEY
Method Detail

getTimer

public static JSFTimer getTimer()
Get a reference to the JSFTimer.

Returns:
The JSFTimer.
Throws:
IllegalStateException - If no JSF requests have been made on this session.

getTotalTime

public long getTotalTime()
Returns the total time spent in the JSF lifecycle.

Returns:
The total time in milliseconds. Returns -1 if no phase has been completed.

getPhaseTime

public long getPhaseTime(javax.faces.event.PhaseId phaseId)
Returns the amount of time spent during a JSF phase.

Parameters:
phaseId - The PhaseId.
Returns:
The time in milliseconds, or zero if the phase has not run.
Throws:
IllegalArgumentException - if the phaseId is ANY_PHASE.


Copyright © 2007-2010 JBoss, a division of Red Hat, Inc.. All Rights Reserved.