svn merge -r 1097554:1097555 https://svn.apache.org/repos/asf/geronimo/components/txmanager/branches/geronimo-txmanager-parent-2.2

http://svn.apache.org/viewvc?view=revision&revision=1097555
------------------------------------------------------------------------
r1097555 | dblevins | 2011-04-28 10:22:05 -0700 (Thu, 28 Apr 2011) | 3 lines

GERONIMO-4576 and OPENEJB-782
Record the orgigin of setRollbackOnly calls

------------------------------------------------------------------------


git-svn-id: https://svn.apache.org/repos/asf/geronimo/components/txmanager/trunk@1097971 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/SetRollbackOnlyException.java b/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/SetRollbackOnlyException.java
new file mode 100644
index 0000000..468099f
--- /dev/null
+++ b/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/SetRollbackOnlyException.java
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.transaction.manager;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SetRollbackOnlyException extends Exception {
+
+    public SetRollbackOnlyException() {
+        super("setRollbackOnly() called.  See stacktrace for origin");
+    }
+}
diff --git a/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java b/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
index 0058007..0d8ef48 100644
--- a/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
+++ b/geronimo-transaction/src/main/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
@@ -123,10 +123,15 @@
     }
 
     public synchronized void setRollbackOnly() throws IllegalStateException {
+        setRollbackOnly(new SetRollbackOnlyException());
+    }
+
+    public synchronized void setRollbackOnly(Exception reason) {
         switch (status) {
             case Status.STATUS_ACTIVE:
             case Status.STATUS_PREPARING:
                 status = Status.STATUS_MARKED_ROLLBACK;
+                markRollbackCause(reason);
                 break;
             case Status.STATUS_MARKED_ROLLBACK:
             case Status.STATUS_ROLLING_BACK:
@@ -209,7 +214,7 @@
         } catch (XAException e) {
             log.warn("Unable to enlist XAResource " + xaRes + ", errorCode: " + e.errorCode, e);
             // mark status as rollback only because enlist resource failed
-            setRollbackOnly();
+            setRollbackOnly(e);
             return false;
         }
     }