public interface TaskContext<T,S> extends Serializable
A task context is an object that is aware of the lifecycle of a task and can perform operations before and after the task evaluates. A common use case for task contexts is to be able to integrate 3rd party libraries into Flo in a way that makes them easily accessible to tasks.
Modifier and Type | Method and Description |
---|---|
default void |
onFail(Task<?> task,
Throwable throwable)
Will be called just after a task that is using this task context has failed evaluating.
|
default void |
onSuccess(Task<?> task,
S z)
Will be called just after a task that is using this task context has successfully evaluated.
|
default void |
preRun(Task<?> task)
Will be called just before a task that is using this task context starts evaluating.
|
T |
provide(EvalContext evalContext)
Creates a new instance of type
T . |
T provide(EvalContext evalContext)
T
. The given EvalContext
will be
the evaluation context for the task.
The task itself can be accessed through EvalContext.currentTask()
.evalContext
- The evaluation context in which the current task is being evaluateddefault void preRun(Task<?> task)
task
- The task being evaluateddefault void onSuccess(Task<?> task, S z)
task
- The task that evaluatedz
- The return value of the evaluated taskCopyright © 2020. All rights reserved.