Interface LocalTransactionProvider
-
- All Superinterfaces:
TransactionProvider
- All Known Implementing Classes:
JBossLocalTransactionProvider
public interface LocalTransactionProvider extends TransactionProvider
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
Fields Modifier and Type Field Description static LocalTransactionProviderEMPTYAn empty provider which does not support new transactions.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidcommitLocal(Transaction transaction)Locally commit the given provider transaction.TransactioncreateNewTransaction(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.ObjectgetKey(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.StringgetNodeName()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.ObjectgetResource(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).TransactionManagergetTransactionManager()Get the transaction manager.XAImportergetXAImporter()Get the XA importer.default XAResourceRegistrygetXAResourceRegistry(LocalTransaction transaction)Return the XAResource registry associated withtransaction.XidgetXid(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.ObjectputResourceIfAbsent(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 Detail
-
EMPTY
static final LocalTransactionProvider EMPTY
An empty provider which does not support new transactions.
-
-
Method Detail
-
getTransactionManager
@NotNull TransactionManager getTransactionManager()
Get the transaction manager.- Returns:
- the transaction manager (must not be
null)
-
getXAImporter
@NotNull XAImporter getXAImporter()
Get the XA importer.- Returns:
- the XA importer (must not be
null)
-
createNewTransaction
@NotNull Transaction createNewTransaction(int timeout) throws 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:
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 Transaction transaction) throws IllegalArgumentExceptionDetermine 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 IllegalArgumentExceptionRegister 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
Object getResource(@NotNull Transaction transaction, @NotNull Object key)
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 IllegalArgumentExceptionPut 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
boolean getRollbackOnly(@NotNull Transaction transaction) throws IllegalArgumentExceptionDetermine 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 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 Transaction transaction) throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemExceptionLocally 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
void rollbackLocal(@NotNull Transaction transaction) throws IllegalStateException, SystemExceptionLocally 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
void dropLocal(@NotNull 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 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 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
@NotNull Xid getXid(@NotNull Transaction transaction)
Get the transaction ID of the given transaction.- Parameters:
transaction- the transaction (notnull)- Returns:
- the transaction ID (must not be
null)
-
getNodeName
@NotNull String getNodeName()
Get the unique node name of this provider.- Returns:
- the node name (must not be
null)
-
getNameFromXid
default String getNameFromXid(@NotNull Xid xid)
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(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 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
-
-