Package io.automatiko.engine.api.uow
Interface WorkUnit<T>
-
public interface WorkUnit<T>Defines individual work unit that can be associated with unit of work
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidabort()Optional abort logic associated with the work unitstatic <S> WorkUnit<S>create(S data, Consumer<S> action)Creates new WorkUnit that has only action invoked upon completion of the unit of workstatic <S> WorkUnit<S>create(S data, Consumer<S> action, Consumer<S> compensation)Creates new WorkUnit that has both action invoked upon completion of the unit of work and compensation invoked in case of unit of work cancellation.Tdata()Returns data attached to the work unitvoidperform()Performs action associated with the work unit usually consuming datadefault Integerpriority()Returns desired priority for the work unit execution order
-
-
-
Method Detail
-
data
T data()
Returns data attached to the work unit- Returns:
- actual data of the work unit
-
perform
void perform()
Performs action associated with the work unit usually consuming data
-
abort
default void abort()
Optional abort logic associated with the work unit
-
priority
default Integer priority()
Returns desired priority for the work unit execution order- Returns:
- property as positive number
-
create
static <S> WorkUnit<S> create(S data, Consumer<S> action)
Creates new WorkUnit that has only action invoked upon completion of the unit of work- Parameters:
data- data associated with the workaction- work to be executed on given data- Returns:
- WorkUnit populated with data and action
-
create
static <S> WorkUnit<S> create(S data, Consumer<S> action, Consumer<S> compensation)
Creates new WorkUnit that has both action invoked upon completion of the unit of work and compensation invoked in case of unit of work cancellation.- Parameters:
data- data associated with the workaction- work to be executed on given datacompensation- revert action to be performed upon cancellation- Returns:
- WorkUnit populated with data, action and compensation
-
-