com.jamonapi.proxy
Class MonProxy

java.lang.Object
  extended by com.jamonapi.proxy.MonProxy
All Implemented Interfaces:
java.lang.reflect.InvocationHandler

public class MonProxy
extends java.lang.Object
implements java.lang.reflect.InvocationHandler

By using this proxy class ANY java interface can be monitored for performance and exceptions via JAMon. In particular the 'monitor' method is great for wrapping (and so monitoring) any of the JDBC classes which all implement interfaces (i.e. Connection, ResultSet, Statement, PreparedStatement,...). It tracks performance stats (hits/avg/min/max/...) for method calls and Exceptions. 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.


Method Summary
 boolean equals(java.lang.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)
 java.lang.Object getMonitoredObject()
          Return the underlying object being Monitored.
static java.lang.Object getMonitoredObject(java.lang.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.
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Method that monitors method invocations of the proxied interface.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getMonitoredObject

public java.lang.Object getMonitoredObject()
Return the underlying object being Monitored. If the monitored object is wrapped with another Monitored object it will call until MonProxy is not returned (i.e. find the underlying monitored object


getMonitoredObject

public static java.lang.Object getMonitoredObject(java.lang.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. It will follow the chain of MonProxy objects until the first non-MonProxy object is returned. This could return another type of Proxy object too.


invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Method that monitors method invocations of the proxied interface. This method is not explicitly called. The MonProxy class automatically calls it.

Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Throws:
java.lang.Throwable

equals

public boolean equals(java.lang.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)

Overrides:
equals in class java.lang.Object