org.opensubsystems.core.persist.db.transaction
Class JOTMTransactionFactoryImpl

java.lang.Object
  extended by org.opensubsystems.core.persist.db.DatabaseTransactionFactoryImpl
      extended by org.opensubsystems.core.persist.db.transaction.JOTMTransactionFactoryImpl
All Implemented Interfaces:
DatabaseTransactionFactory, TransactionFactory

public class JOTMTransactionFactoryImpl
extends DatabaseTransactionFactoryImpl

Transaction factory using JOTM transaction manager from Objectweb (http://www.objectweb.org/jotm/index.html)

Version:
$Id: JOTMTransactionFactoryImpl.java,v 1.5 2007/01/07 06:14:21 bastafidli Exp $
Author:
Miro Halas
Code reviewer:
Miro Halas
Code reviewed:
1.3 2006/05/15 05:12:15 bastafidli

Field Summary
protected  boolean m_bStarted
          True if transaction factory is started.
protected  org.objectweb.transaction.jta.TMService m_tmJotm
          Instance of JOTM transaction manager.
 
Fields inherited from class org.opensubsystems.core.persist.db.DatabaseTransactionFactoryImpl
s_bTransactionMonitor, s_iTransactionTimeout, TRANSACTION_MONITOR, TRANSACTION_MONITOR_DEFAULT, TRANSACTION_TIMEOUT, TRANSACTION_TIMEOUT_DEFAULT
 
Constructor Summary
JOTMTransactionFactoryImpl()
          Create new transaction factory.
 
Method Summary
 javax.transaction.TransactionManager getTransactionManager()
          Get transaction manager for this factory.
 javax.transaction.UserTransaction requestTransaction()
          Get transaction object which we can use to begin/commit/rollback transactions.
protected  java.sql.Connection requestTransactionalConnection(boolean bAutoCommit, java.lang.String strDataSourceName, java.lang.String strUser, java.lang.String strPassword, DatabaseConnectionFactoryImpl connectionFactory)
          This method should be exclusively used by DatabaseConnectionFactoryImpl to get a transaction aware version of a connection.
 void reset()
          This method is here mainly for testing and it should reset the transaction manager to initial status to that tests can start from known environment instead of being influenced by other tests.
protected  void returnTransactionalConnection(java.sql.Connection cntDBConnection, DatabaseConnectionFactoryImpl connectionFactory)
          This method should be exclusively used by DatabaseConnectionFactoryImpl to get a transaction aware version of a connection.
protected  void start()
          Start the transaction manager.
 void stop()
          Stop the transaction factory.
 
Methods inherited from class org.opensubsystems.core.persist.db.DatabaseTransactionFactoryImpl
commitTransaction, getInstance, isTransactionInProgress, isTransactionMonitored, rollbackTransaction, setInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_tmJotm

protected org.objectweb.transaction.jta.TMService m_tmJotm
Instance of JOTM transaction manager.


m_bStarted

protected boolean m_bStarted
True if transaction factory is started.

Constructor Detail

JOTMTransactionFactoryImpl

public JOTMTransactionFactoryImpl()
Create new transaction factory.

Method Detail

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Get transaction manager for this factory.

Returns:
TransactionManager

requestTransaction

public javax.transaction.UserTransaction requestTransaction()
                                                     throws OSSException
Get transaction object which we can use to begin/commit/rollback transactions. This operation is valid only if the transaction factory support explicit transaction across multiple connections.

Returns:
UserTransaction - null if explicit transactions are not supported.
Throws:
OSSException - - an error has occured

reset

public void reset()
           throws OSSException
This method is here mainly for testing and it should reset the transaction manager to initial status to that tests can start from known environment instead of being influenced by other tests.

Throws:
OSSException - - an error has occured during reset

stop

public void stop()
          throws OSSException
Stop the transaction factory.

Throws:
OSSException - - problem stoping transaction factory.

start

protected void start()
Start the transaction manager.


requestTransactionalConnection

protected java.sql.Connection requestTransactionalConnection(boolean bAutoCommit,
                                                             java.lang.String strDataSourceName,
                                                             java.lang.String strUser,
                                                             java.lang.String strPassword,
                                                             DatabaseConnectionFactoryImpl connectionFactory)
                                                      throws OSSDatabaseAccessException
This method should be exclusively used by DatabaseConnectionFactoryImpl to get a transaction aware version of a connection. If there one already exists (such as there is one associated with the current pending transaction managed by the database transaction factory) then this method will return that one and there is no need to allocate a new one. If there is not one, then this method will call back the database connection factory which allocated the connection and then create a transaction aware version of it. This method is protected so that only classes in this package can access it.

Overrides:
requestTransactionalConnection in class DatabaseTransactionFactoryImpl
Parameters:
bAutoCommit - - The desired autocommit state of the connection. If this connection is invoked in global (JTA) transaction then the autocommit is false regardless of what value is specified here. Use true here if the client only reads the data and false if the client also modifies the data.
strDataSourceName - - datasource for which the connection was requested, if null then it is requested for default data source
strUser - - user for which the connection was requested, if null then it is requested for default user
strPassword - - password for which the connection was requested, if null then it is requested for default passwoed
connectionFactory - - connection factory which is requesting the connection
Returns:
Connection - transaction aware version of connection
Throws:
OSSDatabaseAccessException - - an error has occured

returnTransactionalConnection

protected void returnTransactionalConnection(java.sql.Connection cntDBConnection,
                                             DatabaseConnectionFactoryImpl connectionFactory)
This method should be exclusively used by DatabaseConnectionFactoryImpl to get a transaction aware version of a connection. If the connection is transaction aware then it will be realy returned if it is not involved in a pending transaction. This method is protected so that only classes from this package can access it.

Overrides:
returnTransactionalConnection in class DatabaseTransactionFactoryImpl
Parameters:
cntDBConnection - - connection to return, can be null
connectionFactory - - connection factory to which the connection should be returned


Copyright © 2003 - 2006 OpenSubsystems s.r.o.