users@jersey.java.net

Re: [Jersey] Custom Context type is not injected?

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 18 Feb 2009 10:44:18 +0100

On Feb 17, 2009, at 6:26 PM, Roytman, Alex wrote:

> Hello Paul,
>
> Thank you for the tip
>
> I do use InjectableProvider for JDO injection for per-request
> lifecycle (it also subscribe its injections to cleanup service
> automatically). I hoped to use @Context for cleanup service to avoid
> an additional annotation for it. The cleanup service is the service
> we talked about with regard of guaranteed "closeable" closure at the
> end of lifecycle. I wanted it as transparent and non-intrusive as
> possible so you could consider it for addition to jersey and did not
> want extra annotations.
>
> I would appreciate your advise on how to proceed with CleanupService
> integration with Jersey. If you would like me to use
> InjectableProvider for CleanupService resolution, which annotation
> would you like me to use?
>

You can reuse @Context, just make sure you check in your injectable
provider for the type you want to support.


> BTW Are there any samples on Resources with Session lifecycle and on
> communication from request level resources to session level one? I
> could not find any prescribed ways of doing it in the specs.
>

No, not currently. Session life-cycle is supported but it is currently
not something i am keen to promote too much because it breaks one of
the REST constraints (statelessness). However, the rules for injection
of per-request stuff onto a per-session or per-singleton is the same.

I think i need to write a simple example of how to do this. Let me try
and do this within the next week or two.

Paul.