Top Description Inners Fields Constructors Methods
org.apache.tomcat.jdbc.pool.interceptor

public Class StatementDecoratorInterceptor

extends AbstractCreateStatementInterceptor
Class Inheritance
Known Direct Subclasses
org.apache.tomcat.jdbc.pool.interceptor.StatementCache
Imports
java.lang.reflect.Constructor, .InvocationHandler, .InvocationTargetException, .Method, .Proxy, java.sql.CallableStatement, .PreparedStatement, .ResultSet, .SQLException, .Statement, org.apache.juli.logging.Log, .LogFactory

Implementation of JdbcInterceptor that proxies resultSets and statements.
Author
Guillermo Fernandes

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
protected class
StatementDecoratorInterceptor.StatementProxy<T extends Statement>

Class to measure query execute time.

Field Summary

Modifier and TypeField and Description
protected static final String
protected static final String
protected static final String
private static final Log
protected static final String[]
protected static volatile Constructor<?>
resultSetConstructor

the constructor to create the resultSet proxies

Inherited from org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor:
constructorsCREATE_STATEMENTCREATE_STATEMENT_IDXEXECUTEEXECUTE_BATCHEXECUTE_TYPESEXECUTE_UPDATEPREPARE_CALLPREPARE_CALL_IDXPREPARE_STATEMENTPREPARE_STATEMENT_IDXSTATEMENT_TYPE_COUNTSTATEMENT_TYPES

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
protected Object

Returns:

A new proxy for the Statement
createDecorator
(Object
The proxy object on which the method that triggered the creation of the statement was called.
proxy
,
Method
The method that was called on the proxy
method
,
Object[]
The arguments passed as part of the method call to the proxy
args
,
Object
The statement object that is to be proxied
statement
,
Constructor<?>
The constructor for the desired proxy
constructor
,
String
The sql of of the statement
sql
)

Creates a proxy for a Statement.

public Object
createStatement(Object
the actual proxy object
proxy
,
Method
the method that was called. It will be one of the methods defined in STATEMENT_TYPES
method
,
Object[]
the arguments to the method
args
,
Object
the statement that the underlying connection created
statement
,
long
Elapsed time
time
)

Implements abstract org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.createStatement.

Creates a statement interceptor to monitor query response times

protected Constructor<?>
protected boolean
isExecuteQuery(String methodName)

protected boolean
protected boolean
isResultSet(Method method, boolean process)

Inherited from org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor:
getConstructorinvokeisExecuteisStatementprocessreset

Field Detail

EXECUTE_QUERYback to summary
protected static final String EXECUTE_QUERY

Hides org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.EXECUTE_QUERY.

GET_GENERATED_KEYSback to summary
protected static final String GET_GENERATED_KEYS
GET_RESULTSETback to summary
protected static final String GET_RESULTSET
loggerback to summary
private static final Log logger
RESULTSET_TYPESback to summary
protected static final String[] RESULTSET_TYPES
resultSetConstructorback to summary
protected static volatile Constructor<?> resultSetConstructor

the constructor to create the resultSet proxies

Constructor Detail

StatementDecoratorInterceptorback to summary
public StatementDecoratorInterceptor()

Method Detail

closeInvokedback to summary
public void closeInvoked()

Implements abstract org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.closeInvoked.

Doc from org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.closeInvoked.

Method invoked when the operation java.sql.Connection#close() is invoked.

Annotations
@Override
createDecoratorback to summary
protected Object createDecorator(Object proxy, Method method, Object[] args, Object statement, Constructor<?> constructor, String sql) throws InstantiationException, IllegalAccessException, InvocationTargetException

Creates a proxy for a Statement.

Parameters
proxy:Object

The proxy object on which the method that triggered the creation of the statement was called.

method:Method

The method that was called on the proxy

args:Object[]

The arguments passed as part of the method call to the proxy

statement:Object

The statement object that is to be proxied

constructor:Constructor<?>

The constructor for the desired proxy

sql:String

The sql of of the statement

Returns:Object

A new proxy for the Statement

Exceptions
InstantiationException:
Couldn't instantiate object
IllegalAccessException:
Inaccessible constructor
InvocationTargetException:
Exception thrown from constructor
createStatementback to summary
public Object createStatement(Object proxy, Method method, Object[] args, Object statement, long time)

Implements abstract org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.createStatement.

Creates a statement interceptor to monitor query response times

Parameters
proxy:Object

Doc from org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.createStatement.

the actual proxy object

method:Method

Doc from org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.createStatement.

the method that was called. It will be one of the methods defined in STATEMENT_TYPES

args:Object[]

Doc from org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.createStatement.

the arguments to the method

statement:Object

Doc from org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.createStatement.

the statement that the underlying connection created

time:long

Doc from org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.createStatement.

Elapsed time

Returns:Object

Doc from org.apache.tomcat.jdbc.pool.interceptor.AbstractCreateStatementInterceptor.createStatement.

a java.sql.Statement object

Annotations
@Override
getResultSetConstructorback to summary
protected Constructor<?> getResultSetConstructor() throws NoSuchMethodException
Annotations
@SuppressWarnings:deprecation
isExecuteQueryback to summary
protected boolean isExecuteQuery(String methodName)
isExecuteQueryback to summary
protected boolean isExecuteQuery(Method method)
isResultSetback to summary
protected boolean isResultSet(Method method, boolean process)
org.apache.tomcat.jdbc.pool.interceptor back to summary

protected Class StatementDecoratorInterceptor.ResultSetProxy

extends Object
implements InvocationHandler
Class Inheritance
  • java.lang.Object
  • org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptor.ResultSetProxy
All Implemented Interfaces
java.lang.reflect.InvocationHandler

Field Summary

Modifier and TypeField and Description
private Object
private Object

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
invoke(Object
the proxy instance that the method was invoked on
proxy
,
Method
the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
method
,
Object[]
an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
args
)

Implements java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

delegateback to summary
private Object delegate
stback to summary
private Object st

Constructor Detail

ResultSetProxyback to summary
public ResultSetProxy(Object st, Object delegate)

Method Detail

invokeback to summary
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable

Implements java.lang.reflect.InvocationHandler.invoke.

Doc from java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.

Parameters
proxy:Object

the proxy instance that the method was invoked on

method:Method

the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.

args:Object[]

an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.

Returns:Object

the value to return from the method invocation on the proxy instance. If the declared return type of the interface method is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type. If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, a ClassCastException will be thrown by the method invocation on the proxy instance.

Annotations
@Override
Exceptions
Throwable:
the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the interface method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.
org.apache.tomcat.jdbc.pool.interceptor back to summary

protected Class StatementDecoratorInterceptor.StatementProxy<T extends Statement>

extends Object
implements InvocationHandler
Class Inheritance
  • java.lang.Object
  • org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptor.StatementProxy
All Implemented Interfaces
java.lang.reflect.InvocationHandler
Known Direct Subclasses
org.apache.tomcat.jdbc.pool.interceptor.StatementCache.CachedStatement

Class to measure query execute time.

Field Summary

Modifier and TypeField and Description
private Object
protected boolean
private Object
private Constructor<?>
protected T
private String

Constructor Summary

AccessConstructor and Description
public
StatementProxy(T delegate, String sql)

Method Summary

Modifier and TypeMethod and Description
public void
public Object
public Object
public Constructor<?>
public T
public String
public Object
invoke(Object
the proxy instance that the method was invoked on
proxy
,
Method
the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.
method
,
Object[]
an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
args
)

Implements java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result.

public void
public void
public void
setConstructor(Constructor<?> constructor)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

actualProxyback to summary
private Object actualProxy
closedback to summary
protected boolean closed
connectionback to summary
private Object connection
constructorback to summary
private Constructor<?> constructor
delegateback to summary
protected T delegate
sqlback to summary
private String sql

Constructor Detail

StatementProxyback to summary
public StatementProxy(T delegate, String sql)

Method Detail

closeInvokedback to summary
public void closeInvoked()
getActualProxyback to summary
public Object getActualProxy()
getConnectionback to summary
public Object getConnection()
getConstructorback to summary
public Constructor<?> getConstructor()
getDelegateback to summary
public T getDelegate()
getSqlback to summary
public String getSql()
invokeback to summary
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable

Implements java.lang.reflect.InvocationHandler.invoke.

Doc from java.lang.reflect.InvocationHandler.invoke.

Processes a method invocation on a proxy instance and returns the result. This method will be invoked on an invocation handler when a method is invoked on a proxy instance that it is associated with.

Parameters
proxy:Object

the proxy instance that the method was invoked on

method:Method

the Method instance corresponding to the interface method invoked on the proxy instance. The declaring class of the Method object will be the interface that the method was declared in, which may be a superinterface of the proxy interface that the proxy class inherits the method through.

args:Object[]

an array of objects containing the values of the arguments passed in the method invocation on the proxy instance, or null if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.

Returns:Object

the value to return from the method invocation on the proxy instance. If the declared return type of the interface method is a primitive type, then the value returned by this method must be an instance of the corresponding primitive wrapper class; otherwise, it must be a type assignable to the declared return type. If the value returned by this method is null and the interface method's return type is primitive, then a NullPointerException will be thrown by the method invocation on the proxy instance. If the value returned by this method is otherwise not compatible with the interface method's declared return type as described above, a ClassCastException will be thrown by the method invocation on the proxy instance.

Annotations
@Override
Exceptions
Throwable:
the exception to throw from the method invocation on the proxy instance. The exception's type must be assignable either to any of the exception types declared in the throws clause of the interface method or to the unchecked exception types java.lang.RuntimeException or java.lang.Error. If a checked exception is thrown by this method that is not assignable to any of the exception types declared in the throws clause of the interface method, then an UndeclaredThrowableException containing the exception that was thrown by this method will be thrown by the method invocation on the proxy instance.
setActualProxyback to summary
public void setActualProxy(Object proxy)
setConnectionback to summary
public void setConnection(Object proxy)
setConstructorback to summary
public void setConstructor(Constructor<?> constructor)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override