public class MonProxy extends Object implements InvocationHandler
Sample code:
ResultSet rs= MonProxyFactory.monitor(resultSet);
Connection conn=MonProxyFactory.monitor(connection);
MyInterface my=(MyInterface) MonProxyFactory.monitor(myObject);//myObject implements MyInterface
YourInterface your=(YourInterface) MonProxyFactory.monitor(yourObject);//myObject implements MyInterface
Subsequent public method calls on this interface will be monitored. Quite cool. If the proxy is disabled the Object will be returned unchanged.
Note the object passed MUST implement an interface or a runtime exception will occur i..e it can't be a plain java object.
Also, to change from the default labeler interface you must do the following on your monitored object.
Map map=(Map) MonProxyFactory.monitor(new HashMap());
MonProxy monProxy=MonProxyFactory.getMonProxy((Proxy)map);
monProxy.setLabeler(new MyWonderfulLabeler());
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
When this is called on the proxy object it is the same as calling
proxyObject1.equals(proxyObject2) is the same as calling originalObject1.equals(originalObject2)
|
MonProxyLabelerInt |
getLabeler()
Get current labeler
|
Object |
getMonitoredObject()
Return the underlying object being Monitored.
|
static Object |
getMonitoredObject(Object obj)
Static method that returns the underlying/wrapped/monitored object if the passed object is an interfaced monitored by JAMon else
if not simply return the object unchanged.
|
Object |
invoke(Object proxy,
Method method,
Object[] args)
Method that monitors method invocations of the proxied interface.
|
void |
setLabeler(MonProxyLabelerInt labelerInt)
Set labeler to be called when summary stats are recorded for a method call or when the interface throws an exception
|
public Object getMonitoredObject()
public static Object getMonitoredObject(Object obj)
public void setLabeler(MonProxyLabelerInt labelerInt)
public MonProxyLabelerInt getLabeler()
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
invoke
in interface InvocationHandler
Throwable
Copyright © 2015. All rights reserved.