private String getMetricName(Route route, Method method) { String metricName = route.getName(); if (StringUtils.isNullOrEmpty(metricName)) { metricName = MetricRegistry.name(method.getDeclaringClass(), method.getName()); } return metricName; }
private Route getCompiledRoute(String nameOrUriPattern) { for (Route route : compiledRoutes) { if (nameOrUriPattern.equals(route.getName()) || nameOrUriPattern.equals(route.getUriPattern())) { return route; } } return null; }
private void removeCompiledRoute(Route route) { String nameOrUriPattern = StringUtils.isNullOrEmpty(route.getName()) ? route.getUriPattern() : route.getName(); Route compiledRoute = getCompiledRoute(nameOrUriPattern); if (compiledRoute == null) { // do nothing; probably the route was not yet compiled return; } compiledRoutes.remove(compiledRoute); // update cache List<Route> cacheEntry = compiledRoutesCache.get(route.getRequestMethod()); if (cacheEntry != null) { cacheEntry.remove(compiledRoute); } uriMatcher.removeUriPattern(compiledRoute.getUriPattern()); }
@SuppressWarnings("unchecked") protected void handleRoute(Route route) { if (StringUtils.isNullOrEmpty(route.getName())) { log.debug("Executing handler for {} '{}'", route.getRequestMethod(), route.getUriPattern()); } else { log.debug("Executing '{}' for {} '{}'", route.getName(), route.getRequestMethod(), route.getUriPattern()); } this.route = route; route.getRouteHandler().handle(this); }
/** * Execute all routes that are flagged to run as finally. */ @Override public void runFinallyRoutes() { while (iterator.hasNext()) { Route route = iterator.next().getRoute(); if (route.isRunAsFinally()) { try { handleRoute(route); } catch (Exception e) { log.error("Unexpected error in Finally Route", e); } } else if (log.isDebugEnabled()) { if (StringUtils.isNullOrEmpty(route.getName())) { log.debug("context.next() not called, skipping handler for {} '{}'", route.getRequestMethod(), route.getUriPattern()); } else { log.debug("context.next() not called, skipping '{}' for {} '{}'", route.getName(), route.getRequestMethod(), route.getUriPattern()); } } } }
nameStack.push(route.getName()); nameStack.pushIfNotEmpty(routeGroup.getName());
private String getMetricName(Route route, Method method) { String metricName = route.getName(); if (StringUtils.isNullOrEmpty(metricName)) { metricName = MetricRegistry.name(method.getDeclaringClass(), method.getName()); } return metricName; }
maxControllerLen = Math.max(maxControllerLen, controllerLen); } else if (route.getName() != null) { maxControllerLen = Math.max(maxControllerLen, route.getName().length()); } else if (route.getName() != null) { if (oneLine) { if (logHandlers) { Strings.padEnd(route.getRequestMethod(), maxMethodLen, ' '), Strings.padEnd(route.getUriPattern(), maxPathLen, ' '), route.getName()); } else { log.info("{} {}", log.info("{} {}", Strings.padEnd("", maxMethodLen, ' '), route.getName());
maxControllerLen = Math.max(maxControllerLen, controllerLen); } else if (route.getName() != null) { maxControllerLen = Math.max(maxControllerLen, route.getName().length()); } else if (route.getName() != null) { if (oneLine) { if (logHandlers) { Strings.padEnd(route.getRequestMethod(), maxMethodLen, ' '), Strings.padEnd(route.getUriPattern(), maxPathLen, ' '), route.getName()); } else { log.info("{} {}", log.info("{} {}", Strings.padEnd("", maxMethodLen, ' '), route.getName());