geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r232975 - /geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
Date Tue, 16 Aug 2005 10:28:49 GMT
Author: jstrachan
Date: Tue Aug 16 03:28:43 2005
New Revision: 232975

URL: http://svn.apache.org/viewcvs?rev=232975&view=rev
Log:
added a helper method to avoid ClassCastException when using Geronimo TransactionManager with
regular, non-wrapped XAResource instances

Modified:
    geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java

Modified: geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java?rev=232975&r1=232974&r2=232975&view=diff
==============================================================================
--- geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
(original)
+++ geronimo/trunk/modules/transaction/src/java/org/apache/geronimo/transaction/manager/TransactionImpl.java
Tue Aug 16 03:28:43 2005
@@ -631,12 +631,26 @@
         return manager;
     }
 
+    /**
+     * A helper method to convert an {@link XAResource} into a {@link NamedXAResource}
+     * either via casting or wrapping.
+     */
+    protected static NamedXAResource asNamedXAResource(XAResource xaRes) {
+        if (xaRes instanceof NamedXAResource) {
+            return (NamedXAResource) xaRes;
+        }
+        else {
+            String name = xaRes.toString();
+            return new WrapperNamedXAResource(xaRes, name);
+        }
+    }
+
     private static class TransactionBranch implements TransactionBranchInfo {
         private final NamedXAResource committer;
         private final Xid branchId;
 
         public TransactionBranch(XAResource xaRes, Xid branchId) {
-            committer = (NamedXAResource)xaRes;
+            committer = asNamedXAResource(xaRes);
             this.branchId = branchId;
         }
 



Mime
View raw message