Ejemplo n.º 1
0
  @Override
  public void onInbound(InboundInterceptorContext context) throws Exception {
    if (context.request().requestType() == RequestType.CREATE) {
      ResourceResponse response =
          new DefaultResourceResponse(
              context.request(),
              ResourceResponse.ResponseType.CREATED,
              new Resource() {

                @Override
                public Resource parent() {
                  return null;
                }

                @Override
                public String id() {
                  return "mock";
                }
              });

      ResourceState state = new DefaultResourceState();
      state.putProperty("requestCounter", requestCounter.get());
      state.putProperty("responseCounter", responseCounter.get());
      response.setState(state);

      context.replyWith(response);
    } else {
      requestCounter.incrementAndGet();
      super.onInbound(context);
    }
  }
Ejemplo n.º 2
0
 @Override
 public void onOutbound(OutboundInterceptorContext context) throws Exception {
   responseCounter.incrementAndGet();
   super.onOutbound(context);
 }