Class StatementCache
java.lang.Object
org.apache.tomcat.jdbc.pool.JdbcInterceptor
org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor
org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptor
org.apache.tomcat.jdbc.pool.interceptor.StatementCache
- All Implemented Interfaces:
InvocationHandler
,StatementCacheMBean
Interceptor that caches
PreparedStatement
and/or
CallableStatement
instances on a connection.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptor
StatementDecoratorInterceptor.ResultSetProxy, StatementDecoratorInterceptor.StatementProxy<T extends Statement>
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String[]
protected static final String[]
protected static final String[]
protected static final String[]
protected static final String
Fields inherited from class org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptor
EXECUTE_QUERY, GET_GENERATED_KEYS, GET_RESULTSET, RESULTSET_TYPES, resultSetConstructor
Fields inherited from class org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor
constructors, CREATE_STATEMENT, CREATE_STATEMENT_IDX, EXECUTE, EXECUTE_BATCH, EXECUTE_TYPES, EXECUTE_UPDATE, 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
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 TypeMethodDescriptionboolean
void
protected org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CacheKey
createCacheKey
(Method method, Object[] args) protected org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CacheKey
createCacheKey
(String methodName, Object[] args) protected Object
createDecorator
(Object proxy, Method method, Object[] args, Object statement, Constructor<?> constructor, String sql) Creates a proxy for a Statement.void
disconnected
(ConnectionPool parent, PooledConnection con, boolean finalizing) Called whenConnection.close()
is called on the underlying connection.protected ConcurrentHashMap<org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CacheKey,
StatementCache.CachedStatement> getCache()
int
int
String[]
getTypes()
Gets invoked each time an operation onConnection
is invoked.boolean
boolean
void
poolClosed
(ConnectionPool pool) This method is invoked by a connection pool when the pool is closed.void
poolStarted
(ConnectionPool pool) This method is invoked by a connection pool when the pool is first started up, usually when the first connection is requested.boolean
void
reset
(ConnectionPool parent, PooledConnection con) no-op for this interceptor. no state is stored.void
setProperties
(Map<String, PoolProperties.InterceptorProperty> properties) Called during the creation of an interceptor The properties can be set during the configuration of an interceptor Override this method to perform type casts between string values and object propertiesMethods inherited from class org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptor
closeInvoked, createStatement, getResultSetConstructor, isExecuteQuery, isExecuteQuery, isResultSet
Methods inherited from class org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor
getConstructor, isExecute, isStatement, process
Methods inherited from class org.apache.tomcat.jdbc.pool.JdbcInterceptor
compare, compare, getNext, getProperties, isUseEquals, setNext, setUseEquals
-
Field Details
-
ALL_TYPES
-
CALLABLE_TYPE
-
PREPARED_TYPE
-
NO_TYPE
-
STATEMENT_CACHE_ATTR
-
-
Constructor Details
-
StatementCache
public StatementCache()
-
-
Method Details
-
isCachePrepared
public boolean isCachePrepared()- Specified by:
isCachePrepared
in interfaceStatementCacheMBean
-
isCacheCallable
public boolean isCacheCallable()- Specified by:
isCacheCallable
in interfaceStatementCacheMBean
-
getMaxCacheSize
public int getMaxCacheSize()- Specified by:
getMaxCacheSize
in interfaceStatementCacheMBean
-
getTypes
-
getCacheSize
- Specified by:
getCacheSize
in interfaceStatementCacheMBean
-
setProperties
Description copied from class:JdbcInterceptor
Called during the creation of an interceptor The properties can be set during the configuration of an interceptor Override this method to perform type casts between string values and object properties- Overrides:
setProperties
in classJdbcInterceptor
- Parameters:
properties
- The properties
-
poolStarted
Description copied from class:JdbcInterceptor
This method is invoked by a connection pool when the pool is first started up, usually when the first connection is requested. Interceptor classes can override this method if they keep static variables or other tracking means around. This method is only invoked on a single instance of the interceptor, and not on every instance created.- Overrides:
poolStarted
in classJdbcInterceptor
- Parameters:
pool
- - the pool that is being closed.
-
poolClosed
Description copied from class:JdbcInterceptor
This method is invoked by a connection pool when the pool is closed. Interceptor classes can override this method if they keep static variables or other tracking means around. This method is only invoked on a single instance of the interceptor, and not on every instance created.- Overrides:
poolClosed
in classJdbcInterceptor
- Parameters:
pool
- - the pool that is being closed.
-
reset
Description copied from class:AbstractCreateStatementInterceptor
no-op for this interceptor. no state is stored.- Overrides:
reset
in classAbstractCreateStatementInterceptor
- Parameters:
parent
- - the connection pool owning the connectioncon
- - the pooled connection
-
disconnected
Description copied from class:JdbcInterceptor
Called whenConnection.close()
is called on the underlying connection. This is to notify the interceptors, that the physical connection has been released. Implementation of this method should be thought through with care, as no actions should trigger an exception.- Overrides:
disconnected
in classJdbcInterceptor
- Parameters:
parent
- - the connection pool that this connection belongs tocon
- - the pooled connection that holds this connectionfinalizing
- - if this connection is finalizing. True means that the pooled connection will not reconnect the underlying connection
-
closeStatement
-
createDecorator
protected Object createDecorator(Object proxy, Method method, Object[] args, Object statement, Constructor<?> constructor, String sql) throws InstantiationException, IllegalAccessException, InvocationTargetException Description copied from class:StatementDecoratorInterceptor
Creates a proxy for a Statement.- Overrides:
createDecorator
in classStatementDecoratorInterceptor
- Parameters:
proxy
- The proxy object on which the method that triggered the creation of the statement was called.method
- The method that was called on the proxyargs
- The arguments passed as part of the method call to the proxystatement
- The statement object that is to be proxiedconstructor
- The constructor for the desired proxysql
- The sql of of the statement- Returns:
- A new proxy for the Statement
- Throws:
InstantiationException
- Couldn't instantiate objectIllegalAccessException
- Inaccessible constructorInvocationTargetException
- Exception thrown from constructor
-
invoke
Description copied from class:JdbcInterceptor
Gets invoked each time an operation onConnection
is invoked.- Specified by:
invoke
in interfaceInvocationHandler
- Overrides:
invoke
in classAbstractCreateStatementInterceptor
- Throws:
Throwable
-
isCached
-
cacheStatement
-
removeStatement
-
getCache
protected ConcurrentHashMap<org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CacheKey,StatementCache.CachedStatement> getCache() -
getCacheSizePerConnection
public int getCacheSizePerConnection()- Specified by:
getCacheSizePerConnection
in interfaceStatementCacheMBean
-
createCacheKey
-
createCacheKey
-