P - policy typepublic abstract class PolicyExecutor<P extends Policy> extends Object
Part of the Failsafe SPI.
| Modifier and Type | Field and Description |
|---|---|
protected AbstractExecution |
execution |
protected P |
policy |
| Modifier | Constructor and Description |
|---|---|
protected |
PolicyExecutor(P policy,
AbstractExecution execution) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
isFailure(ExecutionResult result)
Returns whether the
result is a success according to the policy. |
protected ExecutionResult |
onFailure(ExecutionResult result)
Performs post-execution handling for a
result that is considered a failure according to isFailure(ExecutionResult), possibly creating a new result, else returning the original result. |
protected CompletableFuture<ExecutionResult> |
onFailureAsync(ExecutionResult result,
Scheduler scheduler,
FailsafeFuture<Object> future)
Performs potentially asynchrononus post-execution handling for a failed
result, possibly creating a new
result, else returning the original result. |
protected void |
onSuccess(ExecutionResult result)
Performs post-execution handling for a
result that is considered a success according to isFailure(ExecutionResult). |
protected ExecutionResult |
postExecute(ExecutionResult result)
Performs synchronous post-execution handling for a
result. |
protected CompletableFuture<ExecutionResult> |
postExecuteAsync(ExecutionResult result,
Scheduler scheduler,
FailsafeFuture<Object> future)
Performs potentially asynchronous post-execution handling for a
result. |
protected ExecutionResult |
preExecute()
Called before execution to return an alternative result or failure such as if execution is not allowed or needed.
|
protected Supplier<ExecutionResult> |
supply(Supplier<ExecutionResult> supplier,
Scheduler scheduler)
Performs an execution by calling pre-execute else calling the supplier and doing a post-execute.
|
protected Supplier<CompletableFuture<ExecutionResult>> |
supplyAsync(Supplier<CompletableFuture<ExecutionResult>> supplier,
Scheduler scheduler,
FailsafeFuture<Object> future)
Performs an async execution by calling pre-execute else calling the supplier and doing a post-execute.
|
protected final AbstractExecution execution
protected PolicyExecutor(P policy, AbstractExecution execution)
protected ExecutionResult preExecute()
result else some alternative.protected Supplier<ExecutionResult> supply(Supplier<ExecutionResult> supplier, Scheduler scheduler)
protected ExecutionResult postExecute(ExecutionResult result)
result.protected Supplier<CompletableFuture<ExecutionResult>> supplyAsync(Supplier<CompletableFuture<ExecutionResult>> supplier, Scheduler scheduler, FailsafeFuture<Object> future)
protected CompletableFuture<ExecutionResult> postExecuteAsync(ExecutionResult result, Scheduler scheduler, FailsafeFuture<Object> future)
result.protected boolean isFailure(ExecutionResult result)
result is a success according to the policy. If the {code result} has no result, it is
not a failure.protected void onSuccess(ExecutionResult result)
result that is considered a success according to isFailure(ExecutionResult).protected ExecutionResult onFailure(ExecutionResult result)
result that is considered a failure according to isFailure(ExecutionResult), possibly creating a new result, else returning the original result.protected CompletableFuture<ExecutionResult> onFailureAsync(ExecutionResult result, Scheduler scheduler, FailsafeFuture<Object> future)
result, possibly creating a new
result, else returning the original result.Copyright © 2020. All rights reserved.