Interface MethodCallListener

    • Method Summary

      All Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default void afterCall​(java.lang.Object obj, java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Object result)
      The callback to be invoked after any public method of the proxy is called.
      default void beforeCall​(java.lang.Object obj, java.lang.reflect.Method method, java.lang.Object[] args)
      The callback to be invoked before any public method of the proxy is called.
      default java.lang.Object call​(java.lang.Object obj, java.lang.reflect.Method method, java.lang.Object[] args, java.util.concurrent.Callable<?> original)
      Override this callback in order to change/customize the behavior of a single or multiple methods.
      default java.lang.Object onError​(java.lang.Object obj, java.lang.reflect.Method method, java.lang.Object[] args, java.lang.Throwable e)
      The callback to be invoked if a public method or its Call replacement throws an exception.
    • Method Detail

      • beforeCall

        default void beforeCall​(java.lang.Object obj,
                                java.lang.reflect.Method method,
                                java.lang.Object[] args)
        The callback to be invoked before any public method of the proxy is called. The implementation is not expected to throw any exceptions. If a runtime exception is thrown then it is going to be silently logged.
        Parameters:
        obj - The proxy instance
        method - Method to be called
        args - Array of method arguments
      • call

        default java.lang.Object call​(java.lang.Object obj,
                                      java.lang.reflect.Method method,
                                      java.lang.Object[] args,
                                      java.util.concurrent.Callable<?> original)
                               throws java.lang.Throwable
        Override this callback in order to change/customize the behavior of a single or multiple methods. The original method result will be replaced with the result returned by this callback. Also, any exception thrown by it will replace original method(s) exception.
        Parameters:
        obj - The proxy instance
        method - Method to be replaced
        args - Array of method arguments
        original - The reference to the original method in case it is necessary to instrument its result.
        Returns:
        The type of the returned result should be castable to the returned type of the original method.
        Throws:
        java.lang.Throwable
      • afterCall

        default void afterCall​(java.lang.Object obj,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args,
                               java.lang.Object result)
        The callback to be invoked after any public method of the proxy is called. The implementation is not expected to throw any exceptions. If a runtime exception is thrown then it is going to be silently logged.
        Parameters:
        obj - The proxy instance
        method - Method to be called
        args - Array of method arguments
      • onError

        default java.lang.Object onError​(java.lang.Object obj,
                                         java.lang.reflect.Method method,
                                         java.lang.Object[] args,
                                         java.lang.Throwable e)
                                  throws java.lang.Throwable
        The callback to be invoked if a public method or its Call replacement throws an exception.
        Parameters:
        obj - The proxy instance
        method - Method to be called
        args - Array of method arguments
        e - Exception instance thrown by the original method invocation.
        Returns:
        You could either (re)throw the exception in this callback or overwrite the behavior and return a result from it. It is expected that the type of the returned argument could be cast to the returned type of the original method.
        Throws:
        java.lang.Throwable