users@glassfish.java.net

Jersey/JAX-RS integration with Servlet 3.0

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 03 Sep 2009 10:31:59 +0200

Hi,

I have just implemented Servlet 3.0 integration into Jersey so that it
is no longer necessary to utilize web.xml (or if utilized it is not
necessary to declare the servlet class).

To experiment you need to use Jersey 1.1.3-ea-SNAPSHOT and build 61 or
greater of GF v3. Currently i have only tested on promoted build 61 of
GF v3.

Attached are some maven-based samples. Naresh, these samples could
form the basis of some functional tests, but they do not fully cover
all cases, see the following code to get an understand of what else
needs to be tested:

   http://fisheye4.atlassian.com/browse/jersey/trunk/jersey/jersey-server/src/main/java/com/sun/jersey/server/impl/container/servlet/JerseyServletContainerInitializer.java?r=2735

Jersey will use it's implementation of the Servlet 3.0
ServletContainerInitializer interface to detect classes that extend
from javax.ws.rs.core.Application.

For example. the "annotatedapp" sample contains the following class:

   @ApplicationPath("/oneonly")
   public class OneApplication extends Application {
       @Override
       public Set<Class<?>> getClasses() {
           return Collections.<Class<?>>singleton(One.class);
       }
}

A Jersey servlet will be registered at the mapping "/oneonly/*" using
OneApplication as the class that registers root resource and provider
classes.

Paul.