org.lateralnz.simpletrans
Class SimpleTransactionManager

java.lang.Object
  extended by org.lateralnz.simpletrans.SimpleTransactionManager
All Implemented Interfaces:
java.io.Serializable, javax.naming.Referenceable, javax.transaction.TransactionManager, javax.transaction.UserTransaction

public class SimpleTransactionManager
extends java.lang.Object
implements javax.transaction.TransactionManager, javax.transaction.UserTransaction, java.io.Serializable, javax.naming.Referenceable

a singleton implementation of a transaction manager, using thread-local variables to store the current transaction.

See Also:
Serialized Form

Constructor Summary
SimpleTransactionManager()
           
 
Method Summary
 void begin()
          begin a transaction.
 void commit()
          commit the current transaction (note: this doesn't throw an error if the current thread is not in a transaction)
 javax.naming.Reference getReference()
           
 int getStatus()
          get the status of the current transaction
 javax.transaction.Transaction getTransaction()
          get the transaction for the current (calling) thread
static SimpleTransactionManager getTransactionManager()
           
protected  boolean isInTransaction()
          a helper function to indicate if the calling thread is in a transaction
 void resume(javax.transaction.Transaction transaction)
          not supported
 void rollback()
          rollback the current transaction (note: this doesn't throw an error if the current thread is not in a transaction)
 void setRollbackOnly()
          flag the current transaction for rollback (note: this doesn't throw an error if the current thread is not in a transaction)
 void setTransactionTimeout(int param)
          not supported
 javax.transaction.Transaction suspend()
          not supported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleTransactionManager

public SimpleTransactionManager()
Method Detail

getTransactionManager

public static final SimpleTransactionManager getTransactionManager()

getReference

public javax.naming.Reference getReference()
Specified by:
getReference in interface javax.naming.Referenceable

begin

public void begin()
begin a transaction. This method differs from that specified by the TransactionManager interface, in that it doesn't throw an exception if the current thread is already in a transaction -- and it doesn't create a nested transaction. This basically assumes that everything will run in the current transaction.

Specified by:
begin in interface javax.transaction.TransactionManager
Specified by:
begin in interface javax.transaction.UserTransaction

commit

public void commit()
            throws javax.transaction.RollbackException,
                   javax.transaction.HeuristicMixedException,
                   javax.transaction.HeuristicRollbackException,
                   javax.transaction.SystemException
commit the current transaction (note: this doesn't throw an error if the current thread is not in a transaction)

Specified by:
commit in interface javax.transaction.TransactionManager
Specified by:
commit in interface javax.transaction.UserTransaction
Throws:
javax.transaction.RollbackException
javax.transaction.HeuristicMixedException
javax.transaction.HeuristicRollbackException
javax.transaction.SystemException

getStatus

public int getStatus()
              throws javax.transaction.SystemException
get the status of the current transaction

Specified by:
getStatus in interface javax.transaction.TransactionManager
Specified by:
getStatus in interface javax.transaction.UserTransaction
Throws:
javax.transaction.SystemException

getTransaction

public javax.transaction.Transaction getTransaction()
get the transaction for the current (calling) thread

Specified by:
getTransaction in interface javax.transaction.TransactionManager

resume

public void resume(javax.transaction.Transaction transaction)
not supported

Specified by:
resume in interface javax.transaction.TransactionManager

rollback

public void rollback()
              throws javax.transaction.SystemException
rollback the current transaction (note: this doesn't throw an error if the current thread is not in a transaction)

Specified by:
rollback in interface javax.transaction.TransactionManager
Specified by:
rollback in interface javax.transaction.UserTransaction
Throws:
javax.transaction.SystemException

setRollbackOnly

public void setRollbackOnly()
                     throws javax.transaction.SystemException
flag the current transaction for rollback (note: this doesn't throw an error if the current thread is not in a transaction)

Specified by:
setRollbackOnly in interface javax.transaction.TransactionManager
Specified by:
setRollbackOnly in interface javax.transaction.UserTransaction
Throws:
javax.transaction.SystemException

setTransactionTimeout

public void setTransactionTimeout(int param)
not supported

Specified by:
setTransactionTimeout in interface javax.transaction.TransactionManager
Specified by:
setTransactionTimeout in interface javax.transaction.UserTransaction

suspend

public javax.transaction.Transaction suspend()
not supported

Specified by:
suspend in interface javax.transaction.TransactionManager

isInTransaction

protected boolean isInTransaction()
a helper function to indicate if the calling thread is in a transaction