-
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface TransactionalRunnable
AnFunctionalInterfacethat wraps transactional code.Transactional code should not depend on any captured scope, but use the argument
Configurationpassed to therun(Configuration)method to derive its transaction context.If transactional code needs to depend on captured scope ("context"), then
ContextTransactionalRunnableis a better fit.- Author:
- Lukas Eder
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static TransactionalRunnableof(Collection<? extends TransactionalRunnable> runnables)Wrap a set of nestedTransactionalRunnableobjects in a single globalTransactionalRunnable.static TransactionalRunnableof(TransactionalRunnable... runnables)Wrap a set of nestedTransactionalRunnableobjects in a single globalTransactionalRunnable.voidrun(Configuration configuration)Run the transactional code.
-
-
-
Method Detail
-
run
void run(Configuration configuration) throws Throwable
Run the transactional code.If this method completes normally, and this is not a nested transaction, then the transaction will be committed. If this method completes with an exception (any
Throwable), then the transaction is rolled back to the beginning of thisTransactionalRunnable.- Parameters:
configuration- TheConfigurationin whose context the transaction is run.- Throws:
Throwable- Any exception that will cause a rollback of the code contained in this transaction. If this is a nested transaction, the rollback may be performed only to the state before executing thisTransactionalRunnable.
-
of
static TransactionalRunnable of(TransactionalRunnable... runnables)
Wrap a set of nestedTransactionalRunnableobjects in a single globalTransactionalRunnable.
-
of
static TransactionalRunnable of(Collection<? extends TransactionalRunnable> runnables)
Wrap a set of nestedTransactionalRunnableobjects in a single globalTransactionalRunnable.
-
-