users@jersey.java.net

[Jersey] Re: How to bind object as RequestScoped?

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Fri, 29 Aug 2014 14:34:08 +0200

It is stable, but internal API at the moment. The stale TODO comment has been removed.

Marek

On 14 Aug 2014, at 11:53, Roger Nordquist <roger.nordquist_at_valtech.se> wrote:

> Hi,
>
> My question is regarding hk2/jersey2 bindings request scoped, is it possible?
>
> In my project we need to have an instance created by a factory only created once per request.
> It only contains data taken from the HttpRequest but we want our own class which maps our model better.
>
> Can we bind this via hk2 bindings as org.glassfish.jersey.process.internal.RequestScoped ?
> My initial tests looks ok but the todo comment in the annotation class file and the fact that it resides inside the internal package makes me worry a bit if it is stable?
>
>> /**
>> * Request scope binding annotation.
>> *
>> * TODO find a way how to bind the scope annotation to the request scope instance.
>> *
>> * @author Marek Potociar (marek.potociar at oracle.com)
>> */
>> @Target({TYPE, METHOD})
>> @Retention(RUNTIME)
>> @Scope
>> public @interface RequestScoped {
>> }
>
>
> Thx for any help!
>
> /Roger