Class StatementFacade
- All Implemented Interfaces:
InvocationHandler
The handles implement only the standard JDBC interfaces, so the driver's own classes are never visible through a cast.
Every result set handed back - including cursors returned through getObject(...) - is sealed to the borrow.
The Wrapper methods are delegated to the driver; an unwrapped driver object is not retired when the borrow
ends, so statements underneath are kept alive only by StatementFinalizer
or by the application closing them.
Sealing follows the declared type: a value that is not itself a result set is passed through unchanged, so cursors
carried inside an Array, Struct or Ref are not sealed.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classProxy for a ResultSet.protected classProxy for a SQL statement. -
Field Summary
Fields inherited from class AbstractCreateStatementInterceptor
CREATE_STATEMENT, CREATE_STATEMENT_IDX, EXECUTE, EXECUTE_BATCH, EXECUTE_LARGE_BATCH, EXECUTE_LARGE_UPDATE, EXECUTE_QUERY, EXECUTE_TYPES, EXECUTE_UPDATE, GET_GENERATED_KEYS, GET_RESULTSET, GET_STATEMENT, PREPARE_CALL, PREPARE_CALL_IDX, PREPARE_STATEMENT, PREPARE_STATEMENT_IDX, RESULTSET_IDX, STATEMENT_TYPE_COUNT, STATEMENT_TYPESFields inherited from class JdbcInterceptor
ABORT_VAL, CLOSE_VAL, EQUALS_VAL, GETCONNECTION_VAL, HASHCODE_VAL, ISCLOSED_VAL, ISVALID_VAL, ISWRAPPERFOR_VAL, properties, TOSTRING_VAL, UNWRAP_VAL -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStatementFacade(JdbcInterceptor interceptor) Constructs a StatementFacade. -
Method Summary
Modifier and TypeMethodDescriptionvoidMarks the borrow as ended, sealing every statement and result set handle this facade handed out so later calls are refused.createStatement(Object proxy, Method method, Object[] args, Object statement, long time) Wraps the statement produced underneath in a handle that retires with the borrow.Gets invoked each time an operation onConnectionis invoked.Methods inherited from class AbstractCreateStatementInterceptor
elapsedMillis, getConstructor, isExecute, isStatement, process, resetMethods inherited from class JdbcInterceptor
compare, compare, disconnected, getNext, getProperties, isUseEquals, poolClosed, poolStarted, setNext, setProperties, setUseEquals, unregisterMBean
-
Constructor Details
-
StatementFacade
Constructs a StatementFacade.- Parameters:
interceptor- the next interceptor in the chain
-
-
Method Details
-
invoke
Description copied from class:JdbcInterceptorGets invoked each time an operation onConnectionis invoked.The base implementation passes the call to the
nextinterceptor in the chain. When there is no next interceptor, the call fails fast with aNullPointerException: a chain built by the pool always ends in theProxyConnectionterminal, so reaching this case means a chain was hand-built without a terminal link. Interceptors that do not answer a call themselves continue it withsuper.invoke(proxy, method, args).- Specified by:
invokein interfaceInvocationHandler- Overrides:
invokein classAbstractCreateStatementInterceptor- Throws:
Throwable
-
closeInvoked
public void closeInvoked()Marks the borrow as ended, sealing every statement and result set handle this facade handed out so later calls are refused. Called before the connection leaves the application - on close and, throughinvoke(Object, Method, Object[]), on abort - so a handle cannot outlive the borrow and end up driving the session of the next borrower. This method does not physically close the driver statements; that is done by the driver's connection close, or byStatementFinalizerwhen configured. A borrow that is abandoned instead never runs this method, but the pool destroys an abandoned session rather than lending it again, so those handles only fail at the driver.- Specified by:
closeInvokedin classAbstractCreateStatementInterceptor
-
createStatement
public Object createStatement(Object proxy, Method method, Object[] args, Object statement, long time) Wraps the statement produced underneath in a handle that retires with the borrow.- Specified by:
createStatementin classAbstractCreateStatementInterceptor- Parameters:
proxy- the actual proxy objectmethod- the method that was called. It will be one of the methods defined inAbstractCreateStatementInterceptor.STATEMENT_TYPESargs- the arguments to the methodstatement- the statement that the underlying connection createdtime- elapsed time in milliseconds, measured with the monotonic clock- Returns:
- a
Statementobject
-