Package org.flowable.cmmn.api.delegate
Interface FlowablePlanItemFutureJavaDelegate<Input,Output>
- Type Parameters:
Input
- the input of the executionOutput
- the output of the execution
- All Superinterfaces:
PlanItemFutureJavaDelegate<Output>
- All Known Subinterfaces:
MapBasedFlowablePlanItemFutureJavaDelegate
public interface FlowablePlanItemFutureJavaDelegate<Input,Output>
extends PlanItemFutureJavaDelegate<Output>
Convenience class which always uses the
AsyncTaskInvoker
to execute the async data.
Provides intermediate methods to prepare the execution data before executing and do the
actual execution without the need to work with futures.- Author:
- Filip Hrisafov
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterExecution
(DelegatePlanItemInstance planItemInstance, Output executionData) Method invoked with the result fromexecute(Object)
.Perform the actual execution of the delegate in another thread.default CompletableFuture<Output>
execute
(DelegatePlanItemInstance planItemInstance, org.flowable.common.engine.api.async.AsyncTaskInvoker taskInvoker) Perform the execution of the delegate, potentially on another thread.prepareExecutionData
(DelegatePlanItemInstance planItemInstance) Method invoked before doing the execution to extract needed that from the planItemInstance on the main thread.
-
Method Details
-
execute
default CompletableFuture<Output> execute(DelegatePlanItemInstance planItemInstance, org.flowable.common.engine.api.async.AsyncTaskInvoker taskInvoker) Description copied from interface:PlanItemFutureJavaDelegate
Perform the execution of the delegate, potentially on another thread. The result of the future is passed in thePlanItemFutureJavaDelegate.afterExecution(DelegatePlanItemInstance, Object)
in order to store the data on the planItemInstance on the same thread as the caller of this method. IMPORTANT: the planItemInstance should only be used to read data before creating the future. The planItemInstance should not be used in the task that will be executed on a new thread.The
AsyncTaskInvoker
is in order to schedule an execution on a different thread. However, it is also possible to use a different scheduler, or return a future not created by the giventaskInvoker
.- Specified by:
execute
in interfacePlanItemFutureJavaDelegate<Input>
- Parameters:
planItemInstance
- the planItemInstance that can be used to extract datataskInvoker
- the task invoker that can be used to execute expensive operation on another thread- Returns:
- the output data of the execution
-
prepareExecutionData
Method invoked before doing the execution to extract needed that from the planItemInstance on the main thread. This should be used to prepare and extract data from the planItemInstance before doing the execution in a different thread.- Parameters:
planItemInstance
- the planItemInstance from which to extract data- Returns:
- the data for the delegate
-
execute
Perform the actual execution of the delegate in another thread. This usesprepareExecutionData(DelegatePlanItemInstance)
to get the needed data from theDelegatePlanItemInstance
and returns the output data that can is passed toafterExecution(DelegatePlanItemInstance, Object)
. IMPORTANT: This is a completely new thread which does not participate in the transaction of the case.- Parameters:
inputData
- the input data for the execution created viaprepareExecutionData(DelegatePlanItemInstance)
- Returns:
- the output data of the execution
- See Also:
-
afterExecution
Method invoked with the result fromexecute(Object)
. This should be used to set data on theDelegatePlanItemInstance
. This is on the same thread asprepareExecutionData(DelegatePlanItemInstance)
and participates in the case transaction.- Specified by:
afterExecution
in interfacePlanItemFutureJavaDelegate<Input>
- Parameters:
planItemInstance
- the planItemInstance to which data can be setexecutionData
- the execution data
-