The Representational State Transfer (REST) architectural style has a stateless client-server architecture in which web services are treated as resources that can be identified by their URLs. Web service clients can access these resources using a small set of remote methods that describe the action to be performed on the resource. REST style systems can take full advantage of the scalability features of HTTP such as caching and proxies.
In REST, servers expose resources using a URI, and clients access these resources using the four HTTP verbs (GET, POST, PUT, and DELETE). As clients receive representations of a resource, they are placed in a state. When they access a new resource, typically by following a link, they change, or transition, their state.
REST systems are highly scalable and highly flexible. With REST systems, clients are less affected by changes to servers because:
Resources are accessed and manipulated using the four HTTP verbs
Resources are exposed using a URI
Resources are represented using standard grammars
The existing web architecture is an example of a system designed on REST principles. Web browsers act as clients accessing resources hosted on Web servers. The resources are represented using HTML or XML grammars that all Web browsers can consume. The browsers can also easily follow the links to new resources.
FUSE Services Framework supports JAX-RS (JSR-311), the Java API for RESTful Web Services according to the REST architectural style. JAX-RS provides a standard way to build RESTful services in Java, using annotations to simplify the development and deployment of web service clients and endpoints.
Some features of using JAX-RS to develop RESTful services are:
The URI bindings are local to the resource beans, which can be arbitrarily nested. This feature simplifies refactoring.
The loose coupling between the objects returned by the resource methods and providers is clean, making it easy to drop in support for new representations without changing the code of your resource beans (or controllers). Instead, you can just modify an annotation.
Static typing can be useful when binding URIs and parameters to your controller, for example, having parameters and String, integer, and Date fields prevents you from having to explicitly convert things in your controller.
See the following references for more information:
JAX-RS Service Development explains how to work with a sample using JAX-RS service development.
Developing RESTful Services provides information about JAX-RS front end programming.
The Java web site for the JAX-RS specification provides information about the Java API for RESTful Web Services.
You use JavaScript Object Notation (JSON) bindings with JAX-RS front ends. JSON is a lightweight data format for data exchange. It is a text-based, human-readable format for representing simple data structures and associative arrays (called objects).
An advantage of JSON is that is very easy for JavaScript developers to use, because once it is evaluated it immediately becomes a JavaScript object. JSON is supported through Jettison, a StAX implementation that reads and writes JSON. Jettison intercepts calls to read/write XML and instead read/writes JSON.
For information about using JSON data bindings, see the JSON web site and the JSON section of the Apache CXF User's Guide.
HTTP is the underlying transport for the Web. It provides a standardized, robust, and flexible platform for communicating between endpoints. Because of these factors it is integral to RESTful architectures. See Using the Bindings and Transports for information about using transports with FUSE Services Framework.