This chapter describes the REST architecture, RESTful web services, and Sun's reference implementation for JAX-RS (JavaTM API for RESTful Web Services, JSR-311), which is referred to as Jersey.
RESTful web services are services that are built to work best on the web. Representational State Transfer (REST) is an architectural style that specifies constraints, such as the uniform interface, that if applied to a web service induce desirable properties, such as performance, scalability, and modifiability, that enable services to work best on the Web. In the REST architectural style, data and functionality are considered resources, and these resources are accessed using Uniform Resource Identifiers (URIs), typically links on the web. The resources are acted upon by using a set of simple, well-defined operations. The REST architectural style constrains an architecture to a client-server architecture, and is designed to use a stateless communication protocol, typically HTTP. In the REST architecture style, clients and servers exchange representations of resources using a standardized interface and protocol. These principles encourages RESTful applications to be simple, lightweight, and have high performance.
RESTful web services typically map the four main HTTP methods to the operations they perform : create, retrieve, update, and delete. The following table shows a mapping of HTTP methods to the operations they perform.
Table 1–1 Mapping HTTP Methods to Operations Performed
HTTP Method |
Operations Performed |
---|---|
GET |
Get a resource |
POST |
Create a resource and other operations, as it has no defined semantics |
PUT |
Create or update a resource |
DELETE |
Delete a resource |
Jersey is Sun's production quality reference implementation for JSR 311: JAX-RS: The Java API for RESTful Web Services. Jersey implements support for the annotations defined in JSR-311, making it easy for developers to build RESTful web services with Java and the Java JVM. Jersey also adds additional features not specified by the JSR.
The latest version of the JAX—RS API's can be viewed at https://jsr311.dev.java.net/nonav/javadoc/index.html
The information in this guide focuses on learning about Jersey. If you are interested in learning more about RESTful Web Services in general, here are a few links to get you started.
The Community Wiki for Project Jersey has loads of information on all things RESTful. You'll find it at http://wikis.sun.com/display/Jersey/Main.
Fielding Dissertation: Chapter 5: Representational State Transfer (REST), at http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm.
Representational State Transfer, from Wikipedia, http://en.wikipedia.org/wiki/Representational_State_Transfer.
RESTful Web Services, by Leonard Richardson and Sam Ruby. Available from O'Reilly Media at http://www.oreilly.com/catalog/9780596529260/.
Some of the Jersey team members discuss topics out of the scope of this tutorial on their blogs. A few are listed below:
Earthly Powers, by Paul Sandoz, at http://blogs.sun.com/sandoz/category/REST.
Marc Hadley's Blog, at http://weblogs.java.net/blog/mhadley/
Japod's Blog, by Jakub Podlesak, at http://blogs.sun.com/japod/category/REST.
You can always get the latest technology and information by visiting the Java Developer's Network. The links are listed below:
Get the latest on JSR-311, the Java API's for RESTful Web Services (JAX-RS), at https://jsr311.dev.java.net/.
Get the latest on Jersey, the open source JAX-RS reference implementation, at https://jersey.dev.java.net/.