Interface LocalTransactionProvider
- All Superinterfaces:
TransactionProvider
- All Known Implementing Classes:
JBossLocalTransactionProvider
A local transaction provider. Such a provider must implement all methods on this interface in order for
local transactions to be supported.
- Author:
- David M. Lloyd
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LocalTransactionProviderAn empty provider which does not support new transactions. -
Method Summary
Modifier and TypeMethodDescriptionvoidcommitLocal(Transaction transaction) Locally commit the given provider transaction.createNewTransaction(int timeout) Create and start a new local transaction, which is not associated with any particular thread.voiddropLocal(Transaction transaction) Drop a local transaction from memory.voiddropRemote(Transaction transaction) The transaction is expected to work with outflowed resources - it contains a remote subordinate enlistment.getKey(Transaction transaction) Get a key which has the same equals and hashCode behavior as the given transaction.default StringgetNameFromXid(Xid xid) Attempt to derive a node name from an XID.Get the unique node name of this provider.default <T> TgetProviderInterface(Transaction transaction, Class<T> providerInterfaceType) Attempt to acquire a provider interface instance from the given provider transaction.getResource(Transaction transaction, Object key) Get a resource associated with the given transaction.booleangetRollbackOnly(Transaction transaction) Determine if the given transaction is rollback-only.intgetTimeout(Transaction transaction) Get the configured timeout of the given transaction (not the remaining time).Get the transaction manager.Get the XA importer.default XAResourceRegistrygetXAResourceRegistry(LocalTransaction transaction) Return the XAResource registry associated withtransaction.getXid(Transaction transaction) Get the transaction ID of the given transaction.booleanisImported(Transaction transaction) Determine whether the given transaction was imported or originated locally.voidputResource(Transaction transaction, Object key, Object value) Put a resource on to the given transaction.putResourceIfAbsent(Transaction transaction, Object key, Object value) Put a resource on to the given transaction if the resource does not already exist.voidregisterInterposedSynchronization(Transaction transaction, Synchronization sync) Register an interposed synchronization on the given transaction.voidrollbackLocal(Transaction transaction) Locally roll back the given provider transaction.
-
Field Details
-
EMPTY
An empty provider which does not support new transactions.
-
-
Method Details
-
getTransactionManager
Get the transaction manager.- Returns:
- the transaction manager (must not be
null)
-
getXAImporter
Get the XA importer.- Returns:
- the XA importer (must not be
null)
-
createNewTransaction
Create and start a new local transaction, which is not associated with any particular thread.- Parameters:
timeout- the timeout to use for the new transaction- Returns:
- the new transaction (must not be
null) - Throws:
SystemException- if the creation of the transaction failed for some reasonSecurityException- if the caller is not authorized to create a transaction
-
isImported
Determine whether the given transaction was imported or originated locally.- Parameters:
transaction- the transaction to test (notnull)- Returns:
trueif the transaction was imported, orfalseif it was created locally- Throws:
IllegalArgumentException- if the transaction does not belong to this provider
-
registerInterposedSynchronization
void registerInterposedSynchronization(@NotNull Transaction transaction, @NotNull Synchronization sync) throws IllegalArgumentException Register an interposed synchronization on the given transaction.- Parameters:
transaction- the transaction (notnull)sync- the synchronization (notnull)- Throws:
IllegalArgumentException- if the transaction does not belong to this provider
-
getResource
Get a resource associated with the given transaction.- Parameters:
transaction- the transaction (notnull)key- the key to look up (notnull)- Returns:
- the resource, or
nullif none is set - Throws:
IllegalArgumentException- if the transaction does not belong to this provider
-
putResource
void putResource(@NotNull Transaction transaction, @NotNull Object key, Object value) throws IllegalArgumentException Put a resource on to the given transaction.- Parameters:
transaction- the transaction (notnull)key- the key to store under (notnull)value- the value to store- Throws:
IllegalArgumentException- if the transaction does not belong to this provider
-
putResourceIfAbsent
Object putResourceIfAbsent(@NotNull Transaction transaction, @NotNull Object key, Object value) throws IllegalArgumentException Put a resource on to the given transaction if the resource does not already exist. Providers which do not support this operation must emulate it.- Parameters:
transaction- the transaction (must not benull)key- the key to store under (notnull)value- the value to store- Returns:
- the existing value, or
nullif none is set - Throws:
IllegalArgumentException- if the transaction does not belong to this provider
-
getRollbackOnly
Determine if the given transaction is rollback-only.- Parameters:
transaction- the transaction (notnull)- Returns:
trueif the transaction is rollback-only,falseotherwise- Throws:
IllegalArgumentException- if the transaction does not belong to this provider
-
getKey
Get a key which has the same equals and hashCode behavior as the given transaction.- Parameters:
transaction- the transaction (notnull)- Returns:
- the key object (must not be
null) - Throws:
IllegalArgumentException- if the transaction does not belong to this provider
-
commitLocal
void commitLocal(@NotNull Transaction transaction) throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException Locally commit the given provider transaction. A given provider transaction will only be committed by this method orSubordinateTransactionControl.commit(boolean).- Parameters:
transaction- the transaction (notnull)- Throws:
RollbackException- if the local commit operation throws this exceptionHeuristicMixedException- if the local commit operation throws this exceptionHeuristicRollbackException- if the local commit operation throws this exceptionSecurityException- if the local commit operation throws this exceptionIllegalStateException- if the local commit operation throws this exceptionSystemException- if the local commit operation throws this exception
-
rollbackLocal
Locally roll back the given provider transaction. A given provider transaction will only be rolled back by this method orSubordinateTransactionControl.rollback().- Parameters:
transaction- the transaction (notnull)- Throws:
IllegalStateException- if the local commit operation throws this exceptionSystemException- if the local commit operation throws this exception
-
dropLocal
Drop a local transaction from memory. The transaction is locally-initiated and contains no remote subordinate enlistments, guaranteeing that the transaction can never reappear on this node.- Parameters:
transaction- the transaction to drop (notnull)
-
dropRemote
The transaction is expected to work with outflowed resources - it contains a remote subordinate enlistment. We can't use thedropLocal(Transaction)directly as the the transaction may reapear on this node during recovery. But this method gives a chance to the provider to reassign the removal timeout or some other work that needs to be done in case the in-flight transaction finished.- Parameters:
transaction- the transaction with ouflowed resources to announce of being finished (notnull)
-
getTimeout
Get the configured timeout of the given transaction (not the remaining time).- Parameters:
transaction- the transaction (notnull)- Returns:
- the number of seconds remaining
-
getXid
Get the transaction ID of the given transaction.- Parameters:
transaction- the transaction (notnull)- Returns:
- the transaction ID (must not be
null)
-
getNodeName
Get the unique node name of this provider.- Returns:
- the node name (must not be
null)
-
getNameFromXid
Attempt to derive a node name from an XID. If the XID is not in a recognized format,nullis returned.- Parameters:
xid- the XID (notnull)- Returns:
- the originating node name
-
getProviderInterface
Attempt to acquire a provider interface instance from the given provider transaction.- Type Parameters:
T- the provider interface type- Parameters:
transaction- the provider transaction (notnull)providerInterfaceType- the provider interface type class (notnull)- Returns:
- the provider interface instance, or
nullif none matches
-
getXAResourceRegistry
default XAResourceRegistry getXAResourceRegistry(LocalTransaction transaction) throws SystemException Return the XAResource registry associated withtransaction. If there is no such registry yet, one is created.- Parameters:
transaction- the transaction- Returns:
- the registry associated with
transaction. Can returnnullif this provider requires no XAResource registry - Throws:
SystemException
-