Class ProxyConnection
java.lang.Object
clazzfish.jdbc.ProxyConnection
- All Implemented Interfaces:
InvocationHandler
This is a dynamic proxy for a JDBC connection which monitors together with
the
ConnectionMonitor
the different newInstance() and close() call.
Note: This class was moved in 2018 from the PatternTesting project to here.
- Since:
- 0.9
- Author:
- oliver (ob@aosd.de)
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ProxyConnection
(Connection connection) Instantiates a new proxy connection. -
Method Summary
Modifier and TypeMethodDescriptionGets the stacktrace of the caller.Gets the wrapped connection.Invokes the orginalConnection
method and puts a wrapper aroundStatement
andPreparedStatement
to support monitoring.static Connection
newInstance
(Connection connection) Creates a new proxy instance for the given connection.toString()
To string.
-
Constructor Details
-
ProxyConnection
Instantiates a new proxy connection. This constructor is called fromnewInstance(Connection)
which is of no interest for us. We want to store the real caller so we ignore theProxyConnection
class but also theProxyDriver
class (ProxyDriver also calls this constructor indirectly) and other classes.- Parameters:
connection
- the connection where this class acts as proxy
-
-
Method Details
-
newInstance
Creates a new proxy instance for the given connection.- Parameters:
connection
- the connection- Returns:
- the connection
-
invoke
Invokes the orginalConnection
method and puts a wrapper aroundStatement
andPreparedStatement
to support monitoring.TODO: CallableStatement is not yet wrapped.
- Specified by:
invoke
in interfaceInvocationHandler
- Parameters:
proxy
- the proxymethod
- the methodargs
- the args- Returns:
- the object
- Throws:
Throwable
- the throwable- See Also:
-
getConnection
-
getCaller
Gets the stacktrace of the caller.- Returns:
- the caller stacktrace
-
toString
-