[seam-commits] Seam SVN: r8153 - trunk/src/main/org/jboss/seam/util and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sun May 11 09:51:36 EDT 2008


Author: pete.muir at jboss.org
Date: 2008-05-11 09:51:35 -0400 (Sun, 11 May 2008)
New Revision: 8153

Modified:
   branches/Seam_2_0/src/main/org/jboss/seam/util/Work.java
   trunk/src/main/org/jboss/seam/util/Work.java
Log:
JBSEAM-2970

Modified: branches/Seam_2_0/src/main/org/jboss/seam/util/Work.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/util/Work.java	2008-05-10 13:48:52 UTC (rev 8152)
+++ branches/Seam_2_0/src/main/org/jboss/seam/util/Work.java	2008-05-11 13:51:35 UTC (rev 8153)
@@ -27,10 +27,10 @@
    {
       boolean transactionActive = Transaction.instance().isActiveOrMarkedRollback()
               || Transaction.instance().isRolledBack(); //TODO: temp workaround, what should we really do in this case??
-      boolean begin = isNewTransactionRequired(transactionActive);
-      UserTransaction userTransaction = begin ? Transaction.instance() : null;
+      boolean newTransactionRequired = isNewTransactionRequired(transactionActive);
+      UserTransaction userTransaction = newTransactionRequired ? Transaction.instance() : null;
       
-      if (begin) 
+      if (newTransactionRequired) 
       {
          log.debug("beginning transaction");
          userTransaction.begin();
@@ -39,16 +39,24 @@
       try
       {
          T result = work();
-         if (begin) 
+         if (newTransactionRequired) 
          {
-            log.debug("committing transaction");
-            userTransaction.commit();
+            if (Transaction.instance().isMarkedRollback())
+            {
+               log.debug("rolling back transaction");
+               userTransaction.rollback(); 
+            }
+            else
+            {
+               log.debug("committing transaction");
+               userTransaction.commit();
+            }
          }
          return result;
       }
       catch (Exception e)
       {
-         if (begin && userTransaction.getStatus() != Status.STATUS_NO_TRANSACTION) 
+         if (newTransactionRequired && userTransaction.getStatus() != Status.STATUS_NO_TRANSACTION) 
          {
             log.debug("rolling back transaction");
             userTransaction.rollback();

Modified: trunk/src/main/org/jboss/seam/util/Work.java
===================================================================
--- trunk/src/main/org/jboss/seam/util/Work.java	2008-05-10 13:48:52 UTC (rev 8152)
+++ trunk/src/main/org/jboss/seam/util/Work.java	2008-05-11 13:51:35 UTC (rev 8153)
@@ -27,10 +27,10 @@
    {
       boolean transactionActive = Transaction.instance().isActiveOrMarkedRollback()
               || Transaction.instance().isRolledBack(); //TODO: temp workaround, what should we really do in this case??
-      boolean begin = isNewTransactionRequired(transactionActive);
-      UserTransaction userTransaction = begin ? Transaction.instance() : null;
+      boolean newTransactionRequired = isNewTransactionRequired(transactionActive);
+      UserTransaction userTransaction = newTransactionRequired ? Transaction.instance() : null;
       
-      if (begin) 
+      if (newTransactionRequired) 
       {
          log.debug("beginning transaction");
          userTransaction.begin();
@@ -39,16 +39,24 @@
       try
       {
          T result = work();
-         if (begin) 
+         if (newTransactionRequired) 
          {
-            log.debug("committing transaction");
-            userTransaction.commit();
+            if (Transaction.instance().isMarkedRollback())
+            {
+               log.debug("rolling back transaction");
+               userTransaction.rollback(); 
+            }
+            else
+            {
+               log.debug("committing transaction");
+               userTransaction.commit();
+            }
          }
          return result;
       }
       catch (Exception e)
       {
-         if (begin && userTransaction.getStatus() != Status.STATUS_NO_TRANSACTION) 
+         if (newTransactionRequired && userTransaction.getStatus() != Status.STATUS_NO_TRANSACTION) 
          {
             log.debug("rolling back transaction");
             userTransaction.rollback();




More information about the seam-commits mailing list