public interface FallbackHandler<T>
Fallback
is specified. The container
must ensure this type safety. Otherwise, IllegalArgumentException
should be thrown.
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; } }
Modifier and Type | Method and Description |
---|---|
T |
handle(ExecutionContext context)
Handle the previous calling failure and then call alternative methods or perform any alternative operations.
|
T handle(ExecutionContext context)
context
- the execution context