dev@grizzly.java.net

Re: Jersey + Grizzly + Weld with _at_RequestScoped

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 28 Apr 2010 17:04:14 +0200

On Apr 28, 2010, at 4:51 PM, Justin Lee wrote:

> I'm "evan, " btw.

Very sorry about that. I don't know why i mixed you up with your tweet
ID :-)


> I'd love to take a look at it as I have time. I can't dedicate my
> primary time on it as I have other demands, but jersey/weld on
> grizzly sounds too interesting to pass up. Hopefully with everyone
> on this list, we can make this work. It'd be a killer feature to
> tout for potential adopters. It probably means improving our
> servlet support but that's been on my radar for a while now anyway.
>

OK. My guess is for the servlet level there is probably some Weld
servlet listener already available, just not looked, that could be set
on the ServletAdapter. So it may be just a matter of telling people,
like me :-), what do to in certain cases.

For web.xml deployment to detect a beans.xml that definitely would
require some Grizzly additions/changes.

In fact if there was a beans.xml present in the META-INF and you had
say a dependency on a grizzly-servlet-weld module then perhaps one
should not require any additional configuration?

Paul.


> On 4/28/10 10:00 AM, Paul Sandoz wrote:
>> On Apr 28, 2010, at 2:44 PM, Sebastien Dionne wrote:
>>
>>> Can you tell me the problem please.
>>>
>>
>> It's not really a problem with Grizzly. More of an investigation,
>> as i described in the email, since Evan via his tweet expressed
>> interest and a potential offer making the example work better with
>> Grizzly and Weld.
>>
>>> Do you have a war file? You could deploy it with Deployer.
>>>
>>>
>>
>> Please see the example code i refer to in the email.
>>
>> We need to wire up something like a servlet listener to manage the
>> CDI request/response scope. So i thought that Evan et. al. might be
>> interested looking at Weld and seeing if there is an appropriate
>> servlet-based artifact one could use in such cases. I have not yet
>> looked myself.
>>
>> Paul.
>>
>>
>>
>>>> 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
>>>>
>>>
>>
>>