Interface TransactionProvider<C>

  • Type Parameters:
    C - the type of the transaction context
    All Known Subinterfaces:
    ThreadContextTransactionProvider

    public interface TransactionProvider<C>
    A provider interface for running 3rd party transactions within the Transactional framework.
    • Method Detail

      • runWithTransaction

        <T> T runWithTransaction​(Function<C,​T> procedure)
        Begin a transaction that is committed when the procedure exists or rolled back if the procedure throws an RuntimeException. The value thrown by the procedure should be rethrown.
        Type Parameters:
        T - the type of the returned result
        Parameters:
        procedure - the procedure to run within a transaction returning a result
        Returns:
        the result of the procedure
      • runWithoutTransaction

        <T> T runWithoutTransaction​(Function<C,​T> procedure)
        Acquire the result without wrapping the operation in a transaction. It is possible to define data access strictly in terms of Transactionals without forcing all interactions to be wrapped in transactions.

        A TransactionProvider implementation is not required to provide support for non-transactional procedures. In these cases the implementation should throw an UnsupportedOperationException.

        Type Parameters:
        T - the type of the returned result
        Parameters:
        procedure - the procedure to run with a non-transactional context
        Returns:
        the result of the procedure