org.javasimon.spring
Class BasicMonitoringInterceptor

java.lang.Object
  extended by org.javasimon.spring.BasicMonitoringInterceptor
All Implemented Interfaces:
Serializable, org.aopalliance.aop.Advice, org.aopalliance.intercept.Interceptor, org.aopalliance.intercept.MethodInterceptor
Direct Known Subclasses:
MonitoringInterceptor

public class BasicMonitoringInterceptor
extends Object
implements org.aopalliance.intercept.MethodInterceptor, Serializable

Basic method interceptor that measures the duration of the intercepted call with a Stopwatch. Class can be overridden in case more sophisticated measuring needs to be provided - this all should happen in processInvoke(org.aopalliance.intercept.MethodInvocation, org.javasimon.Split) method.

Author:
Erik van Oosten
See Also:
Serialized Form

Field Summary
private  StopwatchSource<org.aopalliance.intercept.MethodInvocation> stopwatchSource
           
 
Constructor Summary
BasicMonitoringInterceptor()
          Default constructor using SimonManager.manager.
BasicMonitoringInterceptor(Manager manager)
          Constructor with specified Manager.
BasicMonitoringInterceptor(StopwatchSource<org.aopalliance.intercept.MethodInvocation> stopwatchSource)
          Constructor with specified MonitorSource.
 
Method Summary
 Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
          Performs method invocation and wraps it with Stopwatch.
protected  Object processInvoke(org.aopalliance.intercept.MethodInvocation invocation, Split split)
          Method with default invoke (just calls proceed).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stopwatchSource

private final StopwatchSource<org.aopalliance.intercept.MethodInvocation> stopwatchSource
Constructor Detail

BasicMonitoringInterceptor

public BasicMonitoringInterceptor(StopwatchSource<org.aopalliance.intercept.MethodInvocation> stopwatchSource)
Constructor with specified MonitorSource.

Parameters:
stopwatchSource - stopwatch provider for method invocation

BasicMonitoringInterceptor

public BasicMonitoringInterceptor(Manager manager)
Constructor with specified Manager.


BasicMonitoringInterceptor

public BasicMonitoringInterceptor()
Default constructor using SimonManager.manager.

Method Detail

invoke

public final Object invoke(org.aopalliance.intercept.MethodInvocation invocation)
                    throws Throwable
Performs method invocation and wraps it with Stopwatch.

Specified by:
invoke in interface org.aopalliance.intercept.MethodInterceptor
Parameters:
invocation - method invocation
Returns:
return object from the method
Throws:
Throwable - anything thrown by the method

processInvoke

protected Object processInvoke(org.aopalliance.intercept.MethodInvocation invocation,
                               Split split)
                        throws Throwable
Method with default invoke (just calls proceed). It can be overridden and overriding method can stop the provided split. If split is not stopped it will be stopped right after this method finishes. Any caught throwable should be rethrown again. Method should call invocation.proceed().

Parameters:
invocation - method invocation
split - running split for this monitored action
Returns:
return object from the method
Throws:
Throwable


Copyright © 2013. All Rights Reserved.