Package org.flowable.engine.delegate

# Interface FlowableFutureJavaDelegate<Input,Output>

Type Parameters:
  `Input` - the input of the execution
  `Output` - the output of the execution

All Superinterfaces:
  `FutureJavaDelegate<Output>`

All Known Subinterfaces:
  `MapBasedFlowableFutureJavaDelegate`

public interface FlowableFutureJavaDelegate<Input,Output> extends FutureJavaDelegate<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:
  - `MapBasedFlowableFutureJavaDelegate`
  - `FutureJavaDelegate`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `afterExecution(DelegateExecution execution, Output executionData)`
  Method invoked with the result from `execute(Object)`.
  `Output`
  `execute(Input inputData)`
  Perform the actual execution of the delegate in another thread.
  `default CompletableFuture<Output>`
  `execute(DelegateExecution execution, AsyncTaskInvoker taskInvoker)`
  Perform the execution of the delegate, potentially on another thread.
  `Input`
  `prepareExecutionData(DelegateExecution execution)`
  Method invoked before doing the execution to extract needed that from the execution on the main thread.

- ## Method Details

  - ### execute

    default CompletableFuture<Output> execute(DelegateExecution execution, AsyncTaskInvoker taskInvoker)
    Description copied from interface: `FutureJavaDelegate`
    Perform the execution of the delegate, potentially on another thread. The result of the future is passed in the `FutureJavaDelegate.afterExecution(DelegateExecution, Object)` in order to store the data on the execution on the same thread as the caller of this method. IMPORTANT: the execution should only be used to read data before creating the future. The execution 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 given `taskInvoker`.

    Specified by:
      `execute` in interface `FutureJavaDelegate<Input>`
    Parameters:
      `execution` - the execution that can be used to extract data
      `taskInvoker` - the task invoker that can be used to execute expensive operation on another thread
    Returns:
      the output data of the execution

  - ### prepareExecutionData

    Input prepareExecutionData(DelegateExecution execution)
    Method invoked before doing the execution to extract needed that from the execution on the main thread. This should be used to prepare and extract data from the execution before doing the execution in a different thread.
    Parameters:
      `execution` - the execution from which to extract data
    Returns:
      the data for the delegate

  - ### execute

    Output execute(Input inputData)
    Perform the actual execution of the delegate in another thread. This uses `prepareExecutionData(DelegateExecution)` to get the needed data from the `DelegateExecution` and returns the output data that can is passed to `afterExecution(DelegateExecution, Object)`. IMPORTANT: This is a completely new thread which does not participate in the transaction of the process.
    Parameters:
      `inputData` - the input data for the execution created via `prepareExecutionData(DelegateExecution)`
    Returns:
      the output data of the execution
    See Also:
      - `execute(DelegateExecution, AsyncTaskInvoker)`

  - ### afterExecution

    void afterExecution(DelegateExecution execution, Output executionData)
    Method invoked with the result from `execute(Object)`. This should be used to set data on the `DelegateExecution`. This is on the same thread as `prepareExecutionData(DelegateExecution)` and participates in the process transaction.
    Specified by:
      `afterExecution` in interface `FutureJavaDelegate<Input>`
    Parameters:
      `execution` - the execution to which data can be set
      `executionData` - the execution data