tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgallim...@apache.org
Subject [1/5] tomee git commit: Forward porting 4e69b3fe8d640445cf90a9a94d8c132e52535939 TOMEE-2082 attempting to allow classes without no-arg constructors to be sub-classes
Date Thu, 03 Aug 2017 22:15:27 GMT
Repository: tomee
Updated Branches:
  refs/heads/master 6f9b67b39 -> 9cd843883


Forward porting 4e69b3fe8d640445cf90a9a94d8c132e52535939 TOMEE-2082 attempting to allow classes
without no-arg constructors to be sub-classes


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

Branch: refs/heads/master
Commit: bd79546df6372f308a553eb0006ec7e1e854fe71
Parents: b2973d7
Author: Jonathan Gallimore <jon@jrg.me.uk>
Authored: Tue Aug 1 23:47:58 2017 +0100
Committer: Jonathan Gallimore <jon@jrg.me.uk>
Committed: Tue Aug 1 23:47:58 2017 +0100

----------------------------------------------------------------------
 .../org/apache/openejb/dyni/DynamicSubclass.java    |  2 +-
 .../openejb/resource/AutoConnectionTracker.java     | 16 ++++------------
 .../openejb/util/proxy/LocalBeanProxyFactory.java   |  2 +-
 .../apache/openejb/config/ConnectorProxyTest.java   | 10 ++++++++--
 4 files changed, 14 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/bd79546d/container/openejb-core/src/main/java/org/apache/openejb/dyni/DynamicSubclass.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/dyni/DynamicSubclass.java
b/container/openejb-core/src/main/java/org/apache/openejb/dyni/DynamicSubclass.java
index 5c27658..123c0ff 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/dyni/DynamicSubclass.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/dyni/DynamicSubclass.java
@@ -134,7 +134,7 @@ public class DynamicSubclass implements Opcodes {
         for (final Map.Entry<String, List<Method>> entry : methodMap.entrySet())
{
 
             for (final Method method : entry.getValue()) {
-                if (Modifier.isAbstract(method.getModifiers())) {
+                if (Modifier.isPublic(method.getModifiers())) {
                     final MethodVisitor visitor = LocalBeanProxyFactory.visit(cw, method,
proxyClassFileName, "this$handler");
                     visitors.put(method.getName() + Type.getMethodDescriptor(method), visitor);
                 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/bd79546d/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java
b/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java
index 0a26bad..7ec8ecb 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/resource/AutoConnectionTracker.java
@@ -25,6 +25,7 @@ import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrack
 import org.apache.openejb.dyni.DynamicSubclass;
 import org.apache.openejb.util.LogCategory;
 import org.apache.openejb.util.Logger;
+import org.apache.openejb.util.proxy.LocalBeanProxyFactory;
 
 import javax.resource.ResourceException;
 import javax.resource.spi.DissociatableManagedConnection;
@@ -126,18 +127,9 @@ public class AutoConnectionTracker implements ConnectionTracker {
             loader = ClassLoader.getSystemClassLoader();
         }
         if (!Proxy.isProxyClass(handle.getClass())) {
-            try {
-                handle.getClass().getConstructor(); // if not let's the user reuse the impl-ed
interfaces
-                try {
-                    final Object proxy = getProxy(handle.getClass(), loader).newInstance();
-                    DynamicSubclass.setHandler(proxy, invocationHandler);
-                    return proxy;
-                } catch (final InstantiationException | IllegalAccessException e) {
-                    throw new IllegalStateException(e);
-                }
-            } catch (final NoSuchMethodException e1) {
-                // no-op
-            }
+            final Object proxy = LocalBeanProxyFactory.Unsafe.allocateInstance(getProxy(handle.getClass(),
loader));
+            DynamicSubclass.setHandler(proxy, invocationHandler);
+            return proxy;
         }
 
         return Proxy.newProxyInstance(loader, getAPi(handle.getClass()), invocationHandler);

http://git-wip-us.apache.org/repos/asf/tomee/blob/bd79546d/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java
b/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java
index cd9cb7e..9a56db7 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyFactory.java
@@ -788,7 +788,7 @@ public class LocalBeanProxyFactory implements Opcodes {
             });
         }
 
-        private static Object allocateInstance(final Class clazz) {
+        public static Object allocateInstance(final Class clazz) {
             try {
                 return allocateInstance.invoke(unsafe, clazz);
             } catch (final IllegalAccessException e) {

http://git-wip-us.apache.org/repos/asf/tomee/blob/bd79546d/container/openejb-core/src/test/java/org/apache/openejb/config/ConnectorProxyTest.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/config/ConnectorProxyTest.java
b/container/openejb-core/src/test/java/org/apache/openejb/config/ConnectorProxyTest.java
index 5db51c6..9092507 100644
--- a/container/openejb-core/src/test/java/org/apache/openejb/config/ConnectorProxyTest.java
+++ b/container/openejb-core/src/test/java/org/apache/openejb/config/ConnectorProxyTest.java
@@ -203,8 +203,14 @@ public class ConnectorProxyTest {
     }
 
     public static class MyCon implements MyConAPI {
+        private final String arg;
+
+        public MyCon(String arg) {
+            this.arg = arg;
+        }
+
         public String specific() {
-            return "yes";
+            return arg;
         }
 
         @Override
@@ -236,7 +242,7 @@ public class ConnectorProxyTest {
     public static class MyMC implements ManagedConnection {
         @Override
         public Object getConnection(final Subject subject, final ConnectionRequestInfo cxRequestInfo)
throws ResourceException {
-            return new MyCon();
+            return new MyCon("yes");
         }
 
         @Override


Mime
View raw message