Luciano Resende wrote:
On Mon, Aug 23, 2010 at 6:15 PM, Jean-Sebastien Delfino
<[email protected]> wrote:>
- JSON-RPC binding not using the databinding framework
I think we need to be careful about this....

From a maintenance point of view it would be useful to follow the same
infrastructure pattern regardless of what binding and implementation
are in use. It may be possible to embody the notion of conversion to
generic parameters into databinding itself.


Could you please clarify what do you mean by JSON-RPC not using
databinding framework. I'm pretty sure it is using the databinding
framework. Did you mean JSONP by any chance ?


I really meant JSON-RPC.

In JSONRPCServiceServlet SVN r954414 (before my changes) [1], method handleJSONRPCMethodInvocation() uses a jabsorb JSONArray to convert JSON to an array of Java args and sets that Java array directly into the invocation message body.

In JSONRPCClientInvoker SVN r988365 [2], method invoke() casts the message body to an array of Java objects and passes it to a jabsorb.Client proxy.

I also found another, unused, invoker implementation.

In JSONRPCBindingInvoker SVN r988365 [3], method invoke() casts the message body to an array of Java objects and builds a JSONArray used to produce the JSON-RPC request.

In these 3 instances:
- the JSON databinding is not used to (de)serialize the JSON stream;

- the jabsorb JSONArray and Client code require that the arg types be defined as specific Java classes;

- the logic assumes that args are passed as elements of an Java array, if the component uses an XML (or JSON) databinding for example that doesn't work.

My changes only worked around these problems in the case I was interested in.

I tweaked JSONRPCServiceServlet and JSONRPCBindingInvoker (as it was closer to the expected logic than JSONRPCClient) to just pass the JSON stream directly to/from the component if that component uses a JSON databinding (as that's the databinding used in the Python component).

Fixing this completely would require more significant changes to the JSON-RPC binding. For example if the component (say BPEL) expects another databinding (XML DOM in the BPEL case) then the proper logic would be to let the databinding framework perform the conversion from JSON to XML DOM (but that goes a little over my head)... perhaps Raymond or another databinding expert could help fix this...

[1] http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java?view=markup&pathrev=954414 [2] http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCClientInvoker.java?view=markup&pathrev=988365 [2] http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java?view=markup&pathrev=988365
--
Jean-Sebastien

Reply via email to