Monday, May 18, 2015

REST with JAX-RS using Jersey

JAX-RS: 
·         JAX-RS Specification is the Java API for RESTful web services.
·         JAX-RS specification is the outcome of the Java Specification Request (JSR) 311, 339.
·         JAX-RS provides high level simpler API to write RESTful web services that can run on Java EE and SE platforms.

·         JAX-RS is part of the Java EE6, and make developers to develop REST web application easily.
·         JAX-RS uses the declarative style of programming using annotations
·         JAX-RS annotations are runtime annotations; therefore, runtime reflection will generate the helper classes and artifacts for the resource.


JAX-RS Annotations 


The javax.ws.rs package contains JAX-RS annotations.


Annotation
Description
Path
It identifies the URI path. It can be specified on class or method.
PathParam
represents the parameter of the URI path.
GET
specifies method responds to GET request.
POST
specifies method responds to POST request.
PUT
specifies method responds to PUT request.
HEAD
specifies method responds to HEAD request.
DELETE
specifies method responds to DELETE request.
OPTIONS
specifies method responds to OPTIONS request.
FormParam
represents the parameter of the form.
QueryParam
represents the parameter of the query string of an URL.
HeaderParam
represents the parameter of the header.
CookieParam
represents the parameter of the cookie.
Produces
defines media type for the response such as XML, PLAIN, JSON etc. 
It defines the media type that the methods of a resource class or MessageBodyWriter can produce.
Consumes
It defines the media type that the methods of a resource class or 
MessageBodyReader can produce.

No comments:

Post a Comment