What's a JAX-RS implementation?

lixiang picture lixiang · Feb 15, 2011 · Viewed 23.9k times · Source

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!!!

Answer

Heiko Rupp picture Heiko Rupp · Feb 15, 2011

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