Interface InvocationEventHandler<C extends InvocationContext>

Type Parameters:
C - invocation context

public interface InvocationEventHandler<C extends InvocationContext>
Interface for handing invocation events.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if this event handler instance is enabled, otherwise false.
    void
    onFailure(@Nullable InvocationContext context, @NonNull Throwable cause)
    Invoked when an invocation fails.
    void
    onSuccess(@Nullable InvocationContext context, @Nullable Object result)
    Invoked with the result of the invocation when it is successful.
    preInvocation(@NonNull Object instance, @NonNull Method method, @NonNull Object[] args)
    Invoked before invoking the method on the instance.
  • Method Details

    • isEnabled

      boolean isEnabled()
      Returns true if this event handler instance is enabled, otherwise false.
      Returns:
      true if handler is enabled
    • preInvocation

      C preInvocation(@NonNull Object instance, @NonNull Method method, @NonNull Object[] args)
      Invoked before invoking the method on the instance.
      Parameters:
      instance - the instance that the method was invoked on.
      method - the Method corresponding to the interface method invoked on the instance.
      args - an array of objects containing the values of the arguments passed in the method invocation on the instance, or empty array if interface method takes no arguments. Arguments of primitive types are wrapped in instances of the appropriate primitive wrapper class, such as java.lang.Integer or java.lang.Boolean.
      Returns:
      the current invocation context. Null values are not recommended but are supported
    • onSuccess

      void onSuccess(@Nullable InvocationContext context, @Nullable Object result)
      Invoked with the result of the invocation when it is successful.
      Parameters:
      context - the current invocation context or null if preInvocation returned null, or threw an exception.
      result - the return value from invocation, or null if Void.
    • onFailure

      void onFailure(@Nullable InvocationContext context, @NonNull Throwable cause)
      Invoked when an invocation fails.

      If the invocation throws an InvocationTargetException, then the cause is passed to this method. Any other thrown object is passed unaltered.

      Parameters:
      context - the current invocation context or null if preInvocation returned null, or threw an exception.
      cause - the throwable which caused the failure.