Class FallbackPolicy
- java.lang.Object
-
- fish.payara.microprofile.faulttolerance.policy.Policy
-
- fish.payara.microprofile.faulttolerance.policy.FallbackPolicy
-
- All Implemented Interfaces:
Serializable
public final class FallbackPolicy extends Policy
The resolved "cached" information of aFallback
annotation an a specific method.- Author:
- Jan Bernitt
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FallbackPolicy(Method annotated, Class<? extends org.eclipse.microprofile.faulttolerance.FallbackHandler<?>> value, String fallbackMethod)
FallbackPolicy(Method annotated, Class<? extends org.eclipse.microprofile.faulttolerance.FallbackHandler<?>> value, String fallbackMethod, Class<? extends Throwable>[] applyOn, Class<? extends Throwable>[] skipOn)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FallbackPolicy
create(jakarta.interceptor.InvocationContext context, FaultToleranceConfig config)
boolean
isFallbackApplied(Throwable ex)
Helper method that checks whether or not the given exception is should trigger applying the fallback or not.boolean
isHandlerPresent()
-
Methods inherited from class fish.payara.microprofile.faulttolerance.policy.Policy
checkAtLeast, checkAtLeast, checkAtLeast, checkAtMost, checkReturnsSameAs, checkReturnsSameAs, describe, isCaught
-
-
-
-
Method Detail
-
create
public static FallbackPolicy create(jakarta.interceptor.InvocationContext context, FaultToleranceConfig config)
-
isHandlerPresent
public boolean isHandlerPresent()
-
isFallbackApplied
public boolean isFallbackApplied(Throwable ex)
Helper method that checks whether or not the given exception is should trigger applying the fallback or not. Relevant section fromFallback
javadocs:When a method returns and the Fallback policy is present, the following rules are applied:
- If the method returns normally (doesn't throw), the result is simply returned.
- Otherwise, if the thrown object is assignable to any value in the
#skipOn()
parameter, the thrown object will be rethrown. - Otherwise, if the thrown object is assignable to any value in the
#applyOn()
parameter, the Fallback policy, detailed above, will be applied. - Otherwise the thrown object will be rethrown.
- Parameters:
ex
- The exception to check- Returns:
- true, when fallback should be applied, false to rethrow the exception
-
-