Interface Fallback

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

A fallback or recovery method used with Aspects.

This isn't strictly required but more a helper to make it easier for aspects that want to use a fallback or recovery method.

  • Method Summary

    Modifier and Type
    Method
    Description
    static Fallback
    find(String name, Method method)
    Find and return the fallback given the name and original method.
    invoke(Invocation call, Throwable sourceException)
    Invoke the fallback method given the invocation and exception.
  • Method Details

    • find

      static Fallback find(String name, Method method) throws NoSuchMethodException
      Find and return the fallback given the name and original method.

      This will first try and find the method for the name that has the same parameters as the method but additionally takes a Throwable as the last parameter. If no matching method is found it then looks for the method with the name that just has the matching parameters (and not the additional throwable).

      Parameters:
      name - The name of the fallback method
      method - The original method which we match to using argument types.
      Returns:
      The fallback
      Throws:
      NoSuchMethodException - When no matching fallback method is found
    • invoke

      Object invoke(Invocation call, Throwable sourceException)
      Invoke the fallback method given the invocation and exception.
      Parameters:
      call - The invocation being executed
      sourceException - The exception thrown that triggers the use of the fallback method