dev@grizzly.java.net

Re: Jersey + Grizzly + Weld with _at_RequestScoped

From: Sebastien Dionne <survivant00_at_gmail.com>
Date: Wed, 28 Apr 2010 08:44:15 -0400

Can you tell me the problem please. Do you have a war file? You could
deploy it with Deployer.

On Apr 28, 2010 5:15 AM, "Paul Sandoz" <Paul.Sandoz_at_sun.com> wrote:

Hi,

As per Evan's tweet:

 http://twitter.com/evanchooly/statuses/12951736142

anybody want to help me get Jersey + Grizzly + Weld (the CDI impl
distributed with GF) to work on SE for @RequestScoped support.

You can find a sample maven project here:

http://markmail.org/search/?q=list%3Anet.java.dev.jersey.users#query:list%3Anet.java.dev.jersey.users+page:1+mid:txgigj6adxjtohz4+state:results

What this means is modifying the sample such that the JAX-RS resource class
is:

@Path("hello")
@RequestScoped // per request
public class JerseyResource {

   @Inject BeanManager bm;

   @GET
   public String get() {
       return bm.toString();
   }
}


and then somehow we modify the following:

       GrizzlyWebServer g = new GrizzlyWebServer();

       ServletAdapter jerseyAdapter = new ServletAdapter();
       jerseyAdapter.addInitParameter("javax.ws.rs.Application",
               "org.jersey.jweld.JerseyWebApp");
       jerseyAdapter.setContextPath("/jersey");
       jerseyAdapter.setServletInstance(new ServletContainer() {
           @Override
           protected void initiate(ResourceConfig rc, WebApplication wa) {
               wa.initiate(rc, new JCDIComponentProviderFactory(bm));
           }
       });

       g.addGrizzlyAdapter(jerseyAdapter, new String[] {"/jersey"});
       g.start();

to register a weld listener to manage the request scope. I am assuming Weld
has some sort of basic servlet support one can add as a request context
listener, but i have not checked.

Paul.
P.S. i am not a member of the dev list so please CC on replies.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
For additional commands, e-mail: dev-help_at_grizzly.dev.java.net