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
ConstructorsModifierConstructorDescriptionprotectedProxyConnection(Connection connection) Instantiates a new proxy connection. -
Method Summary
Modifier and TypeMethodDescriptionGets the stacktrace of the caller.Gets the wrapped connection.Invokes the orginalConnectionmethod and puts a wrapper aroundStatementandPreparedStatementto support monitoring.static ConnectionnewInstance(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 theProxyConnectionclass but also theProxyDriverclass (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 orginalConnectionmethod and puts a wrapper aroundStatementandPreparedStatementto support monitoring.TODO: CallableStatement is not yet wrapped.
- Specified by:
invokein 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
-