Class FallbackPolicy

  • All Implemented Interfaces:
    Serializable

    public final class FallbackPolicy
    extends Policy
    The resolved "cached" information of a Fallback annotation an a specific method.
    Author:
    Jan Bernitt
    See Also:
    Serialized Form
    • Field Detail

      • value

        public final Class<? extends org.eclipse.microprofile.faulttolerance.FallbackHandler<?>> value
      • fallbackMethod

        public final String fallbackMethod
      • method

        public final Method method
    • Constructor Detail

      • FallbackPolicy

        public FallbackPolicy​(Method annotated,
                              Class<? extends org.eclipse.microprofile.faulttolerance.FallbackHandler<?>> value,
                              String fallbackMethod)
      • FallbackPolicy

        public FallbackPolicy​(Method annotated,
                              Class<? extends org.eclipse.microprofile.faulttolerance.FallbackHandler<?>> value,
                              String fallbackMethod,
                              Class<? extends Throwable>[] applyOn,
                              Class<? extends Throwable>[] skipOn)
    • Method Detail

      • 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 from Fallback javadocs:
        When a method returns and the Fallback policy is present, the following rules are applied:
        1. If the method returns normally (doesn't throw), the result is simply returned.
        2. Otherwise, if the thrown object is assignable to any value in the #skipOn() parameter, the thrown object will be rethrown.
        3. Otherwise, if the thrown object is assignable to any value in the #applyOn() parameter, the Fallback policy, detailed above, will be applied.
        4. 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