Restlet ported to GWT ! July 25, 2008Posted by Jerome Louvel in GWT, Restlet General, User interface.
Google Web Toolkit is a very successful technology that brings Java right inside Web browsers. It could be compared to traditional Applets but without requiring any extra plugin and with a more natural integration with the browser artifacts.
Now, how can you leverage REST in GWT? By default, they propose an opaque GWT-RPC mechanism that is closer to SOAP than to REST. It gives a feeling of transparent distribution but actually introduces tight coupling between client and server code and prevents you from leveraging existing RESTful back-ends. There is an HTTP request builder class that you can use, but it requires knowledge of lower HTTP levels like the exact headers syntax.
Wouldn’t it be nice to use the Restlet API instead, which provides a higher level mapping of HTTP semantics to a clean Java API ? Thanks to the support for generics added in GWT 1.5, we were able to achieve this port with reduced efforts and limited troubles. We had to get rid of the server-side features that don’t make sense in a browser, and of the APIs like NIO and logging that aren’t emulated by GWT. The major impact was the adaptation of the API to the asynchronous communication imposed by AJAX and GWT.
The port, named “Restlet edition for GWT”, is available since Restlet 1.1 and its usage is documented in our Wiki. There is a discussion comparing the GWT-RPC and Restlet edition for GWT architectures and much more! The testing, most of the documentation as well as the back-end integration (see the server-side GWT extension) was contributed by Rob Heittman. I would like to thank him as well for the numerous design discussions while working on this port.
Rob Heittman is Chief Technology Officer at Solertium. Using prototypes of the Restlet edition for GWT, Solertium has been building large enterprise applications with Restlet and GWT for the past year, for worldwide customers like IUCN and Conservation International. “I love GWT, but I prefer RESTful web services to RPC,” says Rob. “GWT backed by Restlet has been great for us. Now, GWT 1.5 and the new Restlet edition for GWT will make our client-side code as simple and elegant as our server code.”
Finally, if you want to follow the latest news about GWT, I recommend the onGWT blog. It is maintained by Didier Girard, a good friend who introduced me to the joys of GWT!
- Carl Scott -RESTful Client-Side tools for GWT
- Reworded to match the latest terminology changes (Restlet edition for GWT instead of Restlet-GWT module)
- Updated links to point to Restlet 2.0 version
- New post: Restlet, a RESTful middleware for GWT, GAE and Android