E - the interface of the object being wrapped.public class GenericMonitoringWrapper<E> extends Object implements InvocationHandler
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| Modifier and Type | Class and Description |
|---|---|
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.
|
| Modifier and Type | Field and Description |
|---|---|
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.
|
| Modifier | Constructor and Description |
|---|---|
protected |
GenericMonitoringWrapper(Class<E> targetClass,
Object target,
GenericMonitoringWrapper.TimingReporter timingReporter)
Constructs a new wrapper object.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
invoke(Object proxy,
Method method,
Object[] args)
Handles method invocations on the generated proxy.
|
static <E> E |
wrapObject(Class<E> clazz,
Object target)
Wraps the given object and returns the reporting proxy.
|
static <E> E |
wrapObject(Class<E> clazz,
Object target,
GenericMonitoringWrapper.TimingReporter timingReporter)
Wraps the given object and returns the reporting proxy.
|
private final Class<E> targetClass
private final Object target
private final GenericMonitoringWrapper.TimingReporter reporter
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 reporterpublic 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 wrappublic 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 topublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable
invoke in interface InvocationHandlerThrowableInvocationHandler.invoke(Object, java.lang.reflect.Method, Object[])Copyright © 2013 Immobilien Scout GmbH. All Rights Reserved.