|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.is24.util.monitoring.wrapper.GenericMonitoringWrapper<E>
E - the interface of the object being wrapped.public class GenericMonitoringWrapper<E>
This class provides the ability to wrap arbitrary objects and monitor the execution times of methods invoked on the object. The wrapped object must be described by an interface so that the wrapper can generate a proxy object during runtime.
The wrapper can be configured with a GenericMonitoringWrapper.TimingReporter that is used to
report the timinig measurement of a single method invocation. A default
implementation based on the InApplicationMonitor is provided.
Use one of the static wrapObject(Class, Object) or
wrapObject(Class, Object, TimingReporter) factory methods to wrap a
given object. Here is a small code snipped demonstrating the use:
final Connection connection = dataSource.getConnection(); final wrappedConnection = GenericMonitoringWrapper.wrapObject(Connection.class, connection);Now, if you make method calls on the
wrappedConnection object,
each method invocation will be reported to the InApplicationMonitor,
as the GenericMonitoringWrapper.InApplicationMonitorTimingReporter is the default reporter to
use in case none is given.
InApplicationMonitor,
Proxy| Nested Class Summary | |
|---|---|
static class |
GenericMonitoringWrapper.InApplicationMonitorTimingReporter
Default implementation of the GenericMonitoringWrapper.TimingReporter interface that uses
the InApplicationMonitor as it's backend. |
static interface |
GenericMonitoringWrapper.TimingReporter
Interface for objects that receive and handle timinig information for a given method invocation. |
| Field Summary | |
|---|---|
private GenericMonitoringWrapper.TimingReporter |
reporter
The reported used to report method invocation timings. |
private Object |
target
The target object being wrapped. |
private Class<E> |
targetClass
Stores the interface the wrapped object want's to expose. |
| Constructor Summary | |
|---|---|
protected |
GenericMonitoringWrapper(Class<E> targetClass,
Object target,
GenericMonitoringWrapper.TimingReporter timingReporter)
Constructs a new wrapper object. |
| Method Summary | ||
|---|---|---|
Object |
invoke(Object proxy,
Method method,
Object[] args)
Handles method invocations on the generated proxy. |
|
static
|
wrapObject(Class<E> clazz,
Object target)
Wraps the given object and returns the reporting proxy. |
|
static
|
wrapObject(Class<E> clazz,
Object target,
GenericMonitoringWrapper.TimingReporter timingReporter)
Wraps the given object and returns the reporting proxy. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private final Class<E> targetClass
private final Object target
private final GenericMonitoringWrapper.TimingReporter reporter
| Constructor Detail |
|---|
protected GenericMonitoringWrapper(Class<E> targetClass,
Object target,
GenericMonitoringWrapper.TimingReporter timingReporter)
wrapObject(Class, Object) factory methods.
targetClass - the class object of the public interface to wraptarget - the target object to wraptimingReporter - the timing reporter| Method Detail |
|---|
public static <E> E wrapObject(Class<E> clazz,
Object target)
GenericMonitoringWrapper.InApplicationMonitorTimingReporter to report the timings.
E - the type of the public interface of the wrapped objectclazz - the class object to the interfacetarget - the object to wrap
public static <E> E wrapObject(Class<E> clazz,
Object target,
GenericMonitoringWrapper.TimingReporter timingReporter)
E - the type of the public interface of the wrapped objectclazz - the class object to the interfacetarget - the object to wraptimingReporter - the reporter to report timing information to
public Object invoke(Object proxy,
Method method,
Object[] args)
throws Throwable
invoke in interface InvocationHandlerThrowableInvocationHandler.invoke(Object, java.lang.reflect.Method, Object[])
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||