Class StatementDecoratorInterceptor

  • All Implemented Interfaces:
    java.lang.reflect.InvocationHandler
    Direct Known Subclasses:
    StatementCache

    public class StatementDecoratorInterceptor
    extends AbstractCreateStatementInterceptor
    Implementation of JdbcInterceptor that proxies resultSets and statements.
    Author:
    Guillermo Fernandes
    • Field Detail

      • GET_GENERATED_KEYS

        protected static final java.lang.String GET_GENERATED_KEYS
        See Also:
        Constant Field Values
      • RESULTSET_TYPES

        protected static final java.lang.String[] RESULTSET_TYPES
      • resultSetConstructor

        protected static volatile java.lang.reflect.Constructor<?> resultSetConstructor
        the constructor to create the resultSet proxies
    • Constructor Detail

      • StatementDecoratorInterceptor

        public StatementDecoratorInterceptor()
    • Method Detail

      • getResultSetConstructor

        protected java.lang.reflect.Constructor<?> getResultSetConstructor()
                                                                    throws java.lang.NoSuchMethodException
        Throws:
        java.lang.NoSuchMethodException
      • createStatement

        public java.lang.Object createStatement​(java.lang.Object proxy,
                                                java.lang.reflect.Method method,
                                                java.lang.Object[] args,
                                                java.lang.Object statement,
                                                long time)
        Creates a statement interceptor to monitor query response times
        Specified by:
        createStatement in class AbstractCreateStatementInterceptor
        Parameters:
        proxy - the actual proxy object
        method - the method that was called. It will be one of the methods defined in AbstractCreateStatementInterceptor.STATEMENT_TYPES
        args - the arguments to the method
        statement - the statement that the underlying connection created
        time - Elapsed time
        Returns:
        a Statement object
      • createDecorator

        protected java.lang.Object createDecorator​(java.lang.Object proxy,
                                                   java.lang.reflect.Method method,
                                                   java.lang.Object[] args,
                                                   java.lang.Object statement,
                                                   java.lang.reflect.Constructor<?> constructor,
                                                   java.lang.String sql)
                                            throws java.lang.InstantiationException,
                                                   java.lang.IllegalAccessException,
                                                   java.lang.reflect.InvocationTargetException
        Creates a proxy for a Statement.
        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 proxy
        args - The arguments passed as part of the method call to the proxy
        statement - The statement object that is to be proxied
        constructor - The constructor for the desired proxy
        sql - The sql of of the statement
        Returns:
        A new proxy for the Statement
        Throws:
        java.lang.InstantiationException - Couldn't instantiate object
        java.lang.IllegalAccessException - Inaccessible constructor
        java.lang.reflect.InvocationTargetException - Exception thrown from constructor
      • isExecuteQuery

        protected boolean isExecuteQuery​(java.lang.String methodName)
      • isExecuteQuery

        protected boolean isExecuteQuery​(java.lang.reflect.Method method)
      • isResultSet

        protected boolean isResultSet​(java.lang.reflect.Method method,
                                      boolean process)