Interface TransactionSession
- All Superinterfaces:
AutoCloseable, Closeable, OsidSession, OsidSession
The transaction session is coordinate transactions. A transaction
session allows for Transactions to be added to the list of
transactions it is managing. Upon a commit() , all registered
transactions receive a prepare() and a commit() . Upon an
abort() all registered transactions receive an abort() . A
TransactionSession itself may implement transactions (as it is an
OsidSession ) as a means of enabling a form of federated
transaction management.
-
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Cancels this transaction, rolling back the queue of operations since the start of this transaction.voidadd(Transaction transaction) Adds a Transaction to be managed by this transaction service.voidcommit()Commits the transaction and makes the state change(s) visible.getState()Gets the current state of this transaction.Methods inherited from interface OsidSession
closeMethods inherited from interface OsidSession
getAuthenticatedAgent, getAuthenticatedAgentId, getClockRate, getDate, getEffectiveAgent, getEffectiveAgentId, getFormatType, getLocale, isAuthenticated, startTransaction, supportsTransactionsModifier and TypeMethodDescriptionGets the agent authenticated to this session.Gets theIdof the agent authenticated to this session.Gets the rate of the service clock.getDate()Gets the service date which may be the current date or the effective date in which this session exists.Gets the effective agent in use by this session.Gets theIdof the effective agent in use by this session.Gets theDisplayTextformatTypepreference in effect for this session.Gets the locale indicating the localization preferences in effect for this session.booleanTests if an agent is authenticated to this session.Starts a new transaction for this sesson.booleanTests for the availability of transactions.
-
Method Details
-
add
void add(Transaction transaction) throws AlreadyExistsException, OperationFailedException, PermissionDeniedException Adds a Transaction to be managed by this transaction service.- Parameters:
transaction- the transaction to add- Throws:
AlreadyExistsException- transaction already addedIllegalStateException- this transaction has endedInvalidArgumentException- the session doesn't support transactionsNullArgumentException- anullargument providedOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.
-
commit
Commits the transaction and makes the state change(s) visible. This transaction is effectively closed and the only valid method that may be invoked isgetState().- Throws:
IllegalStateException- this transaction has been committed or abortedOperationFailedException- unable to complete requestPermissionDeniedException- authorization failure- Compliance:
mandatory- This method must be implemented.- Notes:
{@code- prepare()} should be invoked on all regstered transactions and iff all are successful should {@code commit()} be invoked on all registered transactions. In case of error on any {@code prepare()} , all transactions should be aborted. If an error occurs on a {@code commit()} after a transaction reported success on a {@code prepare()} after one or more transactions were already committed, then it is not ACID compliant and success should be assumed by committing the rest of the transactions. If a {@code commit()} error occurs when no transactions have been committed, then this operation should not proceed.
-
abort
void abort()Cancels this transaction, rolling back the queue of operations since the start of this transaction. This transaction is effectively closed and the only valid method that may be invoked isgetState().- Throws:
IllegalStateException- this transaction has been committed or aborted- Compliance:
mandatory- This method must be implemented.- Notes:
Invokes- {@code abort()} on all registered transactions().
-
getState
TransactionState getState()Gets the current state of this transaction.- Returns:
- the current state of this transaction
- Throws:
IllegalStateException- this transaction has been committed or aborted- Compliance:
mandatory- This method must be implemented.
-