Holger's
Java API

com.antelmann.util
Class PerformanceMonitor<T>

java.lang.Object
  extended by com.antelmann.util.InterfaceMonitor.Adapter
      extended by com.antelmann.util.PerformanceMonitor<T>
All Implemented Interfaces:
InterfaceMonitor, Wrapped<T>

public class PerformanceMonitor<T>
extends InterfaceMonitor.Adapter
implements Wrapped<T>

allows to easily monitor the performance of method calls of an interface and then analyze the data based on a TimeDataGrid.

Since:
16.04.2009, 00:00:07
Author:
Holger Antelmann

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.antelmann.util.InterfaceMonitor
InterfaceMonitor.Adapter, InterfaceMonitor.IMLogger, InterfaceMonitor.Profiler
 
Constructor Summary
PerformanceMonitor(Class<T> interfaceToBeMonitored, T objectToBeMonitored)
           
 
Method Summary
 TimeDataGrid<?> getTimeDataGrid()
          provides access to the TimeDataGrid instance that contains all relevant performance data from the method calls to the embedded instance for further analysis.
 T getWrappedInstance()
          returns the wrapped instance of the original object given in the constructor.
 void methodInvoked(Object object, Method method, Object[] args, long timeTaken, Object returnValue, Throwable throwable)
          this method gets automatically called on every call to the wrapped instance; the current time, the method name and the time taken will be added to the embedded TimeDataGrid.
 T unwrap()
          provides access to the embedded object that this instance was constructed with
 
Methods inherited from class com.antelmann.util.InterfaceMonitor.Adapter
prepareInvocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PerformanceMonitor

public PerformanceMonitor(Class<T> interfaceToBeMonitored,
                          T objectToBeMonitored)
Method Detail

unwrap

public T unwrap()
provides access to the embedded object that this instance was constructed with

Specified by:
unwrap in interface Wrapped<T>

getWrappedInstance

public T getWrappedInstance()
returns the wrapped instance of the original object given in the constructor. All calls to the interface of the return value will be monitored in such a way that the embedded TimeDataGrid will be updated.

See Also:
getTimeDataGrid()

getTimeDataGrid

public TimeDataGrid<?> getTimeDataGrid()
provides access to the TimeDataGrid instance that contains all relevant performance data from the method calls to the embedded instance for further analysis.


methodInvoked

public void methodInvoked(Object object,
                          Method method,
                          Object[] args,
                          long timeTaken,
                          Object returnValue,
                          Throwable throwable)
this method gets automatically called on every call to the wrapped instance; the current time, the method name and the time taken will be added to the embedded TimeDataGrid.

Specified by:
methodInvoked in interface InterfaceMonitor
Overrides:
methodInvoked in class InterfaceMonitor.Adapter
Parameters:
object - the original object that the given method was invoked on
method - the method that was executed on the given object
args - the arguments that were used for the given method call (may be null)
timeTaken - the time it took to execute the given method in milliseconds
returnValue - the value returned by the given method call (if no exception was thrown; otherwise null)
throwable - contains the exception thrown by the given method call (if any); if the Throwable is null, the returnValue is not and vice versa.
See Also:
getWrappedInstance(), TimeDataGrid.addPoint(Date, Object, Number), getTimeDataGrid()


(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads