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 void
begin()
Create a new transaction and associate it with the current thread.void
begin(int timeout)
Create a new transaction with the given timeout and associate it with the current thread.void
commit()
Complete the transaction associated with the current thread.int
getStatus()
Obtain the status of the transaction associated with the current thread.jakarta.transaction.Transaction
getTransaction()
Get the transaction object that represents the transaction context of the calling threadstatic TransactionManagerImpl
getTransactionManagerImpl()
get the singleton TransactionManagerImplstatic int
getXAResourceTimeOut()
static jakarta.resource.spi.XATerminator
getXATerminator()
Provides a handle to aXATerminator
instance.static void
initJTSProperties(Properties props, String logDir, boolean trace, String traceDir)
extends props with the JTS-related properties based on the specified parameters.static int
mapStatus(org.omg.CosTransactions.Status status)
given a CosTransactions Status, return the equivalent JTA Statusstatic void
recover(Enumeration xaResourceList)
The application server passes in the list of XAResource objects to be recovered.static void
recreate(Xid xid, long timeout)
Recreate a transaction based on the Xid.static void
release(Xid xid)
Release a transaction.void
resume(jakarta.transaction.Transaction suspended)
Resume the transaction context association of the calling thread with the transaction represented by the supplied Transaction object.void
rollback()
Roll back the transaction associated with the current thread.void
setRollbackOnly()
Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.void
setTransactionTimeout(int seconds)
Modify the timeout value that is associated with transactions started by subsequent invocations of the begin method.static void
setXAResourceTimeOut(int value)
used to set XAResource timeoutjakarta.transaction.Transaction
suspend()
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.SystemException
Create a new transaction and associate it with the current thread.- Specified by:
begin
in 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.SystemException
Create 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.SystemException
Complete the transaction associated with the current thread. When this method completes, the thread becomes associated with no transaction.- Specified by:
commit
in 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.SystemException
Roll back the transaction associated with the current thread. When this method completes, the thread becomes associated with no transaction.- Specified by:
rollback
in 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.SystemException
Modify the transaction associated with the current thread such that the only possible outcome of the transaction is to roll back the transaction.- Specified by:
setRollbackOnly
in 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.SystemException
Obtain the status of the transaction associated with the current thread.- Specified by:
getStatus
in 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.SystemException
Modify 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:
setTransactionTimeout
in 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.SystemException
Get the transaction object that represents the transaction context of the calling thread- Specified by:
getTransaction
in interfacejakarta.transaction.TransactionManager
- Throws:
jakarta.transaction.SystemException
-
resume
public void resume(jakarta.transaction.Transaction suspended) throws jakarta.transaction.InvalidTransactionException, IllegalStateException, jakarta.transaction.SystemException
Resume 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:
resume
in interfacejakarta.transaction.TransactionManager
- Throws:
jakarta.transaction.InvalidTransactionException
IllegalStateException
jakarta.transaction.SystemException
-
suspend
public jakarta.transaction.Transaction suspend() throws jakarta.transaction.SystemException
Suspend 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:
suspend
in 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 aXATerminator
instance. TheXATerminator
instance could be used by a resource adapter to flow-in transaction completion and crash recovery calls from an EIS.- Returns:
- a
XATerminator
instance.
-
setXAResourceTimeOut
public static void setXAResourceTimeOut(int value)
used to set XAResource timeout
-
getXAResourceTimeOut
public static int getXAResourceTimeOut()
-
-