You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by ge...@apache.org on 2011/07/02 10:17:00 UTC

svn commit: r1142169 - in /openejb/trunk/openejb3/container/openejb-core/src: main/java/org/apache/openejb/core/ivm/naming/ main/java/org/apache/openejb/util/proxy/ test/java/org/apache/openejb/util/proxy/

Author: genspring
Date: Sat Jul  2 08:17:00 2011
New Revision: 1142169

URL: http://svn.apache.org/viewvc?rev=1142169&view=rev
Log:
Revert "OPENEJB-1618 don't cache anything that implements IntraVmProxy, make no-interface proxies implement IntraVmProxy as well"

This reverts commit 6dbfda8c1ef5c89322926bc821b82054ed34861b.  Thanks Jonathan for the quick response.

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImpl.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImplTest.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java?rev=1142169&r1=1142168&r2=1142169&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/ivm/naming/IvmContext.java Sat Jul  2 08:17:00 2011
@@ -50,13 +50,9 @@ import javax.naming.InitialContext;
 import javax.naming.spi.ObjectFactory;
 
 import org.apache.openejb.ClassLoaderUtil;
-import org.apache.openejb.assembler.classic.JndiBuilder;
 import org.apache.openejb.core.ivm.IntraVmCopyMonitor;
-import org.apache.openejb.core.ivm.IntraVmProxy;
 import org.apache.openejb.core.ivm.naming.openejb.openejbURLContextFactory;
 import org.apache.openejb.core.ivm.naming.java.javaURLContextFactory;
-import org.apache.openejb.util.LogCategory;
-import org.apache.openejb.util.Logger;
 import org.apache.xbean.naming.context.ContextUtil;
 
 /*
@@ -69,6 +65,7 @@ import org.apache.xbean.naming.context.C
  * @org.apache.xbean.XBean element="ivmContext"
  */
 public class IvmContext implements Context, Serializable {
+
     private static final long serialVersionUID = -626353930051783641L;
     Hashtable<String, Object> myEnv;
     boolean readOnly = false;
@@ -146,16 +143,14 @@ public class IvmContext implements Conte
         */
         Object obj = fastCache.get(compoundName);
         if (obj == null) {
+
             try {
                 obj = mynode.resolve(new ParsedName(compoundName));
             } catch (NameNotFoundException nnfe) {
                 obj = federate(compositName);
             }
 
-            // don't cache proxies
-            if (!(obj instanceof IntraVmProxy)) {
-            	fastCache.put(compoundName, obj);
-            }
+            fastCache.put(compoundName, obj);
         }
 
         if (obj == null){

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImpl.java?rev=1142169&r1=1142168&r2=1142169&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImpl.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImpl.java Sat Jul  2 08:17:00 2011
@@ -27,7 +27,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.openejb.core.ivm.IntraVmProxy;
 import org.apache.xbean.asm.ClassWriter;
 import org.apache.xbean.asm.FieldVisitor;
 import org.apache.xbean.asm.Label;
@@ -90,7 +89,7 @@ public class LocalBeanProxyGeneratorImpl
         String proxyClassName = proxyName.replaceAll("\\.", "/");
 
         // push class signature
-        cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, proxyClassName, null, clsToOverride, new String[] { getAsmTypeAsString(IntraVmProxy.class, true) });
+        cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, proxyClassName, null, clsToOverride, null);
 		cw.visitSource(clsToOverride + ".java", null);
 
 		// push InvocationHandler fields
@@ -125,7 +124,7 @@ public class LocalBeanProxyGeneratorImpl
 		mv.visitMaxs(0, 0);
 		mv.visitEnd();
 
-		Map<String, List<Method>> methodMap = getNonPrivateMethods(new Class[] { clsToProxy, IntraVmProxy.class });
+		Map<String, List<Method>> methodMap = getNonPrivateMethods(clsToProxy);
 
 		for (Map.Entry<String, List<Method>> entry : methodMap.entrySet()) {
 		    for (Method method : entry.getValue()) {	
@@ -153,39 +152,34 @@ public class LocalBeanProxyGeneratorImpl
 	 * that are not final or static. The returned map includes the inherited methods
 	 * and ensures that overridden methods are included once.
 	 */
-	private Map<String, List<Method>> getNonPrivateMethods(Class<?>[] classes) {
-		Map<String, List<Method>> methodMap = new HashMap<String, List<Method>>();
-		
-		for (int i = 0; i < classes.length; i++) {
-			Class<?> clazz = classes[i];
-		    
-	        while (clazz != null) {
-	            for (Method method : clazz.getDeclaredMethods()) {
-	                int modifiers = method.getModifiers();
-	                if (Modifier.isFinal(modifiers) || 
-	                    Modifier.isPrivate(modifiers) || 
-	                    Modifier.isStatic(modifiers)) {
-	                    continue;
-	                }
-	                
-	                List<Method> methods = methodMap.get(method.getName());
-	                if (methods == null) {
-	                    methods = new ArrayList<Method>();
-	                    methods.add(method);
-	                    methodMap.put(method.getName(), methods);
-	                } else {
-	                    if (isOverridden(methods, method)) {
-	                        // method is overridden in superclass, so do nothing
-	                    } else {
-	                        // method is not overridden, so add it
-	                        methods.add(method);
-	                    }
-	                }
-	            }
-	            
-	            clazz = clazz.getSuperclass();
-	        }
-		}
+	private Map<String, List<Method>> getNonPrivateMethods(Class<?> clazz) {
+	    Map<String, List<Method>> methodMap = new HashMap<String, List<Method>>();
+        while (clazz != null) {
+            for (Method method : clazz.getDeclaredMethods()) {
+                int modifiers = method.getModifiers();
+                if (Modifier.isFinal(modifiers) || 
+                    Modifier.isPrivate(modifiers) || 
+                    Modifier.isStatic(modifiers)) {
+                    continue;
+                }
+                
+                List<Method> methods = methodMap.get(method.getName());
+                if (methods == null) {
+                    methods = new ArrayList<Method>();
+                    methods.add(method);
+                    methodMap.put(method.getName(), methods);
+                } else {
+                    if (isOverridden(methods, method)) {
+                        // method is overridden in superclass, so do nothing
+                    } else {
+                        // method is not overridden, so add it
+                        methods.add(method);
+                    }
+                }
+            }
+            
+            clazz = clazz.getSuperclass();
+        }
         return methodMap;
 	}
 	

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImplTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImplTest.java?rev=1142169&r1=1142168&r2=1142169&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImplTest.java (original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImplTest.java Sat Jul  2 08:17:00 2011
@@ -18,8 +18,6 @@
 package org.apache.openejb.util.proxy;
 
 import junit.framework.TestCase;
-
-import org.apache.openejb.core.ivm.IntraVmProxy;
 import org.junit.Test;
 
 import java.io.IOException;
@@ -228,13 +226,6 @@ public class LocalBeanProxyGeneratorImpl
 	}
 	
 	@Test
-	public void testProxyShouldBeInstanceOfIntraVmProxy() throws Exception {
-		TestInvocationHandler invocationHandler = new TestInvocationHandler(new SampleLocalBean());
-		SampleLocalBean proxy = loadProxy(invocationHandler);
-		assertTrue(proxy instanceof IntraVmProxy);
-	}
-	
-	@Test
 	public void testDoWork() throws Exception {
 		TestInvocationHandler invocationHandler = new TestInvocationHandler(new SampleLocalBean());
 		SampleLocalBean proxy = loadProxy(invocationHandler);