org.javasimon.proxy
Class StopwatchProxyFactory<T>

java.lang.Object
  extended by org.javasimon.proxy.DelegatingProxyFactory<T>
      extended by org.javasimon.proxy.StopwatchProxyFactory<T>
All Implemented Interfaces:
InvocationHandler, Delegating<T>

public final class StopwatchProxyFactory<T>
extends DelegatingProxyFactory<T>

Stopwatch proxy factory can generate a proxy to wrap an existing class and monitor its performance. Sample usage:

 MonitoredInterface monitoredProxy=new StopwatchProxyFactory(monitoredImplementation).newProxy(MonitoredInterface.class);
or
 MonitoredInterface monitoredProxy=new StopwatchProxyFactory(monitoredImplementation, new CustomProxyStopwatchSource()).newProxy(MonitoredInterface.class);


Field Summary
private  StopwatchSource<DelegatingMethodInvocation<T>> stopwatchSource
          Stopwatch template.
 
Constructor Summary
StopwatchProxyFactory(T delegate)
          Constructor
StopwatchProxyFactory(T delegate, StopwatchSource<DelegatingMethodInvocation<T>> stopwatchSource)
          Constructor
 
Method Summary
protected  Object invoke(DelegatingMethodInvocation<T> methodInvocation)
          Invocation handler main method.
 
Methods inherited from class org.javasimon.proxy.DelegatingProxyFactory
getDelegate, invoke, newProxy, newProxy, newProxy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stopwatchSource

private final StopwatchSource<DelegatingMethodInvocation<T>> stopwatchSource
Stopwatch template.

Constructor Detail

StopwatchProxyFactory

public StopwatchProxyFactory(T delegate,
                             StopwatchSource<DelegatingMethodInvocation<T>> stopwatchSource)
Constructor

Parameters:
delegate - Wrapped object
stopwatchSource - Stopwatch source (to configure Stopwatch naming)

StopwatchProxyFactory

public StopwatchProxyFactory(T delegate)
Constructor

Parameters:
delegate - Wrapped object
Method Detail

invoke

protected Object invoke(DelegatingMethodInvocation<T> methodInvocation)
                 throws Throwable
Invocation handler main method.

Overrides:
invoke in class DelegatingProxyFactory<T>
Parameters:
methodInvocation - Method invocation (arguments, method name, etc.)
Returns:
Method invocation results
Throws:
Throwable - Method invocation raised exception


Copyright © 2013. All Rights Reserved.