jodd.jtx.worker
Class LeanTransactionWorker

java.lang.Object
  extended by jodd.jtx.worker.LeanTransactionWorker

public class LeanTransactionWorker
extends java.lang.Object

Lean transaction worker helps dealing transactions when they were requested in several places, usually in separated methods. This worker knows when requested transaction is the same as current one, or completely new. It might be useful for aspects.


Field Summary
protected  JtxTransactionManager txManager
           
 
Constructor Summary
LeanTransactionWorker(JtxTransactionManager txManager)
           
 
Method Summary
 JtxTransaction getCurrentTransaction()
          Returns current transaction or null if there is no transaction at the moment.
 JtxTransactionManager getTransactionManager()
          Returns transaction manager.
 boolean markOrRollbackTransaction(JtxTransaction tx, java.lang.Throwable cause)
          Rollbacks transaction if created in the same scope where this method is invoked.
 boolean maybeCommitTransaction(JtxTransaction tx)
          Commits transaction if created in the same level where this method is invoked.
 JtxTransaction maybeRequestTransaction(JtxTransactionMode txMode)
          Requests for transaction and returns non-null value only when new transaction is created!
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

txManager

protected final JtxTransactionManager txManager
Constructor Detail

LeanTransactionWorker

public LeanTransactionWorker(JtxTransactionManager txManager)
Method Detail

getTransactionManager

public JtxTransactionManager getTransactionManager()
Returns transaction manager.


getCurrentTransaction

public JtxTransaction getCurrentTransaction()
Returns current transaction or null if there is no transaction at the moment.


maybeRequestTransaction

public JtxTransaction maybeRequestTransaction(JtxTransactionMode txMode)
Requests for transaction and returns non-null value only when new transaction is created! When null is returned, transaction may be get by getCurrentTransaction().

See Also:
JtxTransactionManager.requestTransaction(jodd.jtx.JtxTransactionMode)

maybeCommitTransaction

public boolean maybeCommitTransaction(JtxTransaction tx)
Commits transaction if created in the same level where this method is invoked. Returns true if transaction was actually committed or false if transaction was not created on this level.


markOrRollbackTransaction

public boolean markOrRollbackTransaction(JtxTransaction tx,
                                         java.lang.Throwable cause)
Rollbacks transaction if created in the same scope where this method is invoked. If not, current transaction is marked for rollback. Returns true if transaction was actually roll backed.



Copyright ©2008 Jodd Team