Class AbstractCreateStatementInterceptor
java.lang.Object
org.apache.tomcat.jdbc.pool.JdbcInterceptor
org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor
- All Implemented Interfaces:
InvocationHandler
- Direct Known Subclasses:
AbstractQueryReport
,QueryTimeoutInterceptor
,StatementDecoratorInterceptor
,StatementFacade
,StatementFinalizer
Abstraction interceptor. This component intercepts all calls to create some type of SQL statement. By extending this
class, one can intercept queries and update statements by overriding the
createStatement(Object, Method, Object[], Object, long)
method.-
Field Summary
Modifier and TypeFieldDescriptionprotected static final Constructor<?>[]
the constructors that are used to create statement proxiesprotected static final String
protected static final int
protected static final String
protected static final String
protected static final String
protected static final String[]
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final int
protected static final String
protected static final int
protected static final int
protected static final int
protected static final String[]
Fields inherited from class org.apache.tomcat.jdbc.pool.JdbcInterceptor
CLOSE_VAL, EQUALS_VAL, GETCONNECTION_VAL, HASHCODE_VAL, ISCLOSED_VAL, ISVALID_VAL, ISWRAPPERFOR_VAL, properties, TOSTRING_VAL, UNWRAP_VAL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
Method invoked when the operationConnection.close()
is invoked.abstract Object
createStatement
(Object proxy, Method method, Object[] args, Object statement, long time) This method will be invoked after a successful statement creation.protected Constructor<?>
getConstructor
(int idx, Class<?> clazz) Creates a constructor for a proxy class, if one doesn't already existGets invoked each time an operation onConnection
is invoked.protected boolean
Returns true if the method that is being invoked matches one of the execute types.protected boolean
isStatement
(Method method, boolean process) Returns true if the method that is being invoked matches one of the statement types.protected boolean
void
reset
(ConnectionPool parent, PooledConnection con) no-op for this interceptor. no state is stored.Methods inherited from class org.apache.tomcat.jdbc.pool.JdbcInterceptor
compare, compare, disconnected, getNext, getProperties, isUseEquals, poolClosed, poolStarted, setNext, setProperties, setUseEquals
-
Field Details
-
CREATE_STATEMENT
- See Also:
-
CREATE_STATEMENT_IDX
protected static final int CREATE_STATEMENT_IDX- See Also:
-
PREPARE_STATEMENT
- See Also:
-
PREPARE_STATEMENT_IDX
protected static final int PREPARE_STATEMENT_IDX- See Also:
-
PREPARE_CALL
- See Also:
-
PREPARE_CALL_IDX
protected static final int PREPARE_CALL_IDX- See Also:
-
GET_RESULTSET
- See Also:
-
GET_GENERATED_KEYS
- See Also:
-
GET_STATEMENT
- See Also:
-
RESULTSET_IDX
protected static final int RESULTSET_IDX- See Also:
-
STATEMENT_TYPES
-
STATEMENT_TYPE_COUNT
protected static final int STATEMENT_TYPE_COUNT -
EXECUTE
- See Also:
-
EXECUTE_QUERY
- See Also:
-
EXECUTE_UPDATE
- See Also:
-
EXECUTE_BATCH
- See Also:
-
EXECUTE_TYPES
-
constructors
the constructors that are used to create statement proxies
-
-
Constructor Details
-
AbstractCreateStatementInterceptor
public AbstractCreateStatementInterceptor()
-
-
Method Details
-
invoke
Description copied from class:JdbcInterceptor
Gets invoked each time an operation onConnection
is invoked.- Specified by:
invoke
in interfaceInvocationHandler
- Overrides:
invoke
in classJdbcInterceptor
- Throws:
Throwable
-
getConstructor
Creates a constructor for a proxy class, if one doesn't already exist- Parameters:
idx
- - the index of the constructorclazz
- - the interface that the proxy will implement- Returns:
- - returns a constructor used to create new instances
- Throws:
NoSuchMethodException
- Constructor not found
-
createStatement
public abstract Object createStatement(Object proxy, Method method, Object[] args, Object statement, long time) This method will be invoked after a successful statement creation. This method can choose to return a wrapper around the statement or return the statement itself. If this method returns a wrapper then it should return a wrapper object that implements one of the following interfaces.Statement
,PreparedStatement
orCallableStatement
- Parameters:
proxy
- the actual proxy objectmethod
- the method that was called. It will be one of the methods defined inSTATEMENT_TYPES
args
- the arguments to the methodstatement
- the statement that the underlying connection createdtime
- Elapsed time- Returns:
- a
Statement
object
-
closeInvoked
public abstract void closeInvoked()Method invoked when the operationConnection.close()
is invoked. -
isStatement
Returns true if the method that is being invoked matches one of the statement types.- Parameters:
method
- the method being invoked on the proxyprocess
- boolean result used for recursion- Returns:
- returns true if the method name matched
-
isExecute
Returns true if the method that is being invoked matches one of the execute types.- Parameters:
method
- the method being invoked on the proxyprocess
- boolean result used for recursion- Returns:
- returns true if the method name matched
-
process
-
reset
no-op for this interceptor. no state is stored.- Specified by:
reset
in classJdbcInterceptor
- Parameters:
parent
- - the connection pool owning the connectioncon
- - the pooled connection
-