org.javasimon.spring.webmvc
Class MonitoringHandlerInterceptor

java.lang.Object
  extended by org.javasimon.spring.webmvc.MonitoringHandlerInterceptor
All Implemented Interfaces:
org.springframework.web.servlet.HandlerInterceptor

public class MonitoringHandlerInterceptor
extends Object
implements org.springframework.web.servlet.HandlerInterceptor

Spring MVC interceptor monitors time spent in handlers (usually controllers) and views. Spring configuration:

<mvc:interceptors>
    <bean class="org.javasimon.spring.webmvc.MonitoringHandlerInterceptor"/>
 </mvc:interceptors>
 

Since:
Spring 3.1
Author:
gquintana

Field Summary
private  StopwatchSource<HandlerLocation> stopwatchSource
          Stopwatch source.
private  ThreadLocal<HandlerLocation> threadLocation
          Current thread running split, if any.
 
Constructor Summary
MonitoringHandlerInterceptor()
          Default constructor: default stopwatch source, default manager.
MonitoringHandlerInterceptor(Manager manager)
          Constructor with simon manager and default stopwatch source.
MonitoringHandlerInterceptor(StopwatchSource<HandlerLocation> stopwatchSource)
          Constructor with stopwatch source.
 
Method Summary
 void afterCompletion(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler, Exception ex)
          Invoked after view.
 void postHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler, org.springframework.web.servlet.ModelAndView modelAndView)
          Invoked between controller and view.
 boolean preHandle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Object handler)
          Invoked before controller.
protected  Split startStopwatch(HandlerLocation location)
          Start stopwatch for given name and thread.
protected  Split stopStopwatch()
          Stop current thread stopwatch (if any).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

threadLocation

private final ThreadLocal<HandlerLocation> threadLocation
Current thread running split, if any.


stopwatchSource

private StopwatchSource<HandlerLocation> stopwatchSource
Stopwatch source.

Constructor Detail

MonitoringHandlerInterceptor

public MonitoringHandlerInterceptor(StopwatchSource<HandlerLocation> stopwatchSource)
Constructor with stopwatch source.

Parameters:
stopwatchSource - Stopwatch source

MonitoringHandlerInterceptor

public MonitoringHandlerInterceptor(Manager manager)
Constructor with simon manager and default stopwatch source.

Parameters:
manager - Manager manager

MonitoringHandlerInterceptor

public MonitoringHandlerInterceptor()
Default constructor: default stopwatch source, default manager.

Method Detail

startStopwatch

protected final Split startStopwatch(HandlerLocation location)
Start stopwatch for given name and thread.

Returns:
Running split

stopStopwatch

protected final Split stopStopwatch()
Stop current thread stopwatch (if any).

Returns:
Stopped split

preHandle

public boolean preHandle(javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response,
                         Object handler)
Invoked before controller.

Specified by:
preHandle in interface org.springframework.web.servlet.HandlerInterceptor

postHandle

public void postHandle(javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response,
                       Object handler,
                       org.springframework.web.servlet.ModelAndView modelAndView)
Invoked between controller and view.

Specified by:
postHandle in interface org.springframework.web.servlet.HandlerInterceptor

afterCompletion

public void afterCompletion(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response,
                            Object handler,
                            Exception ex)
Invoked after view.

Specified by:
afterCompletion in interface org.springframework.web.servlet.HandlerInterceptor


Copyright © 2013. All Rights Reserved.