@GET
 @Path("/forward/object/{id}")
 public Response forwardObject(
     @PathParam("id") Integer id, @Context InternalDispatcher dispatcher) {
   uriStack.push(uriInfo.getAbsolutePath().toString());
   return dispatcher.getResponse("/object/" + id);
 }
 @POST
 @Consumes("text/plain")
 @Path("/forward/basic")
 public void postForwardBasic(String basic, @Context InternalDispatcher dispatcher) {
   uriStack.push(uriInfo.getAbsolutePath().toString());
   dispatcher.postEntity("/basic", basic);
 }
 @GET
 @Produces("text/plain")
 @Path("/forward/basic")
 public String forwardBasic(@Context InternalDispatcher dispatcher) {
   uriStack.push(uriInfo.getAbsolutePath().toString());
   return (String) dispatcher.getEntity("/basic");
 }
Пример #4
0
 public SynchronousDispatcher(ResteasyProviderFactory providerFactory) {
   this.providerFactory = providerFactory;
   this.registry = new ResourceMethodRegistry(providerFactory);
   defaultContextObjects.put(Providers.class, providerFactory);
   defaultContextObjects.put(Registry.class, registry);
   defaultContextObjects.put(Dispatcher.class, this);
   defaultContextObjects.put(InternalDispatcher.class, InternalDispatcher.getInstance());
 }
    @GET
    @Path("/infinite-forward")
    @Produces("text/plain")
    public int infinitFoward(
        @Context InternalDispatcher dispatcher, @QueryParam("count") @DefaultValue("0") int count) {
      uriStack.push(uriInfo.getAbsolutePath().toString());
      try {
        dispatcher.getEntity("/infinite-forward?count=" + (count + 1));
        // we'll never reach 20, since the max count of times through the
        // system is 20, and first time through is 0
        Assert.assertNotSame(20, count);
      } catch (BadRequestException e) {

      } finally {
        Assert.assertEquals(count, MessageBodyParameterInjector.bodyCount());
        Assert.assertEquals(count + 1, ResteasyProviderFactory.getContextDataLevelCount());
      }
      return ResteasyProviderFactory.getContextDataLevelCount();
    }
 @DELETE
 @Path("/forward/basic")
 public void deleteForwardBasic(@Context InternalDispatcher dispatcher) {
   uriStack.push(uriInfo.getAbsolutePath().toString());
   dispatcher.delete("/basic");
 }