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(jakarta.transaction.Transaction transaction) Locally commit the given provider transaction.jakarta.transaction.TransactioncreateNewTransaction(int timeout) Create and start a new local transaction, which is not associated with any particular thread.voiddropLocal(jakarta.transaction.Transaction transaction) Drop a local transaction from memory.voiddropRemote(jakarta.transaction.Transaction transaction) The transaction is expected to work with outflowed resources - it contains a remote subordinate enlistment.getKey(jakarta.transaction.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(jakarta.transaction.Transaction transaction, Class<T> providerInterfaceType) Attempt to acquire a provider interface instance from the given provider transaction.getResource(jakarta.transaction.Transaction transaction, Object key) Get a resource associated with the given transaction.booleangetRollbackOnly(jakarta.transaction.Transaction transaction) Determine if the given transaction is rollback-only.intgetTimeout(jakarta.transaction.Transaction transaction) Get the configured timeout of the given transaction (not the remaining time).jakarta.transaction.TransactionManagerGet the transaction manager.Get the XA importer.default XAResourceRegistrygetXAResourceRegistry(LocalTransaction transaction) Return the XAResource registry associated withtransaction.getXid(jakarta.transaction.Transaction transaction) Get the transaction ID of the given transaction.booleanisImported(jakarta.transaction.Transaction transaction) Determine whether the given transaction was imported or originated locally.voidputResource(jakarta.transaction.Transaction transaction, Object key, Object value) Put a resource on to the given transaction.putResourceIfAbsent(jakarta.transaction.Transaction transaction, Object key, Object value) Put a resource on to the given transaction if the resource does not already exist.voidregisterInterposedSynchronization(jakarta.transaction.Transaction transaction, jakarta.transaction.Synchronization sync) Register an interposed synchronization on the given transaction.voidrollbackLocal(jakarta.transaction.Transaction transaction) Locally roll back the given provider transaction.
-
Field Details
-
EMPTY
An empty provider which does not support new transactions.
-
-
Method Details
-
getTransactionManager
@NotNull jakarta.transaction.TransactionManager 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
@NotNull jakarta.transaction.Transaction createNewTransaction(int timeout) throws jakarta.transaction.SystemException, SecurityException 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:
jakarta.transaction.SystemException- if the creation of the transaction failed for some reasonSecurityException- if the caller is not authorized to create a transaction
-
isImported
boolean isImported(@NotNull jakarta.transaction.Transaction transaction) throws IllegalArgumentException 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 jakarta.transaction.Transaction transaction, @NotNull jakarta.transaction.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 jakarta.transaction.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 jakarta.transaction.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
boolean getRollbackOnly(@NotNull jakarta.transaction.Transaction transaction) throws IllegalArgumentException 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
@NotNull Object getKey(@NotNull jakarta.transaction.Transaction transaction) throws IllegalArgumentException 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 jakarta.transaction.Transaction transaction) throws jakarta.transaction.RollbackException, jakarta.transaction.HeuristicMixedException, jakarta.transaction.HeuristicRollbackException, SecurityException, IllegalStateException, jakarta.transaction.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:
jakarta.transaction.RollbackException- if the local commit operation throws this exceptionjakarta.transaction.HeuristicMixedException- if the local commit operation throws this exceptionjakarta.transaction.HeuristicRollbackException- if the local commit operation throws this exceptionSecurityException- if the local commit operation throws this exceptionIllegalStateException- if the local commit operation throws this exceptionjakarta.transaction.SystemException- if the local commit operation throws this exception
-
rollbackLocal
void rollbackLocal(@NotNull jakarta.transaction.Transaction transaction) throws IllegalStateException, jakarta.transaction.SystemException 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 exceptionjakarta.transaction.SystemException- if the local commit operation throws this exception
-
dropLocal
void dropLocal(@NotNull jakarta.transaction.Transaction transaction) 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
void dropRemote(@NotNull jakarta.transaction.Transaction transaction) 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
int getTimeout(@NotNull jakarta.transaction.Transaction transaction) 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
default <T> T getProviderInterface(jakarta.transaction.Transaction transaction, Class<T> providerInterfaceType) 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 jakarta.transaction.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:
jakarta.transaction.SystemException
-