Package org.apache.camel.support.task
Class ForegroundTask
- java.lang.Object
-
- org.apache.camel.support.task.ForegroundTask
-
- All Implemented Interfaces:
BlockingTask,Task
public class ForegroundTask extends Object implements BlockingTask
Runs a task in the foreground, executing for a given number of iteration and sleeping between each of them.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classForegroundTask.ForegroundTaskBuilderA builder helper for building new foreground tasks
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Durationelapsed()How long it took to run the taskbooleanrun(BooleanSupplier supplier)Run the task<T> booleanrun(Predicate<T> predicate, T payload)Run the task<T> Optional<T>run(Supplier<T> supplier, Predicate<T> predicate)Run a task until it produces a result
-
-
-
Method Detail
-
run
public <T> boolean run(Predicate<T> predicate, T payload)
Description copied from interface:BlockingTaskRun the task- Specified by:
runin interfaceBlockingTask- Type Parameters:
T- The type of the payload passed to the predicate when testing the task- Parameters:
predicate- the task as a predicate. The result of the predicate is used to check if the task has completed or not. The predicate must return true if the execution has completed or false otherwise. Failures on the task should be handled on the predicate using the payload as wrapper for In/Out if necessarypayload- a payload to be passed to the task- Returns:
- true if the task has completed successfully or false if: 1) the budget is exhausted or 2) the task was interrupted.
-
run
public boolean run(BooleanSupplier supplier)
Description copied from interface:BlockingTaskRun the task- Specified by:
runin interfaceBlockingTask- Parameters:
supplier- the task as a boolean supplier. The result is used to check if the task has completed or not. The supplier must return true if the execution has completed or false otherwise.- Returns:
- true if the task has completed successfully or false if: 1) the budget is exhausted or 2) the task was interrupted.
-
run
public <T> Optional<T> run(Supplier<T> supplier, Predicate<T> predicate)
Run a task until it produces a result- Type Parameters:
T- the type for the result- Parameters:
supplier- the supplier of the resultpredicate- a predicate to test if the result is acceptable- Returns:
- An optional with the result
-
-