tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgallim...@apache.org
Subject [2/5] tomee git commit: Don't break the dynamic abstract ejb concept. Remove unnecessary imports
Date Thu, 03 Aug 2017 22:15:28 GMT
Don't break the dynamic abstract ejb concept. Remove unnecessary imports


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

Branch: refs/heads/master
Commit: dec53967a462ad315f0211ba5d7dfa7954d1a5bf
Parents: bd79546
Author: Jonathan Gallimore <jon@jrg.me.uk>
Authored: Thu Jun 29 16:11:52 2017 +0100
Committer: Jonathan Gallimore <jon@jrg.me.uk>
Committed: Wed Aug 2 10:50:58 2017 +0100

----------------------------------------------------------------------
 .../org/apache/openejb/dyni/DynamicSubclass.java    | 16 +++++++++++-----
 .../openejb/resource/AutoConnectionTracker.java     |  4 +---
 2 files changed, 12 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/dec53967/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 123c0ff..44e1256 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
@@ -61,6 +61,10 @@ public class DynamicSubclass implements Opcodes {
     }
 
     public static Class createSubclass(final Class<?> abstractClass, final ClassLoader
cl) {
+        return createSubclass(abstractClass, cl, false);
+    }
+
+    public static Class createSubclass(final Class<?> abstractClass, final ClassLoader
cl, boolean proxyNonAbstractMethods) {
         final String proxyName = getSubclassName(abstractClass);
 
         try {
@@ -80,7 +84,7 @@ public class DynamicSubclass implements Opcodes {
                 // no-op
             }
 
-            return LocalBeanProxyFactory.Unsafe.defineClass(cl, abstractClass, proxyName,
generateBytes(abstractClass));
+            return LocalBeanProxyFactory.Unsafe.defineClass(abstractClass, proxyName, generateBytes(abstractClass));
 
         } catch (final Exception e) {
             throw new InternalError(DynamicSubclass.class.getSimpleName() + ".createSubclass:
" + Debug.printStackTrace(e));
@@ -96,14 +100,16 @@ public class DynamicSubclass implements Opcodes {
                 thisHandler.setAccessible(true);
             }
             thisHandler.set(instance, handler);
-        } catch (final NoSuchFieldException | IllegalAccessException e) {
+        } catch (final NoSuchFieldException e) {
+            throw new IllegalArgumentException(e);
+        } catch (final IllegalAccessException e) {
             throw new IllegalArgumentException(e);
         }
     }
 
-    private static byte[] generateBytes(final Class<?> classToProxy) throws ProxyGenerationException
{
+    private static byte[] generateBytes(final Class<?> classToProxy, final boolean
proxyNonAbstractMethods) throws ProxyGenerationException {
 
-        final Map<String, MethodVisitor> visitors = new HashMap<>();
+        final Map<String, MethodVisitor> visitors = new HashMap<String, MethodVisitor>();
 
         final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
 
@@ -134,7 +140,7 @@ public class DynamicSubclass implements Opcodes {
         for (final Map.Entry<String, List<Method>> entry : methodMap.entrySet())
{
 
             for (final Method method : entry.getValue()) {
-                if (Modifier.isPublic(method.getModifiers())) {
+                if (Modifier.isAbstract(method.getModifiers()) || (proxyNonAbstractMethods
&& 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/dec53967/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 7ec8ecb..125e37a 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
@@ -23,8 +23,6 @@ import org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor;
 import org.apache.geronimo.connector.outbound.ManagedConnectionInfo;
 import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
 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;
@@ -157,7 +155,7 @@ public class AutoConnectionTracker implements ConnectionTracker {
             synchronized (this) {
                 found = proxies.get(aClass);
                 if (found == null) {
-                    proxies.put(aClass, DynamicSubclass.createSubclass(aClass, loader));
+                    proxies.put(aClass, DynamicSubclass.createSubclass(aClass, loader, true));
                     found = proxies.get(aClass);
                 }
             }


Mime
View raw message