Class TransactionImple
java.lang.Object
com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple
- All Implemented Interfaces:
Transaction
,jakarta.transaction.Transaction
- Direct Known Subclasses:
TransactionImple
public class TransactionImple
extends Object
implements jakarta.transaction.Transaction, Transaction
-
Field Summary
Modifier and TypeFieldDescriptionprotected AtomicAction
protected static final XAResourceRecordWrappingPlugin
Fields inherited from interface com.arjuna.ats.jta.transaction.Transaction
XACONNECTION, XAMODIFIER
-
Constructor Summary
ModifierConstructorDescriptionprotected
TransactionImple
(int timeout) Create a new transaction with the specified timeout.protected
TransactionImple
(BasicAction curr) Create a new TransactionImple representation of a specified transaction. -
Method Summary
Modifier and TypeMethodDescriptionprotected Xid
baseXid()
If this is an imported transaction (via JCA) then this will be the Xid we are pretending to be.void
commit()
We should never throw a HeuristicRollbackException because if we get a HeuristicRollback from a resource, and can successfully rollback the other resources, this is then the same as having simply been forced to rollback the transaction during phase 1.protected void
Does the same as commit, but also changes the thread-to-tx association.protected Xid
createXid
(boolean branch, XAModifier theModifier, XAResource xaResource) boolean
delistResource
(XAResource xaRes, int flags) void
endAssociation
(Xid _tranID, XAResource _theXAResource, int xaState, int txInfoState) protected boolean
If there are any suspended RMs then we should call end on them before the transaction is terminated.boolean
enlistResource
(XAResource xaRes) This is the JTA compliant version of the method.boolean
enlistResource
(XAResource xaRes, Object[] params) boolean
Overloads Object.equals()final Uid
get_uid()
Returning list of throwables which are bound to transaction failure.long
int
int
static final TransactionImple
static final TransactionImple
getTransaction
(Uid id) final Xid
getTxId()
getTxLocalResource
(Object key) int
getXAResourceState
(XAResource xaRes) int
hashCode()
Return -1 if we fail.boolean
isAlive()
protected static final void
void
putTxLocalResource
(Object key, Object value) void
registerSynchronization
(jakarta.transaction.Synchronization sync) static final void
void
rollback()
protected void
Does the same as rollback, but also changes the thread-to-tx association.void
void
setRollbackOnly
(String reason) void
setXAResourceState
(XAResource xaRes, int state) boolean
MethodgetDeferredThrowables()
will return list of deferred throwables.toString()
-
Field Details
-
_theTransaction
-
_xaResourceRecordWrappingPlugin
-
-
Constructor Details
-
TransactionImple
public TransactionImple(int timeout) Create a new transaction with the specified timeout. -
TransactionImple
protected TransactionImple() -
TransactionImple
Create a new TransactionImple representation of a specified transaction.
-
-
Method Details
-
equals
Overloads Object.equals() -
hashCode
public int hashCode()Return -1 if we fail. -
commit
public void commit() throws jakarta.transaction.RollbackException, jakarta.transaction.HeuristicMixedException, jakarta.transaction.HeuristicRollbackException, SecurityException, jakarta.transaction.SystemException, IllegalStateExceptionWe should never throw a HeuristicRollbackException because if we get a HeuristicRollback from a resource, and can successfully rollback the other resources, this is then the same as having simply been forced to rollback the transaction during phase 1.- Specified by:
commit
in interfacejakarta.transaction.Transaction
- Throws:
jakarta.transaction.RollbackException
jakarta.transaction.HeuristicMixedException
jakarta.transaction.HeuristicRollbackException
SecurityException
jakarta.transaction.SystemException
IllegalStateException
-
rollback
public void rollback() throws IllegalStateException, SecurityException, jakarta.transaction.SystemException- Specified by:
rollback
in interfacejakarta.transaction.Transaction
- Throws:
IllegalStateException
SecurityException
jakarta.transaction.SystemException
-
setRollbackOnly
- Specified by:
setRollbackOnly
in interfacejakarta.transaction.Transaction
- Throws:
IllegalStateException
jakarta.transaction.SystemException
-
setRollbackOnly
public void setRollbackOnly(String reason) throws IllegalStateException, jakarta.transaction.SystemException - Throws:
IllegalStateException
jakarta.transaction.SystemException
-
getStatus
public int getStatus() throws jakarta.transaction.SystemException- Specified by:
getStatus
in interfacejakarta.transaction.Transaction
- Throws:
jakarta.transaction.SystemException
-
registerSynchronization
public void registerSynchronization(jakarta.transaction.Synchronization sync) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemException - Specified by:
registerSynchronization
in interfacejakarta.transaction.Transaction
- Throws:
jakarta.transaction.RollbackException
IllegalStateException
jakarta.transaction.SystemException
-
enlistResource
public boolean enlistResource(XAResource xaRes) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemException This is the JTA compliant version of the method. However, you had better know that your XAResource and family are truly compliant implementations. If they aren't then we may fail gracefully (e.g., some versions of Oracle don't work with arbitrary Xid implementations!) If the family isn't compliant, then you should use the other method and pass through a relevant XAModifier, which should address the issues we have already come across.- Specified by:
enlistResource
in interfacejakarta.transaction.Transaction
- Throws:
jakarta.transaction.RollbackException
IllegalStateException
jakarta.transaction.SystemException
-
enlistResource
public boolean enlistResource(XAResource xaRes, Object[] params) throws jakarta.transaction.RollbackException, IllegalStateException, jakarta.transaction.SystemException - Specified by:
enlistResource
in interfaceTransaction
- Throws:
jakarta.transaction.RollbackException
IllegalStateException
jakarta.transaction.SystemException
-
delistResource
public boolean delistResource(XAResource xaRes, int flags) throws IllegalStateException, jakarta.transaction.SystemException - Specified by:
delistResource
in interfacejakarta.transaction.Transaction
- Throws:
IllegalStateException
jakarta.transaction.SystemException
-
get_uid
- Specified by:
get_uid
in interfaceTransaction
-
getTxId
- Specified by:
getTxId
in interfaceTransaction
-
getDeferredThrowables
Returning list of throwables which are bound to transaction failure. This method is intended to be used when handling some error states. The result exception could be enriched with these returned ones. -
supportsDeferredThrowables
public boolean supportsDeferredThrowables()MethodgetDeferredThrowables()
will return list of deferred throwables.- Returns:
- true
-
toString
-
endAssociation
public void endAssociation(Xid _tranID, XAResource _theXAResource, int xaState, int txInfoState) throws XAException - Throws:
XAException
-
getXAResourceState
- Specified by:
getXAResourceState
in interfaceTransaction
-
setXAResourceState
-
getTransaction
-
getTransaction
-
getTxLocalResource
- Specified by:
getTxLocalResource
in interfaceTransaction
-
putTxLocalResource
- Specified by:
putTxLocalResource
in interfaceTransaction
-
isAlive
public boolean isAlive()- Specified by:
isAlive
in interfaceTransaction
-
commitAndDisassociate
protected void commitAndDisassociate() throws jakarta.transaction.RollbackException, jakarta.transaction.HeuristicMixedException, jakarta.transaction.HeuristicRollbackException, SecurityException, jakarta.transaction.SystemException, IllegalStateExceptionDoes the same as commit, but also changes the thread-to-tx association.- Throws:
jakarta.transaction.RollbackException
jakarta.transaction.HeuristicMixedException
jakarta.transaction.HeuristicRollbackException
SecurityException
jakarta.transaction.SystemException
IllegalStateException
-
baseXid
If this is an imported transaction (via JCA) then this will be the Xid we are pretending to be. Otherwise, it will be null.- Returns:
- null if we are a local transaction, a valid Xid if we have been imported.
-
rollbackAndDisassociate
protected void rollbackAndDisassociate() throws IllegalStateException, SecurityException, jakarta.transaction.SystemExceptionDoes the same as rollback, but also changes the thread-to-tx association.- Throws:
IllegalStateException
SecurityException
jakarta.transaction.SystemException
-
endSuspendedRMs
protected boolean endSuspendedRMs()If there are any suspended RMs then we should call end on them before the transaction is terminated. -
createXid
protected Xid createXid(boolean branch, XAModifier theModifier, XAResource xaResource) throws IOException, ObjectStoreException - Throws:
IOException
ObjectStoreException
-
putTransaction
-
removeTransaction
-
getTransactions
-
getResources
- Specified by:
getResources
in interfaceTransaction
-
getTimeout
public int getTimeout()- Specified by:
getTimeout
in interfaceTransaction
-
getRemainingTimeoutMills
public long getRemainingTimeoutMills()- Specified by:
getRemainingTimeoutMills
in interfaceTransaction
-
getSynchronizations
- Specified by:
getSynchronizations
in interfaceTransaction
-