[jboss-cvs] JBossAS SVN: r58986 - trunk/transaction/src/main/org/jboss/tm

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Dec 12 04:41:33 EST 2006


Author: dimitris at jboss.org
Date: 2006-12-12 04:41:30 -0500 (Tue, 12 Dec 2006)
New Revision: 58986

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

Modified: trunk/transaction/src/main/org/jboss/tm/TxUtils.java
===================================================================
--- trunk/transaction/src/main/org/jboss/tm/TxUtils.java	2006-12-12 09:37:06 UTC (rev 58985)
+++ trunk/transaction/src/main/org/jboss/tm/TxUtils.java	2006-12-12 09:41:30 UTC (rev 58986)
@@ -1,24 +1,24 @@
 /*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
 package org.jboss.tm;
 
 import javax.transaction.Status;
@@ -38,7 +38,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
 {
@@ -172,6 +172,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
     * 
@@ -289,7 +334,6 @@
          return "XA_RDONLY";
       case XAException.XA_RETRY:
          return "XA_RETRY";
-
       case XAException.XAER_ASYNC:
          return "XAER_ASYNC";
       case XAException.XAER_DUPID:
@@ -310,5 +354,4 @@
          return "XA_UNKNOWN(" + errorCode + ")";
       }
    }
-
 }




More information about the jboss-cvs-commits mailing list