@Override
 public void service(Request request, Response response) throws Exception {
   String uri = request.getRequestURI();
   Map<HttpMethod, GrizzletHandler> handlerByMethod = handlers.get(uri);
   GrizzletHandler handler = null;
   if (handlerByMethod != null) {
     handler = handlerByMethod.get(HttpMethod.valueOf(request.getMethod().toString()));
   }
   if (handler != null) {
     handler.handle(request, response);
     SimpleGrizzlyAdapterChain.requestServiced();
   }
 }
    @Override
    public void service(final Request request, final Response response) throws Exception {

      final char[] buf = new char[128];
      final NIOReader in = request.getReader(); // put the stream in non-blocking mode
      final NIOWriter out = response.getWriter();

      response.suspend();

      // If we don't have more data to read - onAllDataRead() will be called
      in.notifyAvailable(
          new ReadHandler() {

            @Override
            public void onDataAvailable() throws Exception {
              System.out.printf("[onDataAvailable] echoing %d bytes\n", in.readyData());
              echoAvailableData(in, out, buf);
              in.notifyAvailable(this);
            }

            @Override
            public void onError(Throwable t) {
              System.out.println("[onError]" + t);
              response.resume();
            }

            @Override
            public void onAllDataRead() throws Exception {
              System.out.printf("[onAllDataRead] length: %d\n", in.readyData());
              try {
                echoAvailableData(in, out, buf);
              } finally {
                try {
                  in.close();
                } catch (IOException ignored) {
                }

                try {
                  out.close();
                } catch (IOException ignored) {
                }

                response.resume();
              }
            }
          });
    }