Package org.hibernate.jdbc
Class BorrowedConnectionProxy
java.lang.Object
org.hibernate.jdbc.BorrowedConnectionProxy
- All Implemented Interfaces:
InvocationHandler
A proxy for borrowed connections which funnels all requests back
into the ConnectionManager from which it was borrowed to be properly
handled (in terms of connection release modes).
Note: the term borrowed here refers to connection references obtained
via
Session.connection() for application usage.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ConnectiongenerateProxy(ConnectionManager connectionManager) Generates a Connection proxy wrapping the connection managed by the passed connection manager.static ClassLoaderDetermines the appropriate class loader to which the generated proxy should be scoped.static ConnectiongetWrappedConnection(Connection connection) Convience method for unwrapping a connection proxy and getting a handle to an underlying connection.static voidrenderUnuseable(Connection connection) Marks a borrowed connection as no longer usable.
-
Constructor Details
-
BorrowedConnectionProxy
-
-
Method Details
-
invoke
- Specified by:
invokein interfaceInvocationHandler- Throws:
Throwable
-
generateProxy
Generates a Connection proxy wrapping the connection managed by the passed connection manager.- Parameters:
connectionManager- The connection manager to wrap with the connection proxy.- Returns:
- The generated proxy.
-
renderUnuseable
Marks a borrowed connection as no longer usable.- Parameters:
connection- The connection (proxy) to be marked.
-
getWrappedConnection
Convience method for unwrapping a connection proxy and getting a handle to an underlying connection.- Parameters:
connection- The connection (proxy) to be unwrapped.- Returns:
- The unwrapped connection.
-
getProxyClassLoader
Determines the appropriate class loader to which the generated proxy should be scoped.- Returns:
- The class loader appropriate for proxy construction.
-