Johann Reyes wrote:
Hello Ben

You are using JSON-RPC, have you tried DWR? In my case I'm using it, it
works fairly well, but I'm wondering how you implement JSON-RPC with
qooxdoo.

Here is a example how I implement dwr with qooxdoo:
Whilst DWR is a good project, I have adopted JSON-RPC because it's a formal standard with broader server-side platform support. I consider this important because frameworks like Qooxdoo provide a very welcome opportunity to collaborate with non-Java programmers. Collaboration beyond the Java community not only encourages the development of a broader community and critical mass of server agnostic projects like Qooxdoo, but it also brings different design approaches together and this benefits everyone.

In terms of Spring integration with JSON-RPC, I wrote a Spring BeanPostProcessor. I could polish it some more (like named beans in addition to a marker interface), but basically it's shown below. It locates any bean in the application context which implements the JsonExportable marker interface.

public interface JsonExportable {}

public class JsonBridgeBeanPostProcessor implements BeanPostProcessor {
public Object postProcessBeforeInitialization(Object obj, String beanName) throws BeansException {
       return obj;
   }

public Object postProcessAfterInitialization(Object obj, String beanName) throws BeansException {
       if (obj instanceof JsonExportable) {
           JSONRPCBridge.getGlobalBridge().registerObject(beanName, obj);
       }
       return obj;
   }
}

To use JSON-RPC in Java, go download it from http://oss.metaparadigm.com/jsonrpc/, then add the JAR to your classpath and add to web.xml:

   <servlet>
       <servlet-name>com.metaparadigm.jsonrpc.JSONRPCServlet</servlet-name>
<servlet-class>com.metaparadigm.jsonrpc.JSONRPCServlet</servlet-class>
       <init-param>
           <param-name>auto-session-bridge</param-name>
           <param-value>0</param-value>
       </init-param>
   </servlet>

   <servlet-mapping>
       <servlet-name>com.metaparadigm.jsonrpc.JSONRPCServlet</servlet-name>
       <url-pattern>/JSON-RPC</url-pattern>
   </servlet-mapping>

Client-side use it amazingly simple. There is a jsonrpc.js you need to include, and then you simply execute:

QxSettings.serverUrl = "/acegi-ajax/JSON-RPC";
var jsonrpc = new JSONRpcClient(QxSettings.serverUrl);
jsonrpc.someBeanOnServer.someMethodOnTheBean();

I am not using the JSON-RPC Java implementation's session-based support, as I use Acegi Security for security instead.

Cheers
Ben
**


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Qooxdoo-devel mailing list
Qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to