TransactionalProcessor
Provides the mechanism to run a block of code within a transaction boundary, using Spring Framework’s transaction primitives (such as TransactionDefinition and its annotation equivalent, Propagation ).
API
interface TransactionalProcessor {
Try<T> callTransactional(TransactionDefinition def, Callable<T> callable) (1)
Try<Void> runTransactional(TransactionDefinition def, ThrowingRunnable runnable) (2)
Try<T> callTransactional(Propagation propagation, Callable<T> callable) (3)
Try<Void> runTransactional(Propagation propagation, ThrowingRunnable runnable) (4)
Try<T> callWithinCurrentTransactionElseCreateNew(Callable<T> callable) (5)
Try<Void> runWithinCurrentTransactionElseCreateNew(ThrowingRunnable runnable) (6)
}
1 | callTransactional(TransactionDefinition, Callable)
Runs given callable with a transactional boundary, where the detailed transactional behavior is governed by given TransactionDefinition def . |
2 | runTransactional(TransactionDefinition, ThrowingRunnable)
Runs given runnable with a transactional boundary, where the detailed transactional behavior is governed by given TransactionDefinition def . |
3 | callTransactional(Propagation, Callable)
Runs given callable with a transactional boundary, where the detailed transactional behavior is governed by given Propagation propagation . |
4 | runTransactional(Propagation, ThrowingRunnable)
Runs given runnable with a transactional boundary, where the detailed transactional behavior is governed by given Propagation propagation . |
5 | callWithinCurrentTransactionElseCreateNew(Callable)
Runs given callable within an existing transactional boundary, or in the absence of such a boundary, creates a new one. |
6 | runWithinCurrentTransactionElseCreateNew(ThrowingRunnable)
Runs given runnable within an existing transactional boundary, or in the absence of such a boundary creates a new one. |
Members
callTransactional(TransactionDefinition, Callable)
Runs given callable with a transactional boundary, where the detailed transactional behavior is governed by given TransactionDefinition def .
runTransactional(TransactionDefinition, ThrowingRunnable)
Runs given runnable with a transactional boundary, where the detailed transactional behavior is governed by given TransactionDefinition def .
callTransactional(Propagation, Callable)
Runs given callable with a transactional boundary, where the detailed transactional behavior is governed by given Propagation propagation .
runTransactional(Propagation, ThrowingRunnable)
Runs given runnable with a transactional boundary, where the detailed transactional behavior is governed by given Propagation propagation .
More fine grained control is given via #runTransactional(TransactionDefinition, ThrowingRunnable)
Implementation
The TransactionService is a sub-interface of this interface. The Core Runtime Services module provides a default implementation, TransactionServiceSpring.