users@jersey.java.net

[Jersey] _at_ParentRef

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

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