Top Description Methods
org.eclipse.microprofile.faulttolerance

public Interface FallbackHandler<T>

Known Direct Implementers
org.eclipse.microprofile.faulttolerance.Fallback.DEFAULT

The handler instance used by the container to service a fallback invocation is a non-contextual instance created using the CDI SPI. The instance exists to service a single invocation only. The type parameter of the handler instance must be assignable to the return type of the method, where the Fallback is specified. The container must ensure this type safety. Otherwise, IllegalArgumentException should be thrown.

Usage

public class MyService {
    @Inject
    OtherService otherService;

    @Timeout(3000)
    @Fallback(MyFallback.class)
    Long getAmount() {
        return otherService.getAmount() * 2;
    }
}
The fallback handler implementation is shown below. The type parameter must be assignable to Long.
public class MyFallback implements FallbackHandler<Long> {
    Long handle(ExecutionContext context) {
        return 42;
    }
}
Authors
Emily Jiang, Ken Finnigan

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

the result of the fallback
handle
(ExecutionContext
the execution context
context
)

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

Method Detail

handleback to summary
public T handle(ExecutionContext context)

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

Parameters
context:ExecutionContext

the execution context

Returns:T

the result of the fallback