users@jersey.java.net

Jersey/JAX-RS integration with _at_ManagedBean

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Thu, 01 Oct 2009 21:41:10 +0200

Hi,

I have recently implemented, thanks to Ken, integration with
@ManagedBean.

This means one can inject EE artifacts on to root resource classes
that are managed beans. Just annotate the resource class with
@ManagedBean. For example:

   @Path("/managedbean/per-request")
   @ManagedBean
   public class ManagedBeanPerRequestResource {

       @Resource(name="injectedResource") int injectedResource = 50;

       @Context UriInfo ui;

       ...
   }


To experiment you need to use Jersey 1.1.3-ea-SNAPSHOT and build 65 or
greater of GF v3 [1] (i have only tested on promoted build 65 of GF v3).

See the sample in the SVN (it will be available on the maven repo):

   jersey/samples/managed-beans-webapp

(see attached for a zip file)

To make this work you need to make two modifications to the sample:

1) Change classloader delegation in the sun-web.xml to false; and

2) Remove the provided scope from the jersey-server dependency in the
pom.xml.

Paul.