Class ConnectionFactoryCallbackHandler

java.lang.Object
io.r2dbc.proxy.callback.ConnectionFactoryCallbackHandler
All Implemented Interfaces:
CallbackHandler

public final class ConnectionFactoryCallbackHandler extends Object
Proxy callback handler for ConnectionFactory.
Author:
Tadaya Tsuyukubo
  • Field Details

    • DEFAULT_INVOCATION_STRATEGY

      protected static final io.r2dbc.proxy.callback.CallbackHandlerSupport.MethodInvocationStrategy DEFAULT_INVOCATION_STRATEGY
    • proxyConfig

      protected final ProxyConfig proxyConfig
    • methodInvocationStrategy

      protected io.r2dbc.proxy.callback.CallbackHandlerSupport.MethodInvocationStrategy methodInvocationStrategy
  • Constructor Details

  • Method Details

    • invoke

      public Object invoke(Object proxy, Method method, @Nullable Object[] args) throws Throwable
      Description copied from interface: CallbackHandler
      When proxy is invoked, actual implementation of the proxy handler delegates the invocation to this method.
      Parameters:
      proxy - the proxy instance that the method was invoked on
      method - the method that has invoked on the proxy instance
      args - an array of objects that has passed to the method invocation. this can be null when method is invoked with no argument.
      Returns:
      result returned from the method invocation on the proxy instance. (can be null.)
      Throws:
      Throwable - the exception thrown from the method invocation on the proxy instance.
    • isCommonMethod

      protected boolean isCommonMethod(String methodName)
    • handleCommonMethod

      @Nullable protected Object handleCommonMethod(String methodName, Object original, @Nullable Object[] args, @Nullable Connection originalConnection)
    • proceedExecution

      protected Object proceedExecution(Method method, Object target, @Nullable Object[] args, ProxyExecutionListener listener, @Nullable ConnectionInfo connectionInfo, @Nullable Consumer<MethodExecutionInfo> onComplete) throws Throwable
      Augment method invocation and call method listener.
      Parameters:
      method - method to invoke on target
      target - an object being invoked
      args - arguments for the method. null if the method doesn't take any arguments.
      listener - listener that before/after method callbacks will be called
      connectionInfo - current connection information. null when invoked operation is not associated to the Connection.
      onComplete - a callback that will be invoked at successful termination(onComplete) of the result publisher.
      Returns:
      result of invoking the original object
      Throws:
      Throwable - thrown exception during the invocation
      IllegalArgumentException - if method is null
      IllegalArgumentException - if target is null
      IllegalArgumentException - if listener is null
    • interceptQueryExecution

      protected Flux<? extends Result> interceptQueryExecution(Publisher<? extends Result> publisher, io.r2dbc.proxy.callback.MutableQueryExecutionInfo executionInfo)
      Augment query execution result to hook up listener lifecycle.
      Parameters:
      publisher - query invocation result publisher
      executionInfo - query execution context info
      Returns:
      query invocation result flux
      Throws:
      IllegalArgumentException - if flux is null
      IllegalArgumentException - if executionInfo is null
    • setMethodInvocationStrategy

      public void setMethodInvocationStrategy(io.r2dbc.proxy.callback.CallbackHandlerSupport.MethodInvocationStrategy methodInvocationStrategy)
      Set CallbackHandlerSupport.MethodInvocationStrategy to invoke the original instance(non-proxy) and retrieve result.
      Parameters:
      methodInvocationStrategy - strategy for method invocation
      Throws:
      IllegalArgumentException - if methodInvocationStrategy is null
      See Also:
      • CallbackHandlerSupport.MethodInvocationStrategy