Module io.automatiko.engine.api
Interface WorkItemHandler
public interface WorkItemHandler
A work item handler is responsible for executing work items of a specific
type. They represent the glue code between an abstract, high-level work item
that is used inside the process and the implementation of this work item.
Work item handlers should be registered with the
WorkItemManager
for each type of work that can be executed in the engine.
A work item handler is responsible for executing a work item whenever the
work item manager delegates one to it. It should also notify the work item
manager when the work item has been completed.
It is also possible that a work item handler is requested to abort an
existing work item (that is still executing) because it is no longer
necessary. This might for example be because the process instance (or a part
of the process instance) that is was executing in is being aborted. The work
item handler should then try to abort this work item (if possible) and if
necessary clean up runtime state related to its execution.
For example, a work item handler that is responsible for executing email work
items will retrieve the necessary information from the work item (from, to,
body, etc.) and invoke the mail server. Afterwards, it will notify the
WorkItemManager that the work item was completed.-
Method Summary
Modifier and TypeMethodDescriptionvoidabortWorkItem(WorkItem workItem, WorkItemManager manager) The given work item should be aborted.voidexecuteWorkItem(WorkItem workItem, WorkItemManager manager) The given work item should be executed.default StringgetName()Returns name that it should be registered with, by default simple class name;default voidtransitionToPhase(WorkItem workItem, WorkItemManager manager, Transition<?> transition) Allows to transition given work item into another life cycle phase as defined in the given transition object.
-
Method Details
-
executeWorkItem
The given work item should be executed.- Parameters:
workItem- the work item that should be executedmanager- the manager that requested the work item to be executed
-
abortWorkItem
The given work item should be aborted.- Parameters:
workItem- the work item that should be abortedmanager- the manager that requested the work item to be aborted
-
getName
Returns name that it should be registered with, by default simple class name;- Returns:
- name that should this handler be registered with
-
transitionToPhase
default void transitionToPhase(WorkItem workItem, WorkItemManager manager, Transition<?> transition) Allows to transition given work item into another life cycle phase as defined in the given transition object.- Parameters:
workItem- work item to be transitionedtransition- life cycle phase to be transition to
-