Package org.apache.tomcat.jdbc.pool
Class JdbcInterceptor
java.lang.Object
org.apache.tomcat.jdbc.pool.JdbcInterceptor
- All Implemented Interfaces:
- InvocationHandler
- Direct Known Subclasses:
- AbstractCreateStatementInterceptor,- ConnectionState,- DisposableConnectionFacade,- ProxyConnection,- TrapException
Abstract class that is to be extended for implementations of interceptors.
 Everytime an operation is called on the 
Interceptors can receive a set of properties. Each sub class is responsible for parsing the properties during runtime when they are needed or simply override the
Connection object the
 invoke(Object, Method, Object[]) method on the interceptor will be called.
 Interceptors are useful to change or improve behavior of the connection pool.Interceptors can receive a set of properties. Each sub class is responsible for parsing the properties during runtime when they are needed or simply override the
setProperties(Map) method.
 Properties arrive in a key-value pair of Strings as they were received through the configuration.
 This method is called once per cached connection object when the object is first configured.- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringConnection.close()method namestatic final Stringstatic final StringPooledConnection.getConnection()method namestatic final Stringstatic final StringConnection.isClosed()method namestatic final StringConnection.isValid(int)method namestatic final StringWrapper.isWrapperFor(Class)method nameprotected Map<String,PoolProperties.InterceptorProperty> Properties for this interceptor.static final StringObject.toString()method namestatic final StringWrapper.unwrap(Class)method name
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanCompares a method name (String) to a method (Method)compare(String,String)Uses reference comparison unless the useEquals property is set to truebooleanPerforms a string comparison, using references unless the useEquals property is set to true.voiddisconnected(ConnectionPool parent, PooledConnection con, boolean finalizing) Called whenConnection.close()is called on the underlying connection.getNext()Returns the next interceptor in the chainReturns the properties configured for this interceptorGets invoked each time an operation onConnectionis invoked.booleanvoidpoolClosed(ConnectionPool pool) This method is invoked by a connection pool when the pool is closed.voidpoolStarted(ConnectionPool pool) This method is invoked by a connection pool when the pool is first started up, usually when the first connection is requested.abstract voidreset(ConnectionPool parent, PooledConnection con) Gets called each time the connection is borrowed from the pool This means that if an interceptor holds a reference to the connection the interceptor can be reused for another connection.voidsetNext(JdbcInterceptor next) configures the next interceptor in the chainvoidsetProperties(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 propertiesvoidsetUseEquals(boolean useEquals) Set to true if string comparisons (for thecompare(String, Method)andcompare(String, String)methods) should use the Object.equals(Object) method The default is false
- 
Field Details- 
CLOSE_VALConnection.close()method name- See Also:
 
- 
TOSTRING_VALObject.toString()method name- See Also:
 
- 
ISCLOSED_VALConnection.isClosed()method name- See Also:
 
- 
GETCONNECTION_VALPooledConnection.getConnection()method name- See Also:
 
- 
UNWRAP_VALWrapper.unwrap(Class)method name- See Also:
 
- 
ISWRAPPERFOR_VALWrapper.isWrapperFor(Class)method name- See Also:
 
- 
ISVALID_VALConnection.isValid(int)method name- See Also:
 
- 
EQUALS_VAL- See Also:
 
- 
HASHCODE_VAL- See Also:
 
- 
propertiesProperties for this interceptor.
 
- 
- 
Constructor Details- 
JdbcInterceptorpublic JdbcInterceptor()Public constructor for instantiation through reflection
 
- 
- 
Method Details- 
invokeGets invoked each time an operation onConnectionis invoked.- Specified by:
- invokein interface- InvocationHandler
- Throws:
- Throwable
 
- 
getNextReturns the next interceptor in the chain- Returns:
- the next interceptor in the chain
 
- 
setNextconfigures the next interceptor in the chain- Parameters:
- next- The next chain item
 
- 
comparePerforms a string comparison, using references unless the useEquals property is set to true.- Parameters:
- name1- The first name
- name2- The second name
- Returns:
- true if name1 is equal to name2 based on useEquals
 
- 
compareCompares a method name (String) to a method (Method)compare(String,String)Uses reference comparison unless the useEquals property is set to true- Parameters:
- methodName- The method name
- method- The method
- Returns:
- trueif the name matches
 
- 
resetGets called each time the connection is borrowed from the pool This means that if an interceptor holds a reference to the connection the interceptor can be reused for another connection.
 This method may be called with null as both arguments when we are closing down the connection.- Parameters:
- parent- - the connection pool owning the connection
- con- - the pooled connection
 
- 
disconnectedCalled 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.- Parameters:
- parent- - the connection pool that this connection belongs to
- con- - the pooled connection that holds this connection
- finalizing- - if this connection is finalizing. True means that the pooled connection will not reconnect the underlying connection
 
- 
getPropertiesReturns the properties configured for this interceptor- Returns:
- the configured properties for this interceptor
 
- 
setPropertiesCalled 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- Parameters:
- properties- The properties
 
- 
isUseEqualspublic boolean isUseEquals()- Returns:
- true if the compare method uses the Object.equals(Object) method false if comparison is done on a reference level
 
- 
setUseEqualspublic void setUseEquals(boolean useEquals) Set to true if string comparisons (for thecompare(String, Method)andcompare(String, String)methods) should use the Object.equals(Object) method The default is false- Parameters:
- useEquals-- trueif equals will be used for comparisons
 
- 
poolClosedThis 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.- Parameters:
- pool- - the pool that is being closed.
 
- 
poolStartedThis 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.- Parameters:
- pool- - the pool that is being closed.
 
 
-