users@jersey.java.net

Re: [Jersey] Object injection

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Thu, 31 Jul 2008 17:00:18 -0400

Assuming you are using Servlets and the default per-request resource
class lifecycle, then the filter could put the object in the servlet
context and the resource class could extract it in its constructor.

Marc.

On Jul 31, 2008, at 3:47 PM, Li, Jun wrote:

> Hi,
>
> I just wondering if there is a way to inject a object for all the
> GET/PUT/POST/DELETE methods.
> Basically, I have a session filter which extracts an id in the
> header, then I construct a object based on the id.
> And I'd like to pass the object to all the methods in the resources,
> so I don't need to have the exactly same code (although it is just
> one line) in each methods.
>
> Any suggestion?
>
> Thanks,
> Jun
>
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> Please access the attached hyperlink for an important electronic
> communications disclaimer:
>
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
>

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.