|
Brantley and all -- Do you think the following approach will work for you? The idea is to have the application register locallyResolved classes and avoid introducing dependency into the package? See the enclosed patch. Thanks, -- Sasha Brantley Hobbs wrote: Here's a patch to fix issue #48. Only one file is patched (o.j.cl.Client.java). |
Index: test/src/org/jabsorb/test/JabsorbTestServer.java
===================================================================
--- test/src/org/jabsorb/test/JabsorbTestServer.java (revision 309)
+++ test/src/org/jabsorb/test/JabsorbTestServer.java (working copy)
@@ -26,6 +26,7 @@
package org.jabsorb.test;
+//import org.apache.jasper.servlet.JspServlet;
import org.apache.jasper.servlet.JspServlet;
import org.jabsorb.JSONRPCServlet;
import org.jabsorb.ext.InitializationServlet;
Index: src/org/jabsorb/client/Client.java
===================================================================
--- src/org/jabsorb/client/Client.java (revision 309)
+++ src/org/jabsorb/client/Client.java (working copy)
@@ -25,7 +25,10 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import org.jabsorb.JSONRPCResult;
@@ -47,7 +50,7 @@
Session session;
JSONSerializer serializer;
-
+
/**
* Create a client given a session
*
@@ -111,7 +114,20 @@
proxyMap.remove(proxy);
}
+ static HashSet locallyResolved= new HashSet();
+
/**
+ * Register class as locally resolved
+ */
+ public static void registerLocallyResolved(Class klass) {
+ locallyResolved.add(klass);
+ }
+
+ public static void unregisterLocallyResolved(Class klass) {
+ locallyResolved.remove(klass);
+ }
+
+ /**
* This method is public because of the inheritance from the
* InvokationHandler -- should never be called directly.
*/
@@ -132,7 +148,20 @@
return proxyObj.getClass().getName() + '@'
+ Integer.toHexString(proxyObj.hashCode());
}
- return invoke(proxyMap.getString(proxyObj), method.getName(), args,
method.getReturnType());
+ ArrayList argList= null;
+ Class[] paramTypes = method.getParameterTypes();
+ for(int i = 0; i < paramTypes.length; i++)
+ {
+ Class paramType = paramTypes[i];
+ if (locallyResolved.contains(paramType)) {
+ // Optimize for the case when there is no locallyResolved
+ if (argList==null)
+ argList= new ArrayList(Arrays.asList(args));
+ argList.remove(i);
+ }
+ }
+ return invoke(proxyMap.getString(proxyObj), method.getName(),
+ argList==null? args : argList.toArray(),
method.getReturnType());
}
private Object invoke(String objectTag, String methodName, Object[] args,
Class returnType) throws Exception {
_______________________________________________ Jabsorb-dev mailing list [email protected] http://lists.jabsorb.org/mailman/listinfo/jabsorb-dev
