Transaction
- public abstract class Transaction<C extends TransactionContainer> extends AbstractObservable implements EntityTransactionInterface, UseCacheResource
Abstract base implementation for all EntityTransactions (Transaction involving entities).
Handles caching, benchmark timing, the access to the back end, generates and checks entity ids, holds the state of the transaction and triggers the scheduler to run the jobs.
- Author:
Timm Fitschen
Fields
CLEAN_UP
idRegistry
- protected EntityIdRegistry idRegistry
Constructors
Transaction
- protected Transaction(C container)
Transaction
Methods
check
- protected final void check()
See also:
{@link.execute()}
cleanUp
- protected abstract void cleanUp()
See also:
{@link.execute()}
commit
- protected void commit()
See also:
{@link.execute()}
execute
- public final void execute()
The main transaction execution method.
This method calls the following other internal methods and scheduled jobs stored in the
internal Schedule object
:init
- MakeSchedule
, resolve names to ids, aquire read access.preCheck
- Load/generateEntityACL
s, check if any updates are to be processed.Schedule.runJobs(PRE_CHECK)
- SeeTransactionStage.PRE_CHECK
.check
- only run the jobs in the CHECK stage, seeTransactionStage.CHECK
.Schedule.runJobs(POST_CHECK)
- SeeTransactionStage.POST_CHECK
.postCheck
- currently, nothing happens here (just there for consistency).preTransaction
- acquire write access (if necessary)Schedule.runJobs(PRE_TRANSACTION)
- SeeTransactionStage.PRE_TRANSACTION
.transaction
: This is typically the main method of a Transaction.Schedule.runJobs(POST_TRANSACTION)
- SeeTransactionStage.POST_TRANSACTION
.postTransaction
- Add success messageswriteHistory
- write the transaction history logscommit
- commit the changesrollBack
: Only in the case of errors - rollback any changes (also file-system changes).cleanUp
: Always - cleanup the transaction (e.g. remove temporary files).notifyObservers(CLEAN_UP)
: Also always - for any jobs that do their own clean-up.
See also:
{@linkTransactionStage}.
getAccess
getAccessManager
- public static DatabaseAccessManager getAccessManager()
getCache
getContainer
- public C getContainer()
getSchedule
getTimestamp
- public UTCDateTime getTimestamp()
getTransactionBenchmark
- public TransactionBenchmark getTransactionBenchmark()
getTransactor
- public Subject getTransactor()
getUseCacheResourceDelegate
- public UseCacheResource getUseCacheResourceDelegate()
init
- protected abstract void init()
See also:
{@link.execute()}
logHistory
- public abstract boolean logHistory()
Return true iff this transaction should be logged in the transaction history logs.
makeSchedule
- protected void makeSchedule()
Implementation note: Not called in this class, but may be used by subclasses.
E.g. in
Retrieve
andWriteTransaction
.
matchIdPattern
postCheck
- protected abstract void postCheck()
See also:
{@link.execute()}
postTransaction
- protected abstract void postTransaction()
See also:
{@link.execute()}
preCheck
- protected abstract void preCheck()
See also:
{@link.execute()}
preTransaction
- protected abstract void preTransaction()
See also:
{@link.execute()}
rollBack
- protected void rollBack()
See also:
{@link.execute()}
setAccess
setUseCacheResourceDelegate
- public void setUseCacheResourceDelegate(UseCacheResource delegate)
transaction
- protected abstract void transaction()
See also:
{@link.execute()}