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; }