public class

JamonPerformanceMonitorInterceptor

extends AbstractMonitoringInterceptor
java.lang.Object
   ↳ org.springframework.aop.interceptor.AbstractTraceInterceptor
     ↳ org.springframework.aop.interceptor.AbstractMonitoringInterceptor
       ↳ org.springframework.aop.interceptor.JamonPerformanceMonitorInterceptor

Class Overview

Performance monitor interceptor that uses JAMon library to perform the performance measurement on the intercepted method and output the stats.

This code is inspired by Thierry Templier's blog.

See Also

Summary

[Expand]
Inherited Fields
From class org.springframework.aop.interceptor.AbstractTraceInterceptor
Public Constructors
JamonPerformanceMonitorInterceptor()
Create a new JamonPerformanceMonitorInterceptor with a static logger.
JamonPerformanceMonitorInterceptor(boolean useDynamicLogger)
Create a new JamonPerformanceMonitorInterceptor with a dynamic or static logger, according to the given flag.
JamonPerformanceMonitorInterceptor(boolean useDynamicLogger, boolean trackAllInvocations)
Create a new JamonPerformanceMonitorInterceptor with a dynamic or static logger, according to the given flag.
Public Methods
void setTrackAllInvocations(boolean trackAllInvocations)
Set whether to track all invocations that go through this interceptor, or just invocations with trace logging enabled.
Protected Methods
Object invokeUnderTrace(MethodInvocation invocation, Log logger)
Wraps the invocation with a JAMon Monitor and writes the current performance statistics to the log (if enabled).
boolean isInterceptorEnabled(MethodInvocation invocation, Log logger)
Always applies the interceptor if the "trackAllInvocations" flag has been set; else just kicks in if the log is enabled.
[Expand]
Inherited Methods
From class org.springframework.aop.interceptor.AbstractMonitoringInterceptor
From class org.springframework.aop.interceptor.AbstractTraceInterceptor
From class java.lang.Object

Public Constructors

public JamonPerformanceMonitorInterceptor ()

Create a new JamonPerformanceMonitorInterceptor with a static logger.

public JamonPerformanceMonitorInterceptor (boolean useDynamicLogger)

Create a new JamonPerformanceMonitorInterceptor with a dynamic or static logger, according to the given flag.

Parameters
useDynamicLogger whether to use a dynamic logger or a static logger

public JamonPerformanceMonitorInterceptor (boolean useDynamicLogger, boolean trackAllInvocations)

Create a new JamonPerformanceMonitorInterceptor with a dynamic or static logger, according to the given flag.

Parameters
useDynamicLogger whether to use a dynamic logger or a static logger
trackAllInvocations whether to track all invocations that go through this interceptor, or just invocations with trace logging enabled

Public Methods

public void setTrackAllInvocations (boolean trackAllInvocations)

Set whether to track all invocations that go through this interceptor, or just invocations with trace logging enabled.

Default is "false": Only invocations with trace logging enabled will be monitored. Specify "true" to let JAMon track all invocations, gathering statistics even when trace logging is disabled.

Protected Methods

protected Object invokeUnderTrace (MethodInvocation invocation, Log logger)

Wraps the invocation with a JAMon Monitor and writes the current performance statistics to the log (if enabled).

Parameters
logger the Log to write trace messages to
Returns
  • the result of the call to MethodInvocation.proceed()
Throws
Throwable
See Also
  • com.jamonapi.MonitorFactory#start
  • com.jamonapi.Monitor#stop

protected boolean isInterceptorEnabled (MethodInvocation invocation, Log logger)

Always applies the interceptor if the "trackAllInvocations" flag has been set; else just kicks in if the log is enabled.

Parameters
invocation the MethodInvocation being traced
logger the Log instance to check