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
public abstract class AbstractCreateStatementInterceptor extends JdbcInterceptor
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 thecreateStatement(Object, Method, Object[], Object, long)method.- Version:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description protected static Constructor<?>[]constructorsthe constructors that are used to create statement proxiesprotected static StringCREATE_STATEMENTprotected static intCREATE_STATEMENT_IDXprotected static StringEXECUTEprotected static StringEXECUTE_BATCHprotected static StringEXECUTE_QUERYprotected static String[]EXECUTE_TYPESprotected static StringEXECUTE_UPDATEprotected static StringPREPARE_CALLprotected static intPREPARE_CALL_IDXprotected static StringPREPARE_STATEMENTprotected static intPREPARE_STATEMENT_IDXprotected static intSTATEMENT_TYPE_COUNTprotected static String[]STATEMENT_TYPES-
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
Constructors Constructor Description AbstractCreateStatementInterceptor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract voidcloseInvoked()Method invoked when the operationConnection.close()is invoked.abstract ObjectcreateStatement(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 existObjectinvoke(Object proxy, Method method, Object[] args)Gets invoked each time an operation onConnectionis invoked.protected booleanisExecute(Method method, boolean process)Returns true if the method that is being invoked matches one of the execute types.protected booleanisStatement(Method method, boolean process)Returns true if the method that is being invoked matches one of the statement types.protected booleanprocess(String[] names, Method method, boolean process)voidreset(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 Detail
-
CREATE_STATEMENT
protected static final String CREATE_STATEMENT
- See Also:
- Constant Field Values
-
CREATE_STATEMENT_IDX
protected static final int CREATE_STATEMENT_IDX
- See Also:
- Constant Field Values
-
PREPARE_STATEMENT
protected static final String PREPARE_STATEMENT
- See Also:
- Constant Field Values
-
PREPARE_STATEMENT_IDX
protected static final int PREPARE_STATEMENT_IDX
- See Also:
- Constant Field Values
-
PREPARE_CALL
protected static final String PREPARE_CALL
- See Also:
- Constant Field Values
-
PREPARE_CALL_IDX
protected static final int PREPARE_CALL_IDX
- See Also:
- Constant Field Values
-
STATEMENT_TYPES
protected static final String[] STATEMENT_TYPES
-
STATEMENT_TYPE_COUNT
protected static final int STATEMENT_TYPE_COUNT
-
EXECUTE
protected static final String EXECUTE
- See Also:
- Constant Field Values
-
EXECUTE_QUERY
protected static final String EXECUTE_QUERY
- See Also:
- Constant Field Values
-
EXECUTE_UPDATE
protected static final String EXECUTE_UPDATE
- See Also:
- Constant Field Values
-
EXECUTE_BATCH
protected static final String EXECUTE_BATCH
- See Also:
- Constant Field Values
-
EXECUTE_TYPES
protected static final String[] EXECUTE_TYPES
-
constructors
protected static final Constructor<?>[] constructors
the constructors that are used to create statement proxies
-
-
Method Detail
-
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
Gets invoked each time an operation onConnectionis invoked.- Specified by:
invokein interfaceInvocationHandler- Overrides:
invokein classJdbcInterceptor- Throws:
Throwable
-
getConstructor
protected Constructor<?> getConstructor(int idx, Class<?> clazz) throws NoSuchMethodException
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,PreparedStatementorCallableStatement- Parameters:
proxy- the actual proxy objectmethod- the method that was called. It will be one of the methods defined inSTATEMENT_TYPESargs- the arguments to the methodstatement- the statement that the underlying connection createdtime- Elapsed time- Returns:
- a
Statementobject
-
closeInvoked
public abstract void closeInvoked()
Method invoked when the operationConnection.close()is invoked.
-
isStatement
protected boolean isStatement(Method method, boolean process)
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
protected boolean isExecute(Method method, boolean process)
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
-
reset
public void reset(ConnectionPool parent, PooledConnection con)
no-op for this interceptor. no state is stored.- Specified by:
resetin classJdbcInterceptor- Parameters:
parent- - the connection pool owning the connectioncon- - the pooled connection
-
-