Using the Restlet framework to develop a rest Web Service that conforms to the JSR311 specification standard

Source: Internet
Author: User
Tags http post resource web services

JSR311 as a standard for Java to implement the rest Web Service, though controversial from birth, is in fact universally accepted by most rest implementation frameworks. In the midst of this, both Sun's native Jersey and other open-source projects, such as Jboss's Resteasy, Apache's CXF. Of course, there is the longest development time, quite mature RESTlet framework.

The main core of RESTlet is according to the works of Roy Thomas Fielding "Architectural Styles and the design of network-based Software". Clear structure, strong stability. But the resource definition under this framework is different from the JSR311 of the jax-ws style of annotation. This is the risk of choosing a camp for a Web Service developer who loves RESTlet. Fortunately, RESTlet's lead developer Jérome Louve is also a JSR311 participant, as reflected in RESTlet 1.1, which provides a Extension to help RESTlet developers write JSR311-compliant Web Service. Some enterprise-class products, such as IBM Systems Director 6.1.2, have already used this technology in their products. This article focuses on the basic implementation structure of JAX-RS extension and how to use the plug-in to perform JSR311 standard REST Service.

This paper takes neolies RESTlet 1.1.8 as the basis for discussion, and assumes that the reader has a certain understanding of rest,jax-rs and RESTlet. As a result, the basic knowledge is not discussed in detail, and readers can learn about this by reading "Building RESTful Web Services."

RESTlet and JSR-311

Jax-rs Annotation Introduction

@Path: Used to map URIs, provide access paths for resource classes and methods contained in resource classes.

@GET: Represents a resource class method that handles HTTP get requests. When the Web Service obtains an HTTP get operation from the client for a network resource, the server invokes the method after the @GET annotation to process the GET request. Of course, the invoked resource class method first has to satisfy the URI.

@POST: Represents the resource class method that handles HTTP POST requests. Similar to @GET, except that it corresponds to an HTTP POST operation.

@PUT: Represents the resource class method that handles HTTP put requests. This Annotation is typically used to update network object methods. and @GET, @POST processing process is similar.

@DELETE: Represents a resource class method that handles HTTP DELETE requests. The method after using this Annotation is usually to delete an instance of each network object. Process and @GET, @POST, @PUT similar.

@HEAD: Represents a resource class method that handles HTTP head requests. In general, according to the JAX-RS specification, RESTlet jax-rs extension automatically processes HTTP head requests when no resource class method is implemented, and the resource class method of the annotation is automatically invoked @GET. And the difference between processing an ordinary HTTP GET request is that no instance is returned. Resource class methods @HEAD annotations are often used to obtain data formats that Web Services can accept.

@Produces: The type of media used to represent the MIME that the resource class method can return.

@Consumes: A type of media used to represent the MIME that a resource class method can handle.

Neolies RESTlet The design style as much as possible to follow the REST goals set out in the Dr. Roy Fielding's thesis. From the implementation level, Neolies RESTlet can be divided into three parts:

RESTlet API: This section designs the RESTlet framework, including the application, Component,route,connector,virtualhost, Resource, etc. included in the classic REST structure, are defined in detail in this section.

NRE (Noelios Restlet Engine): This section is a reference implementation of the Restlet API, Restlet API through Proxy mode (delegation) to transfer specific work to the NRE, such as a in the Restlet API The agent of Pplication in NRE is Applicationhelper.

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.