Interface MethodCallListener

All Known Subinterfaces:
ProxyAwareListener
All Known Implementing Classes:
ElementAwareWebDriverListener, ElementInterceptor, ElementListInterceptor, InterceptorOfAListOfElements, InterceptorOfASingleElement, WidgetInterceptor, WidgetListInterceptor

public interface MethodCallListener
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final UUID
     
  • Method Summary

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

    • UNSET

      static final UUID UNSET
  • Method Details

    • beforeCall

      default void beforeCall(Object obj, Method method, 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 Object call(Object obj, Method method, Object[] args, Callable<?> original) throws 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:
      Throwable
    • afterCall

      default void afterCall(Object obj, Method method, Object[] args, 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 Object onError(Object obj, Method method, Object[] args, Throwable e) throws 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:
      Throwable