public interface TxContext
Transacional contexts are allocated and released using the API on the
TxManager
class. Objects that then wish to participate in the
transaction can obtain a reference to the current transacional context using
the TxManager.getLocalTxContext()
method. This allows us to separate
the application services from the transaction processing and at the same way
further decouple the business tier from the integration tier.
Modifier and Type | Method and Description |
---|---|
void |
abort()
Abort the transaction.
|
void |
commit()
Commit the transaction.
|
<T> T |
doAs(TxAction<T> action,
java.lang.String user,
java.lang.String password)
Perform an action as another user.
|
<T> T |
doAs(TxAction<T> action,
java.lang.String user,
java.lang.String password,
java.lang.String vault)
Perform an action as another user.
|
<T> T |
doCloned(TxAction<T> action)
Perform an action with a cloned version of the current context.
|
<T> T |
doPrivileged(TxAction<T> action)
Perform an action with system user access.
|
matrix.db.ClientTaskList |
getClientTasks()
Returns the client tasks associated with the Context.
|
matrix.db.Context |
getContext()
Returns the current Context that can be used to connect to the Matrix
database.
|
java.util.Locale |
getLocale()
Returns the
locale associated with the Context. |
TxType |
getTransactionType()
Returns the transaction type.
|
java.lang.String |
getUser()
Returns the name of the user.
|
boolean |
isAbort()
Returns whether the ongoing transaction MUST be aborted.
|
boolean |
isTransactionActive()
Whether a transaction is currently active.
|
TxSavepoint |
savepoint() |
void |
setAbort()
Calling this method will set a flag indicating that the ongoing
transaction MUST be aborted.
|
void |
start(boolean update)
Start a transaction.
|
void start(boolean update) throws TxException
update
- Whether the transaction type should be update or read. If
true then update else read.TxException
- If unable to start the transaction.void abort() throws TxException
TxException
- If unable to abort the transaction.void commit() throws TxException
TxException
- If unable to commit the transaction.IllegalTxStateException
- If called when the abort flag has been
set.TxSavepoint savepoint() throws TxException
TxException
- If unable to create a savepoint.IllegalTxStateException
- If no transaction has been started.boolean isTransactionActive()
TxType getTransactionType()
matrix.db.Context getContext() throws TxException
TxException
- If an error occurs when getting the context.void setAbort()
IllegalTxStateException
- If no transaction has been started.boolean isAbort()
matrix.db.ClientTaskList getClientTasks() throws TxException
TxException
- If unable to get the client tasks.java.util.Locale getLocale()
locale
associated with the Context.java.lang.String getUser()
<T> T doPrivileged(TxAction<T> action) throws TxException, TxActionException
action
- The action to perform.TxException
- If an exception if raised when executing the action.TxActionException
- If an exception is thrown from the
TxAction.run()
method. Use
Throwable.getCause()
to retrieve
the original exception that was thrown from the action.<T> T doAs(TxAction<T> action, java.lang.String user, java.lang.String password, java.lang.String vault) throws TxException, TxActionException
action
- The action to perform.user
- The name of the other user.password
- The other user's password.vault
- The vault (optional).TxException
- If an exception if raised when executing the action.TxActionException
- If an exception is thrown from the
TxAction.run()
method. Use
Throwable.getCause()
to retrieve
the original exception that was thrown from the action.<T> T doAs(TxAction<T> action, java.lang.String user, java.lang.String password) throws TxException, TxActionException
action
- The action to perform.user
- The name of the other user.password
- The other user's password.TxException
- If an exception if raised when executing the action.TxActionException
- If an exception is thrown from the
TxAction.run()
method. Use
Throwable.getCause()
to retrieve
the original exception that was thrown from the action.<T> T doCloned(TxAction<T> action) throws TxException, TxActionException
TxAction.run()
method.
Moreover, if a transaction is started on the clone it will be committed
when the TxAction.run()
method returns, unless some kind of
Throwable is thrown which will abort the transaction.
action
- The action to perform.TxException
- If an exception if raised when executing the action.TxActionException
- If an exception is thrown from the
TxAction.run()
method. Use
Throwable.getCause()
to retrieve
the original exception that was thrown from the action.Copyright © Technia AB. All Rights Reserved.