Package com.gruelbox.transactionoutbox
Class StubThreadLocalTransactionManager
- java.lang.Object
-
- com.gruelbox.transactionoutbox.StubThreadLocalTransactionManager
-
- All Implemented Interfaces:
ThreadLocalContextTransactionManager
,TransactionManager
public class StubThreadLocalTransactionManager extends Object
A stub transaction manager that assumes no underlying database and thread local transaction management.
-
-
Constructor Summary
Constructors Constructor Description StubThreadLocalTransactionManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
inTransaction(TransactionalWork work)
Should do any work necessary to start a (new) transaction, callrunnable
and then either commit on success or rollback on failure, flushing and closing any prepared statements prior to a commit and firing post commit hooks immediately afterwardsvoid
inTransaction(Runnable runnable)
Should do any work necessary to start a (new) transaction, callrunnable
and then either commit on success or rollback on failure, flushing and closing any prepared statements prior to a commit and firing post commit hooks immediately afterwards<T> T
inTransactionReturns(TransactionalSupplier<T> supplier)
Should do any work necessary to start a (new) transaction, callrunnable
and then either commit on success or rollback on failure, flushing and closing any prepared statements prior to a commit and firing post commit hooks immediately afterwards.<T,E extends Exception>
TinTransactionReturnsThrows(ThrowingTransactionalSupplier<T,E> work)
Should do any work necessary to start a (new) transaction, callwork
and then either commit on success or rollback on failure, flushing and closing any prepared statements prior to a commit and firing post commit hooks immediately afterwards.<E extends Exception>
voidinTransactionThrows(ThrowingTransactionalWork<E> work)
Should do any work necessary to start a (new) transaction, callrunnable
and then either commit on success or rollback on failure, flushing and closing any prepared statements prior to a commit and firing post commit hooks immediately afterwards.<T,E extends Exception>
TrequireTransactionReturns(ThrowingTransactionalSupplier<T,E> work)
Runs the specified work in the context of the "current" transaction (the definition of which is up to the implementation).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.gruelbox.transactionoutbox.ThreadLocalContextTransactionManager
extractTransaction, injectTransaction, requireTransaction
-
-
-
-
Constructor Detail
-
StubThreadLocalTransactionManager
@Beta public StubThreadLocalTransactionManager()
-
-
Method Detail
-
inTransactionReturnsThrows
public <T,E extends Exception> T inTransactionReturnsThrows(ThrowingTransactionalSupplier<T,E> work) throws E extends Exception
Description copied from interface:TransactionManager
Should do any work necessary to start a (new) transaction, callwork
and then either commit on success or rollback on failure, flushing and closing any prepared statements prior to a commit and firing post commit hooks immediately afterwards.
-
inTransaction
public final void inTransaction(Runnable runnable)
Description copied from interface:TransactionManager
Should do any work necessary to start a (new) transaction, callrunnable
and then either commit on success or rollback on failure, flushing and closing any prepared statements prior to a commit and firing post commit hooks immediately afterwards- Specified by:
inTransaction
in interfaceTransactionManager
- Parameters:
runnable
- Code which must be called while the transaction is active..
-
inTransaction
public final void inTransaction(TransactionalWork work)
Description copied from interface:TransactionManager
Should do any work necessary to start a (new) transaction, callrunnable
and then either commit on success or rollback on failure, flushing and closing any prepared statements prior to a commit and firing post commit hooks immediately afterwards- Specified by:
inTransaction
in interfaceTransactionManager
- Parameters:
work
- Code which must be called while the transaction is active..
-
inTransactionReturns
public final <T> T inTransactionReturns(TransactionalSupplier<T> supplier)
Description copied from interface:TransactionManager
Should do any work necessary to start a (new) transaction, callrunnable
and then either commit on success or rollback on failure, flushing and closing any prepared statements prior to a commit and firing post commit hooks immediately afterwards.- Specified by:
inTransactionReturns
in interfaceTransactionManager
- Type Parameters:
T
- The type returned.- Parameters:
supplier
- Code which must be called while the transaction is active.- Returns:
- The result of
supplier
.
-
inTransactionThrows
public final <E extends Exception> void inTransactionThrows(ThrowingTransactionalWork<E> work) throws E extends Exception
Description copied from interface:TransactionManager
Should do any work necessary to start a (new) transaction, callrunnable
and then either commit on success or rollback on failure, flushing and closing any prepared statements prior to a commit and firing post commit hooks immediately afterwards.- Specified by:
inTransactionThrows
in interfaceTransactionManager
- Type Parameters:
E
- The exception type.- Parameters:
work
- Code which must be called while the transaction is active.- Throws:
E
- If any exception is thrown byRunnable
.E extends Exception
-
requireTransactionReturns
public <T,E extends Exception> T requireTransactionReturns(ThrowingTransactionalSupplier<T,E> work) throws E extends Exception, NoTransactionActiveException
Description copied from interface:ThreadLocalContextTransactionManager
Runs the specified work in the context of the "current" transaction (the definition of which is up to the implementation).- Specified by:
requireTransactionReturns
in interfaceThreadLocalContextTransactionManager
- Type Parameters:
T
- The type returned.E
- The exception type.- Parameters:
work
- Code which must be called while the transaction is active.- Returns:
- The value returned by
work
. - Throws:
E
- If any exception is thrown byRunnable
.NoTransactionActiveException
- If a transaction is not currently active.E extends Exception
-
-