@ProviderType public interface TransactionContext
Modifier and Type | Method and Description |
---|---|
boolean |
getRollbackOnly()
Is this transaction marked for rollback only
|
Object |
getScopedValue(Object key)
Get a value scoped to this transaction
|
Object |
getTransactionKey()
Get the key associated with the current transaction
|
TransactionStatus |
getTransactionStatus() |
boolean |
isReadOnly() |
void |
postCompletion(Consumer<TransactionStatus> job)
Register a callback that will be made after the scope completes
|
void |
preCompletion(Runnable job)
Register a callback that will be made before a scope completes.
|
void |
putScopedValue(Object key,
Object value)
Associate a value with this transaction
|
void |
registerLocalResource(LocalResource resource)
Register a Local resource with the current transaction
|
void |
registerXAResource(XAResource resource,
String recoveryId)
Register an XA resource with the current transaction
|
void |
setRollbackOnly()
Mark this transaction for rollback
|
boolean |
supportsLocal() |
boolean |
supportsXA() |
Object getTransactionKey()
Object getScopedValue(Object key)
key
- null
void putScopedValue(Object key, Object value)
key
- value
- boolean getRollbackOnly() throws IllegalStateException
IllegalStateException
- if no transaction is activevoid setRollbackOnly() throws IllegalStateException
IllegalStateException
- if no transaction is activeTransactionStatus getTransactionStatus()
void preCompletion(Runnable job) throws IllegalStateException
For transactional scopes the state of the scope will be either
TransactionStatus.ACTIVE
or
TransactionStatus.MARKED_ROLLBACK
. Pre-completion callbacks may
call setRollbackOnly()
to prevent a commit from proceeding.
For no-transaction scopes the state of the scope will always be
TransactionStatus.NO_TRANSACTION
.
Exceptions thrown by pre-completion callbacks are treated as if they were thrown by the scoped work, including any configured commit or rollback behaviors for transactional scopes.
job
- The action to perform before completing the scopeIllegalStateException
- if the transaction has already passed
beyond the TransactionStatus.MARKED_ROLLBACK
statevoid postCompletion(Consumer<TransactionStatus> job) throws IllegalStateException
For transactional scopes the state of the scope will be either
TransactionStatus.COMMITTED
or
TransactionStatus.ROLLED_BACK
.
For no-transaction scopes the state of the scope will always be
TransactionStatus.NO_TRANSACTION
.
Post-completion callbacks should not throw Exception
s and cannot
affect the outcome of a piece of scoped work
job
- IllegalStateException
- if no transaction is activeboolean supportsXA()
boolean supportsLocal()
boolean isReadOnly()
void registerXAResource(XAResource resource, String recoveryId) throws IllegalStateException
resource
- recoveryId
- The resource id to be used for recovery, the id may be
null
if this resource is not recoverable.
If an id is passed then a RecoverableXAResource
with
the same id must be registered in the service registry for
recovery to occur.
If the underlying TransactionControl
service does not
support recovery then it must treat the resource as if it is
not recoverable.
IllegalStateException
- if no transaction is active, or the current
transaction is not XA capablevoid registerLocalResource(LocalResource resource) throws IllegalStateException
resource
- IllegalStateException
- if no transaction is active, or the current
transaction does not support local resources.Copyright © Contributors to the Eclipse Foundation Licensed under the Eclipse Foundation Specification License – v1.0