patterntesting.runtime.monitor.db
Class ProxyConnection

Package class diagram package ProxyConnection
java.lang.Object
  extended by patterntesting.runtime.monitor.db.ProxyConnection
All Implemented Interfaces:
InvocationHandler
Direct Known Subclasses:
ProxyConnection

public class ProxyConnection
extends Object
implements InvocationHandler

This is a dynamic proxy for a JDBC connection which monitors together with the ConnectionMonitor the different newInstance() and close() call.

Note: Since 1.4.2 this class was moved from package "patterntesting.runtime.db" to here.

Since:
1.3 (29.09.2012)
Version:
$Revision: 1.2 $
Author:
oliver (ob@aosd.de)

Constructor Summary
protected ProxyConnection(Connection connection)
          Instantiates a new proxy connection.
 
Method Summary
 StackTraceElement[] getCaller()
          Gets the stacktrace of the caller.
 Connection getConnection()
          Gets the wrapped connection.
 Object invoke(Object proxy, Method method, Object[] args)
          Invokes the orginal Connection method and puts a wrapper around Statement and PreparedStatement to support monitoring.
static Connection newInstance(Connection connection)
          Creates a new proxy instance for the given connection.
 String toString()
          To string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProxyConnection

protected ProxyConnection(Connection connection)
Instantiates a new proxy connection. This constructor is called from newInstance(Connection) which is of no interest for us. We want to store the real caller so we ignore the ProxyConnection class but also the ProxyDriver class (ProxyDriver also calls this constructor indirectly) and other non-interesting classes.

Parameters:
connection - the connection
Method Detail

newInstance

public static Connection newInstance(Connection connection)
Creates a new proxy instance for the given connection.

Parameters:
connection - the connection
Returns:
the connection

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Invokes the orginal Connection method and puts a wrapper around Statement and PreparedStatement to support monitoring.

TODO: CallableStatement is not yet wrapped.

Specified by:
invoke in interface InvocationHandler
Parameters:
proxy - the proxy
method - the method
args - the args
Returns:
the object
Throws:
Throwable - the throwable
See Also:
InvocationHandler.invoke(Object, Method, Object[])

getConnection

public Connection getConnection()
Gets the wrapped connection.

Returns:
the connection

getCaller

public StackTraceElement[] getCaller()
Gets the stacktrace of the caller.

Returns:
the caller stacktrace

toString

public String toString()
To string.

Overrides:
toString in class Object
Returns:
the string
See Also:
Object.toString()


Copyright © 2002–2014 PatternTesting Team. All rights reserved.