users@jersey.java.net

[Jersey] Binding _at_RequestScoped data

From: cowwoc <cowwoc_at_bbs.darktech.org>
Date: Mon, 12 May 2014 19:41:21 -0400

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