Interface Invocation

All Known Implementing Classes:
Invocation.Base, Invocation.Call, Invocation.Run

public interface Invocation
Method invocation used in MethodInterceptor.invoke(Invocation) for Aspects.

Represents a method invocation that can be intercepted with additional before and after invocation logic.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Invocation base type for both callable and runnable methods.
    static final class 
    Callable based Invocation with checked exceptions.
    static interface 
    Runnable with checked exceptions.
    static interface 
    Callable with checked exceptions.
    static final class 
    Runnable based Invocation.
  • Method Summary

    Modifier and Type
    Method
    Description
    Return the arguments used for this invocation.
    boolean
    Return whether this invocation has a registered recovery method
    Return the 'this' instance of the invocation.
    Invoke the underlying method returning the result.
    Invoke the recovery method associated for this invocation and return the result.
    default Object
    Invoke the underlying method returning the result.
    Return the method being called for this invocation.
    void
    result(Object result)
    Set the result that will be returned to the caller.
  • Method Details

    • invoke

      Object invoke() throws Throwable
      Invoke the underlying method returning the result.
      Returns:
      The result of the method call. This will return null for void methods.
      Throws:
      Throwable - Exception thrown by underlying method
    • invokeUnchecked

      default Object invokeUnchecked()
      Invoke the underlying method returning the result. Checked exceptions will be caught and rethrown as InvocationExceptions.
      Returns:
      The result of the method call. This will return null for void methods.
    • result

      void result(Object result)
      Set the result that will be returned to the caller.

      This will replace a prior result set by calling #invoke or can be used to provide a result allowing to skip calling #invoke altogether.

      Parameters:
      result - The result that will be returned to the caller.
    • arguments

      Object[] arguments()
      Return the arguments used for this invocation.
    • method

      Method method()
      Return the method being called for this invocation.
    • instance

      Object instance()
      Return the 'this' instance of the invocation.

      This is typically used when invoking fallback/recovery methods.

    • hasRecoveryMethod

      boolean hasRecoveryMethod()
      Return whether this invocation has a registered recovery method
    • invokeRecoveryMethod

      Object invokeRecoveryMethod(Throwable t)
      Invoke the recovery method associated for this invocation and return the result.
      Returns:
      The result of the method call. This will return null for void methods.
      Throws:
      IllegalStateException - if no fallback method is configured with this invocation