Class StatementFacade

All Implemented Interfaces:
InvocationHandler

public class StatementFacade extends AbstractCreateStatementInterceptor
Facade that creates statement and result set proxies.

The handles implement only the standard JDBC interfaces, so the driver's own classes are never visible through a cast. Every result set handed back - including cursors returned through getObject(...) - is sealed to the borrow. The Wrapper methods are delegated to the driver; an unwrapped driver object is not retired when the borrow ends, so statements underneath are kept alive only by StatementFinalizer or by the application closing them.

Sealing follows the declared type: a value that is not itself a result set is passed through unchanged, so cursors carried inside an Array, Struct or Ref are not sealed.

  • Constructor Details

    • StatementFacade

      protected StatementFacade(JdbcInterceptor interceptor)
      Constructs a StatementFacade.
      Parameters:
      interceptor - the next interceptor in the chain
  • Method Details

    • invoke

      public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
      Description copied from class: JdbcInterceptor
      Gets invoked each time an operation on Connection is invoked.

      The base implementation passes the call to the next interceptor in the chain. When there is no next interceptor, the call fails fast with a NullPointerException: a chain built by the pool always ends in the ProxyConnection terminal, so reaching this case means a chain was hand-built without a terminal link. Interceptors that do not answer a call themselves continue it with super.invoke(proxy, method, args).

      Specified by:
      invoke in interface InvocationHandler
      Overrides:
      invoke in class AbstractCreateStatementInterceptor
      Throws:
      Throwable
    • closeInvoked

      public void closeInvoked()
      Marks the borrow as ended, sealing every statement and result set handle this facade handed out so later calls are refused. Called before the connection leaves the application - on close and, through invoke(Object, Method, Object[]), on abort - so a handle cannot outlive the borrow and end up driving the session of the next borrower. This method does not physically close the driver statements; that is done by the driver's connection close, or by StatementFinalizer when configured. A borrow that is abandoned instead never runs this method, but the pool destroys an abandoned session rather than lending it again, so those handles only fail at the driver.
      Specified by:
      closeInvoked in class AbstractCreateStatementInterceptor
    • createStatement

      public Object createStatement(Object proxy, Method method, Object[] args, Object statement, long time)
      Wraps the statement produced underneath in a handle that retires with the borrow.
      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 in milliseconds, measured with the monotonic clock
      Returns:
      a Statement object