Class RecoveryInterceptor

  • All Implemented Interfaces:
    io.micronaut.aop.Interceptor<java.lang.Object,​java.lang.Object>, io.micronaut.aop.MethodInterceptor<java.lang.Object,​java.lang.Object>, io.micronaut.core.order.Ordered

    @Singleton
    public class RecoveryInterceptor
    extends java.lang.Object
    implements io.micronaut.aop.MethodInterceptor<java.lang.Object,​java.lang.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 int POSITION
      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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<? extends io.micronaut.inject.MethodExecutionHandle<?,​java.lang.Object>> findFallbackMethod​(io.micronaut.aop.MethodInvocationContext<java.lang.Object,​java.lang.Object> context)
      Finds a fallback method for the given context.
      int getOrder()  
      java.lang.Object intercept​(io.micronaut.aop.MethodInvocationContext<java.lang.Object,​java.lang.Object> context)  
      protected java.lang.Object resolveFallback​(io.micronaut.aop.MethodInvocationContext<java.lang.Object,​java.lang.Object> context, java.lang.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 Detail

      • POSITION

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

      • RecoveryInterceptor

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

      • getOrder

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

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

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

        protected java.lang.Object resolveFallback​(io.micronaut.aop.MethodInvocationContext<java.lang.Object,​java.lang.Object> context,
                                                   java.lang.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