users@jersey.java.net

[Jersey] Re: _at_ParentRef

From: Christopher Piggott <cpiggott_at_gmail.com>
Date: Sat, 25 Aug 2012 22:57:44 -0400

Sorry, I meant @ParentRef earlier ... brain freeze.

On Sat, Aug 25, 2012 at 10:56 PM, Christopher Piggott
<cpiggott_at_gmail.com> wrote:
> Hi,
>
> I have a number of subresources that I create using:
>
> @Context ResourceContext rc;
>
> ...
> @Path("attachments)
> public AttachmentsSubResource goToAttachments()
> {
> AttachmentsSubResource sub = rc.getResource(
> AttachmentsSubResource.class );
> sub.setSomething( Something s);
> return sub;
> }
>
> The idea is that the subresource needs to be prepared before it can be
> used. Before CDI/Weld, I would have done this with guice assisted
> injection.
>
> I'm wondering if maybe a way to avoid this is to invert the setup by
> having the subresource get a @ParentResource injection, using an
> interface of some sort that allows it to do a .getSomething() from the
> parent resource. Is that the intent of @ParentResource?
>
> --Chris