T
- see: TransactionRunnable
public class RootTransactionRunnable<T> extends StartableTransactionRunnable<T>
Constructor and Description |
---|
RootTransactionRunnable() |
Modifier and Type | Method and Description |
---|---|
<U extends T> |
runIn(TransactionRunnable<U> parentRunnable)
Run this TransactionRunnable inside of a "parent" runnable.
|
start
asProvider, getProvidedContext
commit, complete, getContext, onCommit, onComplete, onPreRun, onRollback, onRun, preRun, rollback, run
public <U extends T> TransactionRunnable<U> runIn(TransactionRunnable<U> parentRunnable)
TransactionRunnable<DatabaseTransaction>
of a TransactionRunnable which does not offer database
access. However, when you add a runnable which does not need or offer database access to one which
does, this function returns that runnable casted to a type which does offer database access
(since it is running in one which does).
StartableTransactionRunnable<DbTransaction> transaction = new DbTransactionRunnable();
StartableTransactionRunnable<Standalone> standalone = new StandaloneTransactionRunnable();
TransactionRunnable<DbTransaction> runnableRequiringDb = new DbRequiringTransactionRunnable();
// This will not compile:
runnableRequiringDb.runIn(standalone);
// Because if it did, it would allow you to do this:
standalone.start();
// Ut oh, using the database outside of a transaction!
// This will work:
TransactionRunnable<DbTransaction> castedStandalone = standalone.runIn(transaction);
runnableRequiringDb.runIn(castedStandalone);
transaction.start();
This implementation throws an exception because it may not be used in a rootTR.
runIn
in class TransactionRunnable<T>
U
- The type of capabilities provided by the parent runnable.
This defines the state which the state which the storage engine is guaranteed to be in
when this runnable starts. It must extend the type of capabilities required by this
runnable.parentRunnable
- the TransactionRunnable to run this runnable inside of.TransactionRunnable.runIn(TransactionRunnable)
Copyright © 2004–2021 XWiki. All rights reserved.