Guys --

If there are no rejects I will commit this change tomorrow.

Brantley, would it be possible for you to help with creating a JUnit test case to make sure this patch works propertly?

Thanks,
-- Sasha

Brantley Hobbs wrote:
I like this idea.  The biggest question mark I had was introducing those 
dependencies, and this solves that issue.

By the way:  Are you the same Sasha that implemented the 
"json-rpc-client" hosted on Google code?  If so, I also have a patch for 
that client (using the same method as the patch I submitted yesterday).  
That is the client that we're using in production.  We simply haven't 
moved to jabsorb yet....

Thanks!
Brantley


Sasha Ovsankin wrote:
  
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).

The patch works by removing any outgoing arguments if they are one of 
the classes that should be locally resolved on the server 
(HttpSession, HttpServletRequest, HttpServletResponse and JSONRPCBridge).

Brantley
------------------------------------------------------------------------

_______________________________________________
Jabsorb-dev mailing list
[email protected]
http://lists.jabsorb.org/mailman/listinfo/jabsorb-dev
      
------------------------------------------------------------------------

_______________________________________________
Jabsorb-dev mailing list
[email protected]
http://lists.jabsorb.org/mailman/listinfo/jabsorb-dev
    

_______________________________________________
Jabsorb-dev mailing list
[email protected]
http://lists.jabsorb.org/mailman/listinfo/jabsorb-dev
  
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,22 @@
     proxyMap.remove(proxy);
   }
 
+  static HashSet locallyResolved= new HashSet();
+
   /**
+   * Register class as locally resolved. Parameters of this class are 
considered locally resolved --
+   * implicitly supplied by the environment on the server so they are 
+   * not sent to the server in the RPC call.
+   */
+  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 +150,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

Reply via email to