Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's a JAX-RS implementation?

Tags:

I have been trying to figure out how to use JAX-RS for quite some time. I started from the very basic concepts and then to gradually understand the annotation styled programming, the meaning of @Path, @Get, @Post, etc.

To my understanding, as to what has been mentioned in a lot of places, JAX-RS is a framework that focuses on applying Java annotations to plain Java objects (Page 27, Bill Burke, RESTful Java).

I have then got confused beyond this point. If JAX-RS in itself is a framework that defines APIs dealing with annotations in order to implement RESTful web service, what's the meaning of "implementation of JAX-RS" such as "Jersey" and "JBoos Resteasy". Another layer on top of JAX-RS? Why do we need them?

Could someone provide me some insights about it? Many thanks!!!

like image 306
lixiang Avatar asked Feb 15 '11 15:02

lixiang


People also ask

What is a JAX-RS provider?

The JAX-RS specification allows you to plug in your own request/response body reader and writers. To do this, you annotate a class with @Provider and specify the @Produces types for a writer and @Consumes types for a reader. You must also implement a MessageBodyReader/Writer interface respectively.

Why do we need JAX-RS?

Why use JAX-RS / Jersey? Because it makes the development of RESTful services easier. JAX-RS is a standard that makes it easy to create a RESTful service that can be deployed to any Java application server: GlassFish, WebLogic, WebSphere, JBoss, etc.

Which of the following is the JAX-RS reference implementation?

Jersey - the JAX-RS Reference Implementation from Sun. RESTEasy - JBoss's JAX-RS project. Restlet - probably the first REST framework, which existed prior to JAX-RS.

What is your understanding about JAX-RS?

JAX-RS is a JAVA based programming language API and specification to provide support for created RESTful Web Services. Its 2.0 version was released on the 24th May 2013. JAX-RS uses annotations available from Java SE 5 to simplify the development of JAVA based web services creation and deployment.


2 Answers

JAX-RS is a standard defined in Java Specification Request 311 (JSR-311) and Jersey / RESTEasy are implementations of it.

Being implementations mean that the spec says "if you put @GET("/foo") on a method (bar()), you may access data X" - now in an app server, someone needs to go in and actually read your deployed code, parse the byte code with the @GET annotation and then if the user actually browses to e.g. http://localhost/foo get this web request to reach bar() and translate the return value of bar() into a http answer (e.g in XML or JSON representation).

So the spec with the name "JAX-RS" only provides the syntax and semantics of e.g. @GET, but the work of parsing requests, calling the right methods, marshalling the result values etc. need to be done by a package that implements the Spec.

Work on the version 2.0 of the standard has started as JRS-339.

See also http://en.wikipedia.org/wiki/Jax-rs

like image 188
Heiko Rupp Avatar answered Oct 14 '22 11:10

Heiko Rupp


JAX-RS is a specification for RESTful Web Services with Java. There is a reference implementation that is included in Java EE but since it is a specification, other frameworks can be written to implement the spec, and that includes Jersey, Resteasy, and others.

like image 34
Robby Pond Avatar answered Oct 14 '22 11:10

Robby Pond