org.ow2.jonas.tm.jotm
Class JOTMTransactionService

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.ow2.jonas.lib.reconfig.ReconfigEmitter
          extended by org.ow2.jonas.lib.service.AbsServiceImpl
              extended by org.ow2.jonas.tm.jotm.JOTMTransactionService
All Implemented Interfaces:
NotificationBroadcaster, NotificationEmitter, Service, TransactionService

public class JOTMTransactionService
extends AbsServiceImpl
implements TransactionService

Transaction Service implementation. This singleton class must exist in each jonas server. This class manages a unique Current object that implements both TransactionManager and UserTransaction interfaces.

Author:
Philippe Durieux Contributor(s): Adriana Danes

Field Summary
protected  TransactionSynchronizationRegistry tsr
          TransactionSynchronizationRegistry object, to be shared by all components.
 
Fields inherited from class org.ow2.jonas.lib.reconfig.ReconfigEmitter
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
JOTMTransactionService()
           
 
Method Summary
 void attachTransaction(Xid xid, long timeout)
          Attach the current calling Thread to the given Xid.
 int commitXAResource(String xatx)
          administrator recovery action: Commit.
 void detachTransaction()
          Detach the current Thread of the running Transaction.
 void doStart()
          Start the Service Initialization of the service is already done.
 void doStop()
          Stop the transaction service.
 int forgetXAResource(String xatx)
          administrator recovery action: forget
 String[] getAllActiveTx()
          Get all currently executing transactions.
 Xid[] getAllActiveXids()
          Get all currently executing Xids.
 String[] getAllRecoveryTx()
          Get all transactions that require administrator recovery action.
 String[] getAllXAResource(String xtx)
          Get all XAResoures of a transaction that require administrator recovery action.
 int getTimeout()
           
 int getTotalBegunTransactions()
          Get begun transactions number.
 int getTotalCommittedTransactions()
          Get committed transactions number.
 int getTotalCurrentTransactions()
          Get current transactions number.
 int getTotalExpiredTransactions()
          Get expired transactions number.
 int getTotalRolledbackTransactions()
          Get rolled back transactions number.
 TransactionManager getTransactionManager()
          Gets the TransactionManager object instance.
 TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
          Gets the TransactionSynchronizationRegistry object instance.
 UserTransaction getUserTransaction()
          Gets the UserTransaction object instance.
 XATerminator getXATerminator()
          Gets the inflow transaction object that represents the transaction context of the calling thread.
 void resetAllTxTotalCounters()
          Reset all transaction counters.
 int rollbackXAResource(String xatx)
          administrator recovery action: rollback
 void setJmxService(JmxService jmxService)
           
 void setRegistryService(RegistryService registry)
           
 void setRemote(boolean remote)
           
 void setTimeout(int t)
          Sets the default transaction timeout and register Current in JNDI.
 void startResourceManagerRecovery()
          Start Resource Manager Recovery.
 
Methods inherited from class org.ow2.jonas.lib.service.AbsServiceImpl
convertToList, doInit, getDomainName, getJonasServerName, getName, getServerProperties, init, isStarted, setName, setServerProperties, start, stop, throwRequirementException, toString
 
Methods inherited from class org.ow2.jonas.lib.reconfig.ReconfigEmitter
initLogger, sendReconfigNotification, sendSaveNotification
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ow2.jonas.service.Service
getName, init, isStarted, setName, start, stop
 

Field Detail

tsr

protected TransactionSynchronizationRegistry tsr
TransactionSynchronizationRegistry object, to be shared by all components.

Constructor Detail

JOTMTransactionService

public JOTMTransactionService()
Method Detail

setRemote

public void setRemote(boolean remote)
Parameters:
remote - Use a remote TransactionManager ?

doStart

public void doStart()
             throws ServiceException
Start the Service Initialization of the service is already done.

Specified by:
doStart in class AbsServiceImpl
Throws:
ServiceException - if service start fails

doStop

public void doStop()
            throws ServiceException
Stop the transaction service. Not already implemented

Specified by:
doStop in class AbsServiceImpl
Throws:
ServiceException - if the service stop fails

getTransactionManager

public TransactionManager getTransactionManager()
Gets the TransactionManager object instance.

Specified by:
getTransactionManager in interface TransactionService
Returns:
the transaction manager

getXATerminator

public XATerminator getXATerminator()
                             throws XAException
Gets the inflow transaction object that represents the transaction context of the calling thread. If the calling thread is not associated with an inflow transaction, a null object reference is returned.

Specified by:
getXATerminator in interface TransactionService
Returns:
a XATerminator handle
Throws:
XAException

getUserTransaction

public UserTransaction getUserTransaction()
Gets the UserTransaction object instance.

Specified by:
getUserTransaction in interface TransactionService
Returns:
the user transaction object

getTransactionSynchronizationRegistry

public TransactionSynchronizationRegistry getTransactionSynchronizationRegistry()
Gets the TransactionSynchronizationRegistry object instance.

Specified by:
getTransactionSynchronizationRegistry in interface TransactionService
Returns:
the transaction synchronization registry object

startResourceManagerRecovery

public void startResourceManagerRecovery()
                                  throws XAException
Start Resource Manager Recovery.

Specified by:
startResourceManagerRecovery in interface TransactionService
Throws:
XAException

getTimeout

public int getTimeout()

setTimeout

public void setTimeout(int t)
Sets the default transaction timeout and register Current in JNDI.

Specified by:
setTimeout in interface TransactionService
Parameters:
t - new value for time-out

getTotalBegunTransactions

public int getTotalBegunTransactions()
Get begun transactions number.

Returns:
total number of begun transactions

getTotalCommittedTransactions

public int getTotalCommittedTransactions()
Get committed transactions number.

Returns:
total number of committed transactions

getTotalCurrentTransactions

public int getTotalCurrentTransactions()
Get current transactions number.

Returns:
total number of current transactions

getTotalExpiredTransactions

public int getTotalExpiredTransactions()
Get expired transactions number.

Returns:
total number of expired transactions

getTotalRolledbackTransactions

public int getTotalRolledbackTransactions()
Get rolled back transactions number.

Returns:
total number of rolled back transactions

resetAllTxTotalCounters

public void resetAllTxTotalCounters()
Reset all transaction counters.


getAllActiveXids

public Xid[] getAllActiveXids()
Get all currently executing Xids.

Returns:
total number of executing Xids

getAllActiveTx

public String[] getAllActiveTx()
Get all currently executing transactions.

Returns:
total number of executing transaction

getAllRecoveryTx

public String[] getAllRecoveryTx()
Get all transactions that require administrator recovery action.

Returns:
Transactions that require administrator recovery action

getAllXAResource

public String[] getAllXAResource(String xtx)
Get all XAResoures of a transaction that require administrator recovery action.

Returns:
XAResources that require administrator recovery action

commitXAResource

public int commitXAResource(String xatx)
administrator recovery action: Commit.

Returns:
int error, or 0 if OK.

rollbackXAResource

public int rollbackXAResource(String xatx)
administrator recovery action: rollback

Returns:
int error, or 0 if OK.

forgetXAResource

public int forgetXAResource(String xatx)
administrator recovery action: forget

Returns:
int error, or 0 if OK.

attachTransaction

public void attachTransaction(Xid xid,
                              long timeout)
                       throws NotSupportedException,
                              SystemException
Attach the current calling Thread to the given Xid.

Specified by:
attachTransaction in interface TransactionService
Parameters:
xid - Transaction id.
timeout - Transaction timeout.
Throws:
NotSupportedException - if the TM cannot attach the given Xid.
SystemException - if the TM cannot attach the given Xid.

detachTransaction

public void detachTransaction()
Detach the current Thread of the running Transaction.

Specified by:
detachTransaction in interface TransactionService

setJmxService

public void setJmxService(JmxService jmxService)
Parameters:
jmxService - the jmxService to set

setRegistryService

public void setRegistryService(RegistryService registry)
Parameters:
registry - the registry service to set


Copyright © 2010 OW2 Consortium. All Rights Reserved.