Re: @Context annotation...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: @Context annotation...

Paul Sandoz
Administrator
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.

Paul.

--
| ? + ? = To question
----------------\
    Paul Sandoz
         x38109
+33-4-76188109

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...