Simplifying rest application development with JAX-RS

Source: Internet
Author: User
Tags representational state transfer

REST Introduction

REST is an abbreviation of the English representational state Transfer, which has a Chinese translation for "representational status transfer". The term REST is proposed by Roy Fielding in his doctoral thesis, Architectural Styles and the design of network-based Software architectures. REST is not a standard, but a architectural style for developing WEB applications that can be understood as a design pattern. REST is based on Http,uri, as well as XML, these existing widely popular protocols and standards, along with the Rest,http protocol has been more correctly used.

REST mode provides a more concise implementation than SOAP and WSDL based WEB services. More and more WEB services are now being designed and implemented in the rest style, and the more famous rest services in the real world include the Google AJAX search API, the Amazon simple Storage service (Amazon S3), and so on.

REST-based WEB services follow some basic design principles:

Each object or resource in the system can be addressed by a unique URI, which should be simple, predictable, and easy to understand, such as a URI that defines the directory structure.

Explicitly use the HTTP method in a manner consistent with the protocol defined by RFC-2616 to establish a one-to-one mapping between the Create, retrieve, update, and delete operations (Crud:create, Retrieve, updates, and deletes) and HTTP methods:

To create a resource on the server, you should use the POST method;

To retrieve a resource, you should use the Get method;

To change the state of a resource or update it, you should use the Put method;

To delete a resource, you should use the Delete method.

Each resource accessed by a URI can be represented in a different form, such as XML or JSON, depending on the client accessing the resource, and the client and service provider use a mechanism of content negotiation (request header and MIME type) to select the appropriate data format. Minimize data coupling between each other.

Jax-rs--Java API for RESTful Web Services

Java EE 6 introduces support for JSR-311. JSR-311 (Jax-rs:java API for RESTful Web Services) is designed to define a unified specification that allows Java programmers to use a fixed set of interfaces to develop REST applications, avoiding reliance on third-party frameworks. At the same time, Jax-rs uses the POJO programming model and the annotation based configuration, and integrates JAXB, which can effectively shorten the REST application development cycle.

The Jax-rs-defined API is located in the Javax.ws.rs package, with some of the main interfaces, annotations, and abstract classes shown in Figure 1.

Figure 1. Javax.ws.rs Package Overview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.