is it possible to call one jax-rs method from another?

后端 未结 2 576
死守一世寂寞
死守一世寂寞 2021-01-07 23:27

suppose i have some jax-rs resource class:

@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class ResourceA {
   @GET
   pu         


        
2条回答
  •  -上瘾入骨i
    2021-01-08 00:15

    You can get it using ResourceContext as follows:

    @Context 
    ResourceContext resourceContext;
    

    This will inject the ResourceContext into your Resource. You then get the resource you want using:

    ResourceB b = resourceContext.getResource(ResourceB.class);
    

    The Javadoc for ResourceContext is here. You can find a similar question here

提交回复
热议问题