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 void abort()
      Optional abort logic associated with the work unit
      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
      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.
      T data()
      Returns data attached to the work unit
      void perform()
      Performs action associated with the work unit usually consuming data
      default Integer priority()
      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 work
        action - 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 work
        action - work to be executed on given data
        compensation - revert action to be performed upon cancellation
        Returns:
        WorkUnit populated with data, action and compensation