Eclipse Juno M4: RAP speaks JSON

In the RAP framework, the widgets in a website are remotely controlled by the web server. The server does this by sending messages to the client in response to Ajax requests. Until now, those messages used to contain proprietary JavaScript that has been evaluated by the browser. Apart from the drawbacks of using eval to process server responses, this tightly couples RAP to its default browser client. The messages were so specific that only this client could understand them.

One of our goals for RAP 1.5 is to open the framework for alternative client implementations. After all, the messages from the server contain precise rendering commands that are not at all specific to JavaScript. Commands like “create a button with text ‘Ok‘, set its size to 190x25px, and place it at pos (23,42)” or “change the text color of the label with id ‘w47‘ to ‘#ff0000‘” can be rendered by any client that is able to create and manipulate widgets. It doesn’t have to be a JavaScript client, also clients written in other languages like Java or Objective C can implement it. Clients can render widgets with any UI technology, be it SVG or even a mobile device’s native widget set.

To allow for those cases, we exchanged the communication format with a simple predefined format based on JSON. With the M4 build published today, all responses from a RAP server are now plain JSON. This also makes the debugging much easier, since developer tools like Firebug display the structure of a message.

RAP Firebug JSON Eclipse Juno M4: RAP speaks JSON

When designing the protocol, we took great care not to limit the exchange format to widgets. Instead, we created a generic synchronization protocol for any kind of objects. Objects are identified with a unique id, and every operation is related to a target object that is referenced by its unique id. There are different types of operations: one to create an object, one to destroy it, one to change some properties on an object, etc. Every message from the server contains a list of operations, besides some meta information.

You’ve guessed that we already have some prototypes for alternative RAP clients in progress. We’ll write about them soon…

2 Responses to “Eclipse Juno M4: RAP speaks JSON”

  1. Jmini says:

    Do you plan a specification of this protocol? Because it is JSON, it can be reverse engineered, but it would be nice to know what the expected operations are. Do you expect big changes in this protocol until Juno?

    You provide a JavaScript client for now, isn’t it? Have you some input on the technologies used on the client (widgets library, …)

    I never used these technologies, but I could imagine a NaCl client or a Flash/Flex client….

  2. Ralf Sternberg says:

    Now that the new protocol is in place, we’ll surely find some details to polish and optimize. The protocol will change until Juno, but I think the changes will be moderate. Once everything has stabilized, we will publish a description of expected properties / operations per widget.

    The default RAP client is written in JavaScript and based on the Qooxdoo.org widget toolkit. We maintain our own branch of this library that is tailored to RAP’s needs.

    Writing a RAP client with Flex shouldn’t be a problem, native clients are already in the works, stay tuned…

2 responses so far

Written by . Published in Categories: EclipseSource News, Planet Eclipse

Author:
Published:
Dec 16th, 2011
Follow:

Twitter Google+ GitHub