Interface UnitOfWorkFactory<UOW extends UnitOfWork>

    • Field Detail

      • unitOfWorkLog

        static final org.slf4j.Logger unitOfWorkLog
    • Method Detail

      • withUnitOfWork

        default <R> R withUnitOfWork​(dk.cloudcreate.essentials.shared.functional.CheckedSupplier<R> action)
        Works just like withUnitOfWork(CheckedFunction) except the action isn't provided an instance of the UnitOfWork
        The code in the action can always access the UnitOfWork by calling getRequiredUnitOfWork()
        Type Parameters:
        R - the return type from the action
        Parameters:
        action - the action that's performed in a UnitOfWork
        Returns:
        the result of running the action in a UnitOfWork
      • usingUnitOfWork

        default void usingUnitOfWork​(dk.cloudcreate.essentials.shared.functional.CheckedConsumer<UOW> unitOfWorkConsumer)
        Run the unitOfWorkConsumer in a UnitOfWork
        It works in two different ways:
        1.
        If no existing UnitOfWork then a new UnitOfWork is created and started, the unitOfWorkConsumer is called with this UnitOfWork
        When the unitOfWorkConsumer has completed, without throwing an exception, then the created UnitOfWork is committed.
        In case an exception was thrown then the created UnitOfWork is rolledback.

        2.
        If there's already an existing UnitOfWork then the unitOfWorkConsumer joins in with existing UnitOfWork and the unitOfWorkConsumer is called with the existing UnitOfWork
        When the unitOfWorkConsumer has completed, without throwing an exception, then the existing UnitOfWork is NOT committed, this is instead left to the original creator of the UnitOfWork to do
        In case an exception was thrown then the existing UnitOfWork is marked as rollback only.
        Parameters:
        unitOfWorkConsumer - the consumer that's called with a UnitOfWork
      • withUnitOfWork

        default <R> R withUnitOfWork​(dk.cloudcreate.essentials.shared.functional.CheckedFunction<UOW,​R> unitOfWorkFunction)
        Run the unitOfWorkFunction in a UnitOfWork
        It works in two different ways:
        1.
        If no existing UnitOfWork then a new UnitOfWork is created and started, the unitOfWorkFunction is called with this UnitOfWork
        When the unitOfWorkFunction has completed, without throwing an exception, then the created UnitOfWork is committed.
        In case an exception was thrown then the created UnitOfWork is rolledback.

        2.
        If there's already an existing UnitOfWork then the unitOfWorkFunction joins in with existing UnitOfWork and the unitOfWorkFunction is called with the existing UnitOfWork
        When the unitOfWorkFunction has completed, without throwing an exception, then the existing UnitOfWork is NOT committed, this is instead left to the original creator of the UnitOfWork to do
        In case an exception was thrown then the existing UnitOfWork is marked as rollback only.
        Parameters:
        unitOfWorkFunction - the consumer that's called with a UnitOfWork