org.springframework.extensions.surf.site
Class Timer

java.lang.Object
  extended by org.springframework.extensions.surf.site.Timer

public class Timer
extends Object

A class that provides facilities for keeping track of the rendering times of components, regions, templates and pages. The framework will call into this class when execution of said pieces. If it is not enabled, then these calls will just NOP. Otherwise, they will log using the Framework logger.

Author:
muzquiano

Field Summary
protected  List<String> keys
           
protected static org.apache.commons.logging.Log logger
           
protected  Map<String,Long> startTimes
           
protected static String TIMER_KEY
           
protected  Map<String,Long> totalTimes
           
 
Constructor Summary
Timer()
           
 
Method Summary
static void bindTimer(javax.servlet.ServletRequest request)
          Binds a timer container to the current context This must be called at the top of the request execution chain
static void bindTimer(javax.servlet.ServletRequest request, boolean forceNew)
           
static boolean isTimerEnabled()
          Determines whether the timer is enabled.
protected static void print(String value)
          Either print out to the configured Timer logger Or if they haven't set that up, just dump out to console
static void report(javax.servlet.ServletRequest request, String blockId)
          Writes to debug out the report for a single block id
static void reportAll(javax.servlet.ServletRequest request)
           
protected static boolean showMilliseconds()
           
static void start(RenderContext context, String blockId)
           
static void start(javax.servlet.ServletRequest request, String blockId)
          Begins timing for a specific block.
static void stop(RenderContext context, String blockId)
           
static void stop(javax.servlet.ServletRequest request, String blockId)
           
static void unbindTimer(javax.servlet.ServletRequest request)
          Releases the timer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TIMER_KEY

protected static String TIMER_KEY

logger

protected static org.apache.commons.logging.Log logger

totalTimes

protected Map<String,Long> totalTimes

startTimes

protected Map<String,Long> startTimes

keys

protected List<String> keys
Constructor Detail

Timer

public Timer()
Method Detail

print

protected static void print(String value)
Either print out to the configured Timer logger Or if they haven't set that up, just dump out to console


isTimerEnabled

public static boolean isTimerEnabled()
Determines whether the timer is enabled. This is controlled via the configuration file and is false by default.

Returns:
Whether the timer functionality is enabled or not

showMilliseconds

protected static boolean showMilliseconds()
Returns:
Whether to report in milliseconds (rather than nanoseconds)

bindTimer

public static void bindTimer(javax.servlet.ServletRequest request)
Binds a timer container to the current context This must be called at the top of the request execution chain

Parameters:
context - The current request context

bindTimer

public static void bindTimer(javax.servlet.ServletRequest request,
                             boolean forceNew)

unbindTimer

public static void unbindTimer(javax.servlet.ServletRequest request)
Releases the timer. This should be called at the end of the request processing chain

Parameters:
context - The current request context

start

public static void start(RenderContext context,
                         String blockId)

start

public static void start(javax.servlet.ServletRequest request,
                         String blockId)
Begins timing for a specific block. If timing has been captured previously for this block id, it will be added upon

Parameters:
context - The current request context
blockId - The unique id of the block

stop

public static void stop(RenderContext context,
                        String blockId)

stop

public static void stop(javax.servlet.ServletRequest request,
                        String blockId)

report

public static void report(javax.servlet.ServletRequest request,
                          String blockId)
Writes to debug out the report for a single block id

Parameters:
context - The current request context
blockId - The block id to report on

reportAll

public static void reportAll(javax.servlet.ServletRequest request)


Copyright © 2009 SpringSource, Inc. All Rights Reserved.