Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[riena-dev] Riena Server on JSON protocol with Extjs Direct client

Hi Rienars,

 

To re-use Riena’s Server side code and provide JSON service, we created a JSON service publisher for Riena.

 

Using Riena’s Communication model, the Riena’s Hessian service can be published as JSON service by changing the protocol property to “json”.

 

The server side now is using Google GSON to (de)serialize objects.

 

The client side is Extjs Direct. For more information please refer to Extjs website:

http://www.sencha.com/products/js/

http://www.sencha.com/products/js/direct.php

 

****  Please get proper licence when you use Extjs (as well as GSON)*****

 

The code and sample can be downloaded at http://goo.gl/a37Ok, hosted by Google docs. The code are provided to contribute to Riena projects. For other use of the code please consult platinas.hy@xxxxxxxxx.  

 

To start example:

·         Create a new workspace with latest Riena build.

·         Import the example, 4 projects should be imported: publisher, GSON, sample server and client.

·         Check your run configuration and add required bundles to “JSON server”.

·         Run the configuration, then use your browser to point to http://10.1.1.10:8888/static/index.html then the call should be available.

 

Some issues:

1.       Since JSON does not serialize with java class information, the servlet will need to “Guess” what is the actual implementation. Currently this can be done from getting method signature and de-serialize into the expected class. But if the parameter of method signature is an interface or abstract class, GSON will not know how to de-serialize it.

2.       To (partially) overcome the above issue, the de-serializer now will try to “learn” from the calls about what should be the proper implementation. If the first call has a return type “IUser” which is an interface, but actually returns a “xx.User” object. The deserializer will remember this and nextime if the method call has a param type of “IUser”, it will try to deserialize it into “xx.User” object.

3.       If no such calls were made before, GSON will not know how to deserialize the object if the parameter type is “IUser”

4.       Maybe in the future there can be extension to allow clients to pre-define how to de-serialize objects.

 

Comments are welcome.

 

Regards,

 

Patrick He

Email: platinas.hy@xxxxxxxxx

 


Back to the top