You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by jg...@apache.org on 2015/07/22 14:56:31 UTC

[1/2] tomee git commit: Use connection key + transaction to store connection in registry

Repository: tomee
Updated Branches:
  refs/heads/tomee-1.7.x 664a4d73b -> 8c427379f


Use connection key + transaction to store connection in registry


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/efff429a
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/efff429a
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/efff429a

Branch: refs/heads/tomee-1.7.x
Commit: efff429ace2bc59a7586e604bd123f2f217627c5
Parents: cbd55c3
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Jul 22 10:28:39 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Jul 22 10:28:39 2015 +0100

----------------------------------------------------------------------
 .../jdbc/managed/local/ManagedConnection.java   | 49 +++++++++++++++++++-
 1 file changed, 47 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/efff429a/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java b/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
index 3fc6d78..3e2595d 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
@@ -26,6 +26,7 @@ import java.lang.reflect.Method;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Wrapper;
+
 import javax.sql.CommonDataSource;
 import javax.sql.DataSource;
 import javax.sql.XAConnection;
@@ -112,12 +113,14 @@ public class ManagedConnection implements InvocationHandler {
 
             // get the already bound connection to the current transaction or enlist this one in the tx
             if (isUnderTransaction(transaction.getStatus())) {
-                Connection connection = Connection.class.cast(registry.getResource(transaction));
+                final TxRegistryKey txRegistryKey = new TxRegistryKey(key, transaction);
+                
+                Connection connection = Connection.class.cast(registry.getResource(txRegistryKey));
                 if (connection == null && delegate == null) {
                     newConnection();
                     connection = delegate;
 
-                    registry.putResource(transaction, delegate);
+                    registry.putResource(txRegistryKey, delegate);
                     currentTransaction = transaction;
                     try {
                         transaction.enlistResource(getXAResource());
@@ -284,4 +287,46 @@ public class ManagedConnection implements InvocationHandler {
             return hash;
         }
     }
+    
+    private static final class TxRegistryKey {
+        private final Key key;
+        private final Transaction tx;
+        
+        private TxRegistryKey(Key key, Transaction tx) {
+            super();
+            this.key = key;
+            this.tx = tx;
+        }
+
+        public Key getKey() {
+            return key;
+        }
+
+        public Transaction getTx() {
+            return tx;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((key == null) ? 0 : key.hashCode());
+            result = prime * result + ((tx == null) ? 0 : tx.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(final Object o) {
+            if (this == o) {
+                return true;
+            }
+            if (o == null || getClass() != o.getClass()) {
+                return false;
+            }
+
+            final TxRegistryKey txRegKey = TxRegistryKey.class.cast(o);
+            return (this.key == txRegKey.key || this.key.equals(txRegKey.key)) &&
+                    !(this.tx != null ? !this.tx.equals(txRegKey.tx) : txRegKey.tx != null);
+        }
+    }
 }


[2/2] tomee git commit: Merge branch 'patch' into tomee-1.7.x

Posted by jg...@apache.org.
Merge branch 'patch' into tomee-1.7.x


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/8c427379
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/8c427379
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/8c427379

Branch: refs/heads/tomee-1.7.x
Commit: 8c427379f9a20d4f07797b3b02764123139487b1
Parents: 664a4d7 efff429
Author: Jonathan Gallimore <jo...@jrg.me.uk>
Authored: Wed Jul 22 13:56:08 2015 +0100
Committer: Jonathan Gallimore <jo...@jrg.me.uk>
Committed: Wed Jul 22 13:56:08 2015 +0100

----------------------------------------------------------------------
 .../jdbc/managed/local/ManagedConnection.java   | 49 +++++++++++++++++++-
 1 file changed, 47 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/8c427379/container/openejb-core/src/main/java/org/apache/openejb/resource/jdbc/managed/local/ManagedConnection.java
----------------------------------------------------------------------