O'Reilly logo

RESTful Java with JAX-RS by Bill Burke

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 14. JAX-RS Implementations

The JAX-RS specification has been final for over a year now and there are a bunch of implementations out there that you can download and try. This chapter provides an overview of the most popular implementations by highlighting various custom features of each provider. It isn’t meant as documentation for each of the frameworks described, but rather to show you some of the innovations that are going on in the JAX-RS community.

Jersey

Jersey is the open source reference implementation of JAX-RS. It is dual-licensed under both the Common Development and Distribution License (CDDL) version 1.0 and the GNU General Public License (GPL) version 2.

Jersey is built, assembled, and installed using Maven. The main project site, https://jersey.dev.java.net, contains a download button that links to instructions on how to get started with Jersey, its prerequisites, and links to samples. Jersey is also shipped with the application server GlassFish.[19]

Embeddable Jersey

While Jersey is usually deployed within a servlet container, it can also be embedded within simple Java programs. The following Java class represents a very simple example that uses the Grizzly embedded HTTP server to deploy a root resource class called MyResource. It uses the Jersey Client API to communicate with the resource:

import com.sun.grizzly.http.SelectorThread; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.container.grizzly.GrizzlyServerFactory; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required