Class StatementFacade
- java.lang.Object
-
- org.apache.tomcat.jdbc.pool.JdbcInterceptor
-
- org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor
-
- org.apache.tomcat.jdbc.pool.StatementFacade
-
- All Implemented Interfaces:
java.lang.reflect.InvocationHandler
public class StatementFacade extends AbstractCreateStatementInterceptor
Facade that creates statement and result set proxies.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. TheWrappermethods are delegated to the driver; an unwrapped driver object is not retired when the borrow ends, so statements underneath are kept alive only byStatementFinalizeror 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,StructorRefare not sealed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classStatementFacade.ResultSetProxyProxy for a ResultSet.protected classStatementFacade.StatementProxyProxy for a SQL statement.
-
Field Summary
-
Fields inherited from class org.apache.tomcat.jdbc.pool.interceptor.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_TYPES
-
Fields inherited from class org.apache.tomcat.jdbc.pool.JdbcInterceptor
ABORT_VAL, CLOSE_VAL, EQUALS_VAL, GETCONNECTION_VAL, HASHCODE_VAL, ISCLOSED_VAL, ISVALID_VAL, ISWRAPPERFOR_VAL, properties, TOSTRING_VAL, UNWRAP_VAL
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedStatementFacade(JdbcInterceptor interceptor)Constructs a StatementFacade.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseInvoked()Marks the borrow as ended, sealing every statement and result set handle this facade handed out so later calls are refused.java.lang.ObjectcreateStatement(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Object statement, long time)Wraps the statement produced underneath in a handle that retires with the borrow.java.lang.Objectinvoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)Gets invoked each time an operation onConnectionis invoked.-
Methods inherited from class org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor
elapsedMillis, getConstructor, isExecute, isStatement, process, reset
-
Methods inherited from class org.apache.tomcat.jdbc.pool.JdbcInterceptor
compare, compare, disconnected, getNext, getProperties, isUseEquals, poolClosed, poolStarted, setNext, setProperties, setUseEquals, unregisterMBean
-
-
-
-
Constructor Detail
-
StatementFacade
protected StatementFacade(JdbcInterceptor interceptor)
Constructs a StatementFacade.- Parameters:
interceptor- the next interceptor in the chain
-
-
Method Detail
-
invoke
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.ThrowableDescription 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 interfacejava.lang.reflect.InvocationHandler- Overrides:
invokein classAbstractCreateStatementInterceptor- Throws:
java.lang.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(java.lang.Object, java.lang.reflect.Method, java.lang.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 java.lang.Object createStatement(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args, java.lang.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
-
-