Package com.sun.jts.jta
Class TransactionManagerImpl
- java.lang.Object
-
- com.sun.jts.jta.TransactionManagerImpl
-
- All Implemented Interfaces:
jakarta.transaction.TransactionManager
public class TransactionManagerImpl extends Object implements jakarta.transaction.TransactionManager
An implementation of jakarta.transaction.TransactionManager using JTA. This is a singleton object- Author:
- Tony Ng
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbegin()Create a new transaction and associate it with the current thread.voidbegin(int timeout)Create a new transaction with the given timeout and associate it with the current thread.voidcommit()Complete the transaction associated with the current thread.intgetStatus()Obtain the status of the transaction associated with the current thread.jakarta.transaction.TransactiongetTransaction()Get the transaction object that represents the transaction context of the calling threadstatic TransactionManagerImplgetTransactionManagerImpl()get the singleton TransactionManagerImplstatic intgetXAResourceTimeOut()static jakarta.resource.spi.XATerminatorgetXATerminator()Provides a handle to aXATerminatorinstance.static voidinitJTSProperties(Properties props, String logDir, boolean trace, String traceDir)extends props with the JTS-related properties based on the specified parameters.static intmapStatus(org.omg.CosTransactions.Status status)given a CosTransactions Status, return the equivalent JTA Statusstatic voidrecover(Enumeration xaResourceList)The application server passes in the list of XAResource objects to be recovered.static voidrecreate(Xid xid, long timeout)Recreate a transaction based on the Xid.static voidrelease(Xid xid)Release a transaction.voidresume(jakarta.transaction.Transaction suspended)Resume the transaction context association of the calling thread with the transaction represented by the supplied Transaction object.voidrollback()Roll back the transaction associated with the current thread.voidsetRollbackOnly()Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.voidsetTransactionTimeout(int seconds)Modify the timeout value that is associated with transactions started by subsequent invocations of the begin method.static voidsetXAResourceTimeOut(int value)used to set XAResource timeoutjakarta.transaction.Transactionsuspend()Suspend the transaction currently associated with the calling thread and return a Transaction object that represents the transaction context being suspended.
-
-
-
Method Detail
-
getTransactionManagerImpl
public static TransactionManagerImpl getTransactionManagerImpl()
get the singleton TransactionManagerImpl
-
initJTSProperties
public static void initJTSProperties(Properties props, String logDir, boolean trace, String traceDir)
extends props with the JTS-related properties based on the specified parameters. The properties will be used as part of ORB.init() call.- Parameters:
prop- the properties that will be extendedlogDir- directory for the log, current directory if nulltrace- enable JTS tracingtraceDir- directory for tracing, current directory if null
-
mapStatus
public static int mapStatus(org.omg.CosTransactions.Status status)
given a CosTransactions Status, return the equivalent JTA Status
-
begin
public void begin() throws jakarta.transaction.NotSupportedException, jakarta.transaction.SystemExceptionCreate a new transaction and associate it with the current thread.- Specified by:
beginin interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.NotSupportedException- Thrown if the thread is already associated with a transaction.jakarta.transaction.SystemException
-
begin
public void begin(int timeout) throws jakarta.transaction.NotSupportedException, jakarta.transaction.SystemExceptionCreate a new transaction with the given timeout and associate it with the current thread.- Throws:
jakarta.transaction.NotSupportedException- Thrown if the thread is already associated with a transaction.jakarta.transaction.SystemException
-
commit
public void commit() throws jakarta.transaction.RollbackException, jakarta.transaction.HeuristicMixedException, jakarta.transaction.HeuristicRollbackException, SecurityException, IllegalStateException, jakarta.transaction.SystemExceptionComplete the transaction associated with the current thread. When this method completes, the thread becomes associated with no transaction.- Specified by:
commitin interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.RollbackException- Thrown to indicate that the transaction has been rolled back rather than committed.jakarta.transaction.HeuristicMixedException- Thrown to indicate that a heuristic decision was made and that some relevant updates have been committed while others have been rolled back.jakarta.transaction.HeuristicRollbackException- Thrown to indicate that a heuristic decision was made and that all relevant updates have been rolled back.SecurityException- Thrown to indicate that the thread is not allowed to commit the transaction.IllegalStateException- Thrown if the current thread is not associated with a transaction.jakarta.transaction.SystemException
-
rollback
public void rollback() throws IllegalStateException, SecurityException, jakarta.transaction.SystemExceptionRoll back the transaction associated with the current thread. When this method completes, the thread becomes associated with no transaction.- Specified by:
rollbackin interfacejakarta.transaction.TransactionManager- Throws:
SecurityException- Thrown to indicate that the thread is not allowed to roll back the transaction.IllegalStateException- Thrown if the current thread is not associated with a transaction.jakarta.transaction.SystemException
-
setRollbackOnly
public void setRollbackOnly() throws IllegalStateException, jakarta.transaction.SystemExceptionModify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.- Specified by:
setRollbackOnlyin interfacejakarta.transaction.TransactionManager- Throws:
IllegalStateException- Thrown if the current thread is not associated with a transaction.jakarta.transaction.SystemException
-
getStatus
public int getStatus() throws jakarta.transaction.SystemExceptionObtain the status of the transaction associated with the current thread.- Specified by:
getStatusin interfacejakarta.transaction.TransactionManager- Returns:
- The transaction status. If no transaction is associated with the current thread, this method returns the Status.NoTransaction value.
- Throws:
jakarta.transaction.SystemException
-
setTransactionTimeout
public void setTransactionTimeout(int seconds) throws jakarta.transaction.SystemExceptionModify the timeout value that is associated with transactions started by subsequent invocations of the begin method.If an application has not called this method, the transaction service uses some default value for the transaction timeout.
- Specified by:
setTransactionTimeoutin interfacejakarta.transaction.TransactionManager- Parameters:
seconds- The value of the timeout in seconds. If the value is zero, the transaction service restores the default value. If the value is negative a SystemException is thrown.- Throws:
jakarta.transaction.SystemException- Thrown if the transaction manager encounters an unexpected error condition.
-
getTransaction
public jakarta.transaction.Transaction getTransaction() throws jakarta.transaction.SystemExceptionGet the transaction object that represents the transaction context of the calling thread- Specified by:
getTransactionin interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.SystemException
-
resume
public void resume(jakarta.transaction.Transaction suspended) throws jakarta.transaction.InvalidTransactionException, IllegalStateException, jakarta.transaction.SystemExceptionResume the transaction context association of the calling thread with the transaction represented by the supplied Transaction object. When this method returns, the calling thread is associated with the transaction context specified.- Specified by:
resumein interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.InvalidTransactionExceptionIllegalStateExceptionjakarta.transaction.SystemException
-
suspend
public jakarta.transaction.Transaction suspend() throws jakarta.transaction.SystemExceptionSuspend the transaction currently associated with the calling thread and return a Transaction object that represents the transaction context being suspended. If the calling thread is not associated with a transaction, the method returns a null object reference. When this method returns, the calling thread is associated with no transaction.- Specified by:
suspendin interfacejakarta.transaction.TransactionManager- Throws:
jakarta.transaction.SystemException
-
recover
public static void recover(Enumeration xaResourceList)
The application server passes in the list of XAResource objects to be recovered.- Parameters:
xaResourceList- list of XAResource objects.
-
recreate
public static void recreate(Xid xid, long timeout) throws jakarta.resource.spi.work.WorkException
Recreate a transaction based on the Xid. This call causes the calling thread to be associated with the specified transaction.- Parameters:
xid- the Xid object representing a transaction.timeout- positive, non-zero value for transaction timeout.- Throws:
jakarta.resource.spi.work.WorkException
-
release
public static void release(Xid xid) throws jakarta.resource.spi.work.WorkException
Release a transaction. This call causes the calling thread to be dissociated from the specified transaction.- Parameters:
xid- the Xid object representing a transaction.- Throws:
jakarta.resource.spi.work.WorkException
-
getXATerminator
public static jakarta.resource.spi.XATerminator getXATerminator()
Provides a handle to aXATerminatorinstance. TheXATerminatorinstance could be used by a resource adapter to flow-in transaction completion and crash recovery calls from an EIS.- Returns:
- a
XATerminatorinstance.
-
setXAResourceTimeOut
public static void setXAResourceTimeOut(int value)
used to set XAResource timeout
-
getXAResourceTimeOut
public static int getXAResourceTimeOut()
-
-