Top Description Inners Methods
org.eclipse.microprofile.faulttolerance

public @Interface Fallback

extends Annotation
Annotations
@Documented
@Retention:RUNTIME
@Target:METHOD
@Inherited
@InterceptorBinding
Imports
java.lang.annotation.Documented, .ElementType, .Inherited, .Retention, .RetentionPolicy, .Target, jakarta.enterprise.util.Nonbinding, jakarta.interceptor.InterceptorBinding

The fallback annotation to define the fallback handler class so that a failure can be handled properly. The criteria are as follows:
  1. If value is specified, use FallbackHandler#handle(ExecutionContext) on the specified handler to execute the fallback.
  2. If fallbackMethod is specified, invoke the method specified by the fallbackMethod on the same class.
  3. If both are specified, the org.eclipse.microprofile.faulttolerance.exceptions.FaultToleranceDefinitionException must be thrown.

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.
If a method throws a Throwable which is not an Error or Exception, non-portable behavior results.
Author
Emily Jiang
See Also
value(), fallbackMethod(), applyOn(), skipOn()

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Fallback.DEFAULT

Create a default class so the value is not required to be set all the time.

Method Summary

Modifier and TypeMethod and Description
public Class<? extends Throwable>[]

Returns:

the exception types which should trigger Fallback
applyOn
()

The list of exception types which should trigger Fallback

Note that if a method throws a Throwable which is not an Error or Exception, non-portable behavior results.

public String

Returns:

the local method to fallback to
fallbackMethod
()

Specify the method name to fallback to.

public Class<? extends Throwable>[]

Returns:

the exception types which should not trigger Fallback
skipOn
()

The list of exception types which should not trigger Fallback

This list takes priority over the types listed in applyOn

Note that if a method throws a Throwable which is not an Error or Exception, non-portable behavior results.

public Class<? extends FallbackHandler<?>>

Returns:

the fallback class
value
()

Specify the fallback class to be used.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

applyOnback to summary
public Class<? extends Throwable>[] applyOn()

The list of exception types which should trigger Fallback

Note that if a method throws a Throwable which is not an Error or Exception, non-portable behavior results.

Returns:Class<? extends Throwable>[]

the exception types which should trigger Fallback

Annotations
@Nonbinding
fallbackMethodback to summary
public String fallbackMethod()

Specify the method name to fallback to. This method belongs to the same class as the method to fallback. The method must have the exact same arguments as the method being annotated. The method return type must be assignable to the return type of the method the fallback is for. Otherwise, org.eclipse.microprofile.faulttolerance.exceptions.FaultToleranceDefinitionException must be thrown.

Returns:String

the local method to fallback to

Annotations
@Nonbinding
skipOnback to summary
public Class<? extends Throwable>[] skipOn()

The list of exception types which should not trigger Fallback

This list takes priority over the types listed in applyOn

Note that if a method throws a Throwable which is not an Error or Exception, non-portable behavior results.

Returns:Class<? extends Throwable>[]

the exception types which should not trigger Fallback

Annotations
@Nonbinding
valueback to summary
public Class<? extends FallbackHandler<?>> value()

Specify the fallback class to be used. A new instance of the fallback class is returned. The instance is unmanaged. The type parameter of the fallback class must be assignable to the return type of the annotated method. Otherwise, org.eclipse.microprofile.faulttolerance.exceptions.FaultToleranceDefinitionException occurs.

Returns:Class<? extends FallbackHandler<?>>

the fallback class

Annotations
@Nonbinding
org.eclipse.microprofile.faulttolerance back to summary

public Class Fallback.DEFAULT

extends Object
implements FallbackHandler<Void>
Class Inheritance
All Implemented Interfaces
org.eclipse.microprofile.faulttolerance.FallbackHandler

Create a default class so the value is not required to be set all the time.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Void
handle(ExecutionContext
the execution context
context
)

Implements org.eclipse.microprofile.faulttolerance.FallbackHandler.handle.

Handle the previous calling failure and then call alternative methods or perform any alternative operations.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

DEFAULTback to summary
public DEFAULT()

Method Detail

handleback to summary
public Void handle(ExecutionContext context)

Implements org.eclipse.microprofile.faulttolerance.FallbackHandler.handle.

Doc from org.eclipse.microprofile.faulttolerance.FallbackHandler.handle.

Handle the previous calling failure and then call alternative methods or perform any alternative operations.

Parameters
context:ExecutionContext

the execution context

Returns:Void

the result of the fallback

Annotations
@Override