private Route findRoute(Request request) throws Exception {
   for (Route r : routeProvider.getRoutes()) {
     // TODO getBodyAsStream creates ByteArray each call. That could be a performance issue. Using
     // BufferedInputStream did't work, because stream got closed.
     if ((Boolean)
         newXPath(namespaces)
             .evaluate(
                 r.getxPath(), new InputSource(request.getBodyAsStream()), XPathConstants.BOOLEAN))
       return r;
     log.debug("no match found for xpath {" + r.getxPath() + "}");
   }
   return null;
 }
  @Override
  public Outcome handleRequest(Exchange exc) throws Exception {
    if (exc.getRequest().isBodyEmpty()) {
      return Outcome.CONTINUE;
    }

    Route r = findRoute(exc.getRequest());
    if (r == null) {
      return Outcome.CONTINUE;
    }
    log.debug("match found for {" + r.getxPath() + "} routing to {" + r.getUrl() + "}");

    updateDestination(exc, r);
    return Outcome.CONTINUE;
  }