com.sun.jts.jta
Class TransactionManagerImpl

java.lang.Object
  extended by com.sun.jts.jta.TransactionManagerImpl
All Implemented Interfaces:
TransactionManager

public class TransactionManagerImpl
extends java.lang.Object
implements TransactionManager

An implementation of javax.transaction.TransactionManager using JTA. This is a singleton object

Author:
Tony Ng

Method Summary
 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.
 Transaction getTransaction()
          Get the transaction object that represents the transaction context of the calling thread
static TransactionManagerImpl getTransactionManagerImpl()
          get the singleton TransactionManagerImpl
static int getXAResourceTimeOut()
           
static XATerminator getXATerminator()
          Provides a handle to a XATerminator instance.
static void initJTSProperties(java.util.Properties props, java.lang.String logDir, boolean trace, java.lang.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 Status
static void recover(java.util.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(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 timeout
 Transaction suspend()
          Suspend the transaction currently associated with the calling thread and return a Transaction object that represents the transaction context being suspended.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTransactionManagerImpl

public static TransactionManagerImpl getTransactionManagerImpl()
get the singleton TransactionManagerImpl


initJTSProperties

public static void initJTSProperties(java.util.Properties props,
                                     java.lang.String logDir,
                                     boolean trace,
                                     java.lang.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 extended
logDir - directory for the log, current directory if null
trace - enable JTS tracing
traceDir - 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 NotSupportedException,
                  SystemException
Create a new transaction and associate it with the current thread.

Specified by:
begin in interface TransactionManager
Throws:
NotSupportedException - Thrown if the thread is already associated with a transaction.
SystemException

begin

public void begin(int timeout)
           throws NotSupportedException,
                  SystemException
Create a new transaction with the given timeout and associate it with the current thread.

Throws:
NotSupportedException - Thrown if the thread is already associated with a transaction.
SystemException

commit

public void commit()
            throws RollbackException,
                   HeuristicMixedException,
                   HeuristicRollbackException,
                   java.lang.SecurityException,
                   java.lang.IllegalStateException,
                   SystemException
Complete the transaction associated with the current thread. When this method completes, the thread becomes associated with no transaction.

Specified by:
commit in interface TransactionManager
Throws:
RollbackException - Thrown to indicate that the transaction has been rolled back rather than committed.
HeuristicMixedException - Thrown to indicate that a heuristic decision was made and that some relevant updates have been committed while others have been rolled back.
HeuristicRollbackException - Thrown to indicate that a heuristic decision was made and that all relevant updates have been rolled back.
java.lang.SecurityException - Thrown to indicate that the thread is not allowed to commit the transaction.
java.lang.IllegalStateException - Thrown if the current thread is not associated with a transaction.
SystemException

rollback

public void rollback()
              throws java.lang.IllegalStateException,
                     java.lang.SecurityException,
                     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 interface TransactionManager
Throws:
java.lang.SecurityException - Thrown to indicate that the thread is not allowed to roll back the transaction.
java.lang.IllegalStateException - Thrown if the current thread is not associated with a transaction.
SystemException

setRollbackOnly

public void setRollbackOnly()
                     throws java.lang.IllegalStateException,
                            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 interface TransactionManager
Throws:
java.lang.IllegalStateException - Thrown if the current thread is not associated with a transaction.
SystemException

getStatus

public int getStatus()
              throws SystemException
Obtain the status of the transaction associated with the current thread.

Specified by:
getStatus in interface TransactionManager
Returns:
The transaction status. If no transaction is associated with the current thread, this method returns the Status.NoTransaction value.
Throws:
SystemException

setTransactionTimeout

public void setTransactionTimeout(int seconds)
                           throws 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 interface 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:
SystemException - Thrown if the transaction manager encounters an unexpected error condition.

getTransaction

public Transaction getTransaction()
                           throws SystemException
Get the transaction object that represents the transaction context of the calling thread

Specified by:
getTransaction in interface TransactionManager
Throws:
SystemException

resume

public void resume(Transaction suspended)
            throws InvalidTransactionException,
                   java.lang.IllegalStateException,
                   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 interface TransactionManager
Throws:
InvalidTransactionException
java.lang.IllegalStateException
SystemException

suspend

public Transaction suspend()
                    throws 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 interface TransactionManager
Throws:
SystemException

recover

public static void recover(java.util.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 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:
WorkException

release

public static void release(Xid xid)
                    throws 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:
WorkException

getXATerminator

public static XATerminator getXATerminator()
Provides a handle to a XATerminator instance. The XATerminator 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()


Copyright © 2012 GlassFish Community. All Rights Reserved.