com.atomikos.icatch.jta
Class TransactionManagerImp

java.lang.Object
  extended by com.atomikos.icatch.jta.TransactionManagerImp
All Implemented Interfaces:
SubTxAwareParticipant, Serializable, Referenceable, TransactionManager, UserTransaction

public class TransactionManagerImp
extends Object
implements TransactionManager, SubTxAwareParticipant, Referenceable, UserTransaction

The JTA transaction manager implementation.

See Also:
Serialized Form

Field Summary
static String JTA_PROPERTY_NAME
          Transaction property name to indicate that the transaction is a JTA transaction.
 
Method Summary
 void begin()
          Create a new transaction and associate it with the current thread.
 void begin(int timeout)
          Custom begin to guarantee a timeout value through an argument.
 void commit()
           
 void committed(CompositeTransaction tx)
          Notification of termination.
static boolean getDefaultSerial()
          Get the default mode for new txs.
static int getDefaultTimeout()
          Get the default timeout value.
 Reference getReference()
           
 int getStatus()
           
 Transaction getTransaction()
           
 Transaction getTransaction(String tid)
          Retrieve an existing tx with given tid
static TransactionManager getTransactionManager()
          Get the installed transaction manager, if any.
 int getTransactionTimeout()
           
static void installTransactionManager(CompositeTransactionManager ctm, boolean automaticResourceRegistration)
          Install a transaction manager.
 void resume(Transaction tobj)
           
 void rollback()
           
 void rolledback(CompositeTransaction tx)
          Notification that some tx has been rolledback.
static void setDefaultSerial(boolean serial)
          Set the default serial mode for new txs.
static void setDefaultTimeout(int defaultTimeoutValue)
          Set the default transaction timeout value.
 void setRollbackOnly()
           
 void setTransactionTimeout(int seconds)
           
 Transaction suspend()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JTA_PROPERTY_NAME

public static final String JTA_PROPERTY_NAME
Transaction property name to indicate that the transaction is a JTA transaction. If this property is set to an arbitrary non-null value then a JTA transaction is assumed by this class. This property is used for detecting incompatible existing transactions: if a transaction exists without this property then the begin method will fail.

See Also:
Constant Field Values
Method Detail

setDefaultSerial

public static void setDefaultSerial(boolean serial)
Set the default serial mode for new txs.

Parameters:
serial - If true, then new txs will be set to serial mode.

getDefaultSerial

public static boolean getDefaultSerial()
Get the default mode for new txs.

Returns:
boolean If true, then new txs started through here will be in serial mode.

setDefaultTimeout

public static void setDefaultTimeout(int defaultTimeoutValue)
Set the default transaction timeout value.

Parameters:
defaultTimeoutValue - the default transaction timeout value in seconds.

getDefaultTimeout

public static int getDefaultTimeout()
Get the default timeout value.

Returns:
the default transaction timeout value in seconds.

installTransactionManager

public static void installTransactionManager(CompositeTransactionManager ctm,
                                             boolean automaticResourceRegistration)
Install a transaction manager.

Parameters:
ctm - The composite transaction manager to use.
automaticResourceRegistration - If true, then unknown XAResource instances should lead to the addition of a new temporary resource. If false, then unknown resources will lead to an exception.

getTransactionManager

public static TransactionManager getTransactionManager()
Get the installed transaction manager, if any.

Returns:
TransactionManager The installed instance, null if none.

getTransaction

public Transaction getTransaction(String tid)
Retrieve an existing tx with given tid

Parameters:
tid - The tid of the tx.
Returns:
Transaction The instance, or null if not found.

begin

public void begin()
           throws NotSupportedException,
                  SystemException
Create a new transaction and associate it with the current thread. If the current thread already has a transaction, then a local subtransaction will be created. NOTE: the default behaviour of JTA-created subtransactions is blocking. That is: if two of them access the same data, one of the will block. The purpose is to allow safe parallellism in the application. Allowing multiple subtransactions to access the same data has the effect of losing fault tolerance, due to the required XA mappings of JTA. In the native Atomikos mode, this behaviour can be tuned, however.

Specified by:
begin in interface TransactionManager
Specified by:
begin in interface UserTransaction
Throws:
NotSupportedException
SystemException

begin

public void begin(int timeout)
           throws NotSupportedException,
                  SystemException
Custom begin to guarantee a timeout value through an argument.

Throws:
NotSupportedException
SystemException

getTransaction

public Transaction getTransaction()
                           throws SystemException
Specified by:
getTransaction in interface TransactionManager
Throws:
SystemException
See Also:
TransactionManager

setTransactionTimeout

public void setTransactionTimeout(int seconds)
                           throws SystemException
Specified by:
setTransactionTimeout in interface TransactionManager
Specified by:
setTransactionTimeout in interface UserTransaction
Throws:
SystemException
See Also:
TransactionManager

getTransactionTimeout

public int getTransactionTimeout()

suspend

public Transaction suspend()
                    throws SystemException
Specified by:
suspend in interface TransactionManager
Throws:
SystemException
See Also:
TransactionManager

resume

public void resume(Transaction tobj)
            throws InvalidTransactionException,
                   IllegalStateException,
                   SystemException
Specified by:
resume in interface TransactionManager
Throws:
InvalidTransactionException
IllegalStateException
SystemException
See Also:
TransactionManager

getStatus

public int getStatus()
              throws SystemException
Specified by:
getStatus in interface TransactionManager
Specified by:
getStatus in interface UserTransaction
Throws:
SystemException
See Also:
TransactionManager

commit

public void commit()
            throws RollbackException,
                   HeuristicMixedException,
                   HeuristicRollbackException,
                   SystemException,
                   IllegalStateException,
                   SecurityException
Specified by:
commit in interface TransactionManager
Specified by:
commit in interface UserTransaction
Throws:
RollbackException
HeuristicMixedException
HeuristicRollbackException
SystemException
IllegalStateException
SecurityException
See Also:
TransactionManager

rollback

public void rollback()
              throws IllegalStateException,
                     SystemException,
                     SecurityException
Specified by:
rollback in interface TransactionManager
Specified by:
rollback in interface UserTransaction
Throws:
IllegalStateException
SystemException
SecurityException
See Also:
TransactionManager

setRollbackOnly

public void setRollbackOnly()
                     throws IllegalStateException,
                            SystemException
Specified by:
setRollbackOnly in interface TransactionManager
Specified by:
setRollbackOnly in interface UserTransaction
Throws:
IllegalStateException
SystemException
See Also:
TransactionManager

committed

public void committed(CompositeTransaction tx)
Description copied from interface: SubTxAwareParticipant
Notification of termination.

Specified by:
committed in interface SubTxAwareParticipant
Parameters:
tx - The composite transaction that has terminated locally at its node.
See Also:
SubTxAwareParticipant

rolledback

public void rolledback(CompositeTransaction tx)
Description copied from interface: SubTxAwareParticipant
Notification that some tx has been rolledback.

Specified by:
rolledback in interface SubTxAwareParticipant
See Also:
SubTxAwareParticipant

getReference

public Reference getReference()
                       throws NamingException
Specified by:
getReference in interface Referenceable
Throws:
NamingException
See Also:
Referenceable.getReference()


Copyright © 2011. All Rights Reserved.