Sorry my bad :-). This is just what I was looking for thanks!
On Aug 2, 2010, at 2:52 AM, "Paul Sandoz-2 [via Jersey]" <ml-node+5363439-925313795-375667_at_n2.nabble.com> wrote:
> Hi,
>
> On Aug 1, 2010, at 5:27 AM, tofferliu wrote:
>
> >
> > Hi,
> >
> > Is there a way to instatiate a subResource such that class member
> > annotated
> > with @Context will still be injected with their respective values?
> >
>
> Yes, you can inject ResourceContext [1]. Or inject the instance
> directly using Jerseys @Inject annotation. If you do not want the
> instance to be instantiated until you require it wrap the injection
> target type in Injectable (or use ResourceContext) e.g.
>
> @Inject Injectable<SubResource> sr;
>
>
> > The problem with the approach below is that it creates the subResource
> > instance without injecting the value for "bar".
> >
> > -Toffer
> >
> > public class SubResource {
> >
> > @Context
> > Foo bar;
> >
> > }
> >
> > @Path("/")
> > public class MainResource {
> >
> > @GET
> > public SubResource getSubResource() {
> > return new SubResource();
> > }
>
> The above method is a resource method not a sub-resource locator,
> because it is annotated with HTTP-based method annotation and not @Path.
>
> > }
>
>
> Paul.
>
> [1] https://jersey.dev.java.net/nonav/apidocs/latest/jersey/com/sun/jersey/api/core/ResourceContext.html
>
> > --
> > View this message in context: http://jersey.576304.n2.nabble.com/Instatiating-subResources-with-Context-class-fields-tp5360153p5360153.html
> > Sent from the Jersey mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
>
> View message @ http://jersey.576304.n2.nabble.com/Instatiating-subResources-with-Context-class-fields-tp5360153p5363439.html
> To unsubscribe from Instatiating subResources with @Context class fields, click here.
>
--
View this message in context: http://jersey.576304.n2.nabble.com/Instatiating-subResources-with-Context-class-fields-tp5360153p5369520.html
Sent from the Jersey mailing list archive at Nabble.com.