Class RecoveryInterceptor

java.lang.Object
io.micronaut.retry.intercept.RecoveryInterceptor
All Implemented Interfaces:
io.micronaut.aop.Interceptor<Object,Object>, io.micronaut.aop.MethodInterceptor<Object,Object>, io.micronaut.core.order.Ordered

@Singleton public class RecoveryInterceptor extends Object implements io.micronaut.aop.MethodInterceptor<Object,Object>
A MethodInterceptor that will attempt to execute a Fallback when the target method is in an error state.
Since:
1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Positioned before the Retryable interceptor.

    Fields inherited from interface io.micronaut.aop.Interceptor

    ARGUMENT, CACHEABLE_LAZY_TARGET, HOTSWAP, LAZY, PROXY_TARGET

    Fields inherited from interface io.micronaut.core.order.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
    RecoveryInterceptor(io.micronaut.context.BeanContext beanContext)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Optional<? extends io.micronaut.inject.MethodExecutionHandle<?,Object>>
    findFallbackMethod(io.micronaut.aop.MethodInvocationContext<Object,Object> context)
    Finds a fallback method for the given context.
    int
     
    intercept(io.micronaut.aop.MethodInvocationContext<Object,Object> context)
     
    protected Object
    resolveFallback(io.micronaut.aop.MethodInvocationContext<Object,Object> context, RuntimeException exception)
    Resolves a fallback for the given execution context and exception.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.micronaut.aop.MethodInterceptor

    intercept
  • Field Details

    • POSITION

      public static final int POSITION
      Positioned before the Retryable interceptor.
  • Constructor Details

    • RecoveryInterceptor

      public RecoveryInterceptor(io.micronaut.context.BeanContext beanContext)
      Parameters:
      beanContext - The bean context to allow for DI of class annotated with Inject.
  • Method Details

    • getOrder

      public int getOrder()
      Specified by:
      getOrder in interface io.micronaut.core.order.Ordered
    • intercept

      public Object intercept(io.micronaut.aop.MethodInvocationContext<Object,Object> context)
      Specified by:
      intercept in interface io.micronaut.aop.MethodInterceptor<Object,Object>
    • findFallbackMethod

      public Optional<? extends io.micronaut.inject.MethodExecutionHandle<?,Object>> findFallbackMethod(io.micronaut.aop.MethodInvocationContext<Object,Object> context)
      Finds a fallback method for the given context.
      Parameters:
      context - The context
      Returns:
      The fallback method if it is present
    • resolveFallback

      protected Object resolveFallback(io.micronaut.aop.MethodInvocationContext<Object,Object> context, RuntimeException exception)
      Resolves a fallback for the given execution context and exception.
      Parameters:
      context - The context
      exception - The exception
      Returns:
      Returns the fallback value or throws the original exception