[Jersey] How to bind object as RequestScoped?

From: Roger Nordquist <>
Date: Thu, 14 Aug 2014 09:53:39 +0000


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
@Target({TYPE, METHOD})
public @interface RequestScoped {

Thx for any help!