Package io.micronaut.retry.intercept
Class RecoveryInterceptor
java.lang.Object
io.micronaut.retry.intercept.RecoveryInterceptor
- All Implemented Interfaces:
Interceptor<Object,
,Object> MethodInterceptor<Object,
,Object> Ordered
@Singleton
public class RecoveryInterceptor
extends Object
implements MethodInterceptor<Object,Object>
A
MethodInterceptor
that will attempt to execute a Fallback
when the target method is in an error state.- Since:
- 1.0
- Author:
- graemerocher
-
Field Summary
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
-
Method Summary
Modifier and TypeMethodDescriptionOptional<? extends MethodExecutionHandle<?,
Object>> Finds a fallback method for the given context.int
getOrder()
intercept
(MethodInvocationContext<Object, Object> context) Extended version of theMethodInterceptor.intercept(InvocationContext)
method that accepts aMethodInvocationContext
.protected Object
resolveFallback
(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 POSITIONPositioned before theRetryable
interceptor.
-
-
Constructor Details
-
RecoveryInterceptor
- Parameters:
beanContext
- The bean context to allow for DI of class annotated withInject
.
-
-
Method Details
-
getOrder
public int getOrder() -
intercept
Description copied from interface:MethodInterceptor
Extended version of theMethodInterceptor.intercept(InvocationContext)
method that accepts aMethodInvocationContext
.- Specified by:
intercept
in interfaceMethodInterceptor<Object,
Object> - Parameters:
context
- The context- Returns:
- The result
-
findFallbackMethod
public Optional<? extends MethodExecutionHandle<?,Object>> findFallbackMethod(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(MethodInvocationContext<Object, Object> context, RuntimeException exception) Resolves a fallback for the given execution context and exception.- Parameters:
context
- The contextexception
- The exception- Returns:
- Returns the fallback value or throws the original exception
-