Package fi.jubic.easyutils.transactional
Interface ThreadContextTransactionProvider
-
- All Superinterfaces:
TransactionProvider<Void>
public interface ThreadContextTransactionProvider extends TransactionProvider<Void>
ATransactionProviderfor thread context based implementations. A void transaction context is passed to the procedures and externalbegin(),commit()androllback()methods are called to manage the transaction scope.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidbegin()Begin a thread context bound transaction.voidcommit()Commit current thread context bound transaction.voidrollback()Rollback current thread context bound transaction.default <T> TrunWithoutTransaction(Function<Void,T> procedure)Acquire the result without wrapping the operation in a transaction.default <T> TrunWithTransaction(Function<Void,T> procedure)Begin a transaction that is committed when the procedure exists or rolled back if the procedure throws anRuntimeException.
-
-
-
Method Detail
-
begin
void begin()
Begin a thread context bound transaction.
-
commit
void commit()
Commit current thread context bound transaction.
-
rollback
void rollback()
Rollback current thread context bound transaction.
-
runWithTransaction
default <T> T runWithTransaction(Function<Void,T> procedure)
Description copied from interface:TransactionProviderBegin a transaction that is committed when the procedure exists or rolled back if the procedure throws anRuntimeException. The value thrown by the procedure should be rethrown.- Specified by:
runWithTransactionin interfaceTransactionProvider<Void>- 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
default <T> T runWithoutTransaction(Function<Void,T> procedure)
Description copied from interface:TransactionProviderAcquire the result without wrapping the operation in a transaction. It is possible to define data access strictly in terms ofTransactionals without forcing all interactions to be wrapped in transactions.A
TransactionProviderimplementation is not required to provide support for non-transactional procedures. In these cases the implementation should throw anUnsupportedOperationException.- Specified by:
runWithoutTransactionin interfaceTransactionProvider<Void>- 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
-
-