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 2011/07/02 18:15:17 UTC

svn commit: r1142239 - in /openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb: core/ivm/naming/IvmContext.java util/proxy/LocalBeanProxyGeneratorImpl.java

Author: jgallimore
Date: Sat Jul  2 16:15:15 2011
New Revision: 1142239

URL: http://svn.apache.org/viewvc?rev=1142239&view=rev
Log:
OPENEJB-1618 more Geronimo friendly change to stop proxies being cached

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

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=1142239&r1=1142238&r2=1142239&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 16:15:15 2011
@@ -50,9 +50,13 @@ 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;
 
 /*
@@ -65,7 +69,6 @@ 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;
@@ -143,14 +146,16 @@ 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);
             }
 
-            fastCache.put(compoundName, obj);
+            // don't cache proxies
+            if (!(obj instanceof IntraVmProxy || obj.getClass().getName().endsWith("$LocalBeanProxy"))) {
+            	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=1142239&r1=1142238&r2=1142239&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 16:15:15 2011
@@ -124,7 +124,7 @@ public class LocalBeanProxyGeneratorImpl
 		mv.visitMaxs(0, 0);
 		mv.visitEnd();
 
-		Map<String, List<Method>> methodMap = getNonPrivateMethods(clsToProxy);
+		Map<String, List<Method>> methodMap = getNonPrivateMethods(new Class[] { clsToProxy });
 
 		for (Map.Entry<String, List<Method>> entry : methodMap.entrySet()) {
 		    for (Method method : entry.getValue()) {	
@@ -152,34 +152,39 @@ 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<?> 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();
-        }
+	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();
+	        }
+		}
         return methodMap;
 	}