Author: jgallimore
Date: Thu Jun 30 21:42:27 2011
New Revision: 1141732
URL: http://svn.apache.org/viewvc?rev=1141732&view=rev
Log:
OPENEJB-1618 don't cache anything that implements IntraVmProxy, make
no-interface proxies implement IntraVmProxy as well
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=1141732&r1=1141731&r2=1141732&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
Thu Jun 30 21:42:27 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)) {
+ 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=1141732&r1=1141731&r2=1141732&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
Thu Jun 30 21:42:27 2011
@@ -27,6 +27,7 @@ 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;
@@ -89,7 +90,7 @@ public class LocalBeanProxyGeneratorImpl
String proxyClassName = proxyName.replaceAll("\\.", "/");
// push class signature
- cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, proxyClassName, null,
clsToOverride, null);
+ cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, proxyClassName, null,
clsToOverride, new String[] { getAsmTypeAsString(IntraVmProxy.class, true) });
cw.visitSource(clsToOverride + ".java", null);
// push InvocationHandler fields
@@ -124,7 +125,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, IntraVmProxy.class });
for (Map.Entry<String, List<Method>> entry :
methodMap.entrySet()) {
for (Method method : entry.getValue()) {
@@ -152,34 +153,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;
}
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=1141732&r1=1141731&r2=1141732&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
Thu Jun 30 21:42:27 2011
@@ -18,6 +18,8 @@
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;
@@ -226,6 +228,13 @@ 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);