From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 22 Jul 2008 11:53:28 +0200
Martin Grotzke wrote:
> Alternatively you can get subresources from jersey using the
> ResourceContext:
>
> @Path("/")
> public static class MyRootResource {
>
> @Context ResourceContext _resourceContext;
>
> @Path( "subresource" )
> public MySubResource getMySubResource() {
> MySubResource result = _resourceContext.getResource( MySubResource.class );
> return result;
> }
>
> }
>
> Then the subresource will get all required fields injected.
>
Plus you can also do following:
@Path("/")
public static class MyRootResource {
@Context ResourceContext _resourceContext;
@Path( "subresource" )
public Class<MySubResource> getMySubResource() {
return MySubResource.class;
}
}
that implicitly does what Martin explicitly shows.