Evaluate Weigh the pros and cons of technologies, products and projects you are considering.

Restlet framework wrestles RESTful Web applications

Restlet is an open source Java-based framework for creating RESTful Web services. It includes support for annotations and WADL. Read this overview to learn about the framework's creation important changes for version 2.0.

Few dissertations have had an impact comparable to that of Roy Fielding'sArchitectural Styles and the Design of...

Network-based Software Architectures nine years ago. In Chapter 5 he developed the Representational State Transfer (REST) view of network architecture. As the REST way of looking at Web services architecture percolated through the developer community, many developers felt inspired. Before looking at Restlet, one of the first toolkits inspired by REST, lets consider the requirements of REST as stated by Fielding.

The most important requirements have to do with the use of a limited number of strictly defined operations. For Web services, these are the HTTP methods GET, POST, PUT, DELETE, OPTIONS, and HEAD. For example, by strict REST style, the GET operation only returns a representation of the state of a resource without causing any side effect.

Other requirements have to do with the representation of a resource. We need to recognize that a resource can have a number of representations. For example, economic statistics might take the form of graphic images in a variety of formats or data formatted for a spreadsheet. HTTP provides the header "Accept" to define the Internet media types a request will accept, "Accept-Charset" to define acceptable character encodings, and "Content-Type" to define response media type. Other headers can supply metadata about a resource, such as the "Last-Modified" date. HTTP status codes provide a well-defined short-form way to inform a requesting client how the request has been handled. Ideally a REST programming toolkit would make it easy use of HTTP headers and status codes to support REST concepts.

The Restlet framework
Development of the Java-based Restlet framework was started by Jerome Louvel, founder of Noelios Technologies, a French consulting firm. In an arrangement common to many open source tools, Noelios supports open source community development while supplying clients with expert assistance in creating applications. The API and reference implementation code are distributed under the CDDL (Common Development and Distribution License), a form of licensing compatible with Sun's Public License, and considered more liberal for commercial use than the GPL.

More on REST
Report on REST 

Mulesoft Architect talks REST, ESBs 

Considerations for creating a REST implementation strategy

The original intent of Restlet was to support the REST concepts elucidated by Fielding as directly as possible with Java classes representing the component parts of Fielding's diagrams. Work started in 2005, before anything like the JSR 311, the Java API for RESTful Web Services, existed. Jerome Louvel was one of the developers supporting the Java Community Project work on initial drafts of JSR 311, but that project had only just started when the Restlet version 1.0 framework was released in April 2007. Although an early release, it had support for many important concepts, including data representation in XML, HTML and JSON forms, support of both HTTP and HTTPS connectivity, and authentication. A Restlet with direct support of Java's NIO (non-blocking IO) classes avoided the existing servlet API's limitations of one Thread per request. A Restlet application can run as stand-alone or as a component of a larger container. Furthermore, the class library was designed to support both server and client and server side applications.

The work of the JSR 311 group was reflected in Restlet release 1.1 in October of 2008, coincident with the final release of the JAX-RS standard. Major changes were required to add the use of annotations to Restlet classes. Annotations, which were introduced with Java version 1.5, allow a service container to locate the classes and methods capable of fulfilling a given request. The following example from Restlet documentation shows annotation of two methods. The container will pick the method to call to satisfy a GET request according to the "Accept" header.

    public String getHtml() {
        return "\n"
                + "This is an easy resource (as html text).\n"
                + "";

    public String getPlain() {
        return "This is an easy resource (as plain text)";

Other improvements included support for theWeb Application Description Language (WADL), including provision for services to generate WADL documentation on request.

Restlet Version 2
Originally conceived as version 1.2, the number of changes warrented a major version number. As of this writing, Restlet version 2 has reached the "Milestone 4" release. This major redesign of the Restlet framework is intended to achieve API simplifications and improvements based on experiences with version 1.1, and incorporate contributions by many enthusiastic developers. There has been a vast expansion of compatibility for integration with many popular toolkits, response media types, and servlet container alternatives.

An important feature of this new release is the availability of distribution packages tailored for different environments but all derived from the same code base. As of Milestone 4, there are editions specificaly tailored for Java Standard Edition, Java Enterprise Edition, Google Web Toolkit (browser-side JavaScript), Google App Engine (cloud server), and Google's Android operating system for cell phones. Note that we are talking about both server-side and client-side tools, reflecting the Restlet philosophy that server and client side of RESTful applications should share as much code as possible.

What Roy Fielding is up to these days
RFC 2616, the HTTP/1.1 standard.
Home page for Restlet at Noelios Technologies
Restlet framework home page is essentially an alternate Noelios site
The RESTful Web Services book (May 2007) includes Restlet 1.0 examples
Sun's tutorial on the use of annotations
Sun support for WADL in the Glassfish project

Dig Deeper on Topics Archive

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.