users@jersey.java.net

[Jersey] Re: Binding _at_RequestScoped data

From: Robert DiFalco <robert.difalco_at_gmail.com>
Date: Mon, 12 May 2014 16:49:19 -0700

What are you binding to? I mean isn't @RequestScoped meant for your
resource? Meaning it will be re-instantiated for each request? It looks
like you are trying to overload what it is used for in some way.

Are you saying that you are @RequestScoped annotating your REST resource
and that you sometimes see it not being instantiated for a request?

Also, just wondering, what is the high level problem you are trying to
solve? Maybe there is a better way of solving the problem that does not
involve @RequestScoped.



On Mon, May 12, 2014 at 4:41 PM, cowwoc <cowwoc_at_bbs.darktech.org> wrote:

> Hi,
>
> How are we supposed to bind @RequestScoped variables in Jersey?
>
>
> 1. The scope @RequestScoped is listed in Jersey's "internal" package.
> 2. When I try to bindFactory().in(RequestScoped.class) I sometimes get
> stale values out of ServiceLocator.getService(). Meaning, the Factory
> binding is not getting removed at the end of the HTTP request.
> 3. Using ThreadLocal doesn't seem safe in light of the fact that
> threads could be reused across HTTP requests, and there doesn't seem to be
> a clean way to detect the end of a request.
>
>
> Any ideas?
>
> Thanks,
> Gili
>