[jboss-cvs] JBossAS SVN: r58985 - branches/Branch_4_0/transaction/src/main/org/jboss/tm

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Dec 12 04:37:07 EST 2006


Author: dimitris at jboss.org
Date: 2006-12-12 04:37:06 -0500 (Tue, 12 Dec 2006)
New Revision: 58985

Modified:
   branches/Branch_4_0/transaction/src/main/org/jboss/tm/TxUtils.java
Log:
JBAS-3847, add simple utility methods to check for rollback status

Modified: branches/Branch_4_0/transaction/src/main/org/jboss/tm/TxUtils.java
===================================================================
--- branches/Branch_4_0/transaction/src/main/org/jboss/tm/TxUtils.java	2006-12-12 09:36:04 UTC (rev 58984)
+++ branches/Branch_4_0/transaction/src/main/org/jboss/tm/TxUtils.java	2006-12-12 09:37:06 UTC (rev 58985)
@@ -37,7 +37,7 @@
  * @author <a href="mailto:d_jencks at users.sourceforge.net">David Jencks</a>
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
- * @version $1.0$
+ * @version $Revision$
  */
 public class TxUtils
 {
@@ -184,6 +184,51 @@
       }
    }
    
+   public static boolean isRollback(Transaction tx)
+   {
+      try
+      {
+         if (tx == null)
+            return false;
+         
+         int status = tx.getStatus();
+         return status == Status.STATUS_MARKED_ROLLBACK
+             || status == Status.STATUS_ROLLING_BACK
+             || status == Status.STATUS_ROLLEDBACK;
+      }
+      catch (SystemException error)
+      {
+         throw new NestedRuntimeException(error);
+      }
+   }
+
+   public static boolean isRollback(TransactionManager tm)
+   {
+      try
+      {
+         return isRollback(tm.getTransaction());
+      }
+      catch (SystemException error)
+      {
+         throw new NestedRuntimeException(error);
+      }
+   }
+
+   public static boolean isRollback(UserTransaction ut)
+   {
+      try
+      {
+         int status = ut.getStatus();
+         return status == Status.STATUS_MARKED_ROLLBACK
+         	|| status == Status.STATUS_ROLLING_BACK
+         	|| status == Status.STATUS_ROLLEDBACK;
+      }
+      catch (SystemException error)
+      {
+         throw new NestedRuntimeException(error);
+      }
+   }
+   
    /**
     * Converts a tx Status index to a String
     * 




More information about the jboss-cvs-commits mailing list