private static void collectForRoute(CollectInfo collectInfo, String basePath, Route route, ChallengeScheme scheme, List<? extends IntrospectionHelper> introspectionHelper) { if (route instanceof TemplateRoute) { TemplateRoute templateRoute = (TemplateRoute) route; String path = templateRoute.getTemplate().getPattern(); collect(collectInfo, basePath + path, route.getNext(), scheme, introspectionHelper); } else { LOGGER.fine("Route type ignored. Class " + route.getClass()); } }
private static void collectForRoute(CollectInfo collectInfo, String basePath, Route route, ChallengeScheme scheme, List<? extends IntrospectionHelper> introspectionHelper) { if (route instanceof TemplateRoute) { TemplateRoute templateRoute = (TemplateRoute) route; String path = templateRoute.getTemplate().getPattern(); collect(collectInfo, basePath + path, route.getNext(), scheme, introspectionHelper); } else { LOGGER.fine("Route type ignored. Class " + route.getClass()); } }
private static void collectForRoute(CollectInfo collectInfo, String basePath, Route route, ChallengeScheme scheme, List<? extends IntrospectionHelper> introspectionHelper) { if (route instanceof TemplateRoute) { TemplateRoute templateRoute = (TemplateRoute) route; String path = templateRoute.getTemplate().getPattern(); collect(collectInfo, basePath + path, route.getNext(), scheme, introspectionHelper); } else { LOGGER.fine("Route type ignored. Class " + route.getClass()); } }
private static void collectForRoute(CollectInfo collectInfo, String basePath, Route route, ChallengeScheme scheme, List<? extends IntrospectionHelper> introspectionHelper) { if (route instanceof TemplateRoute) { TemplateRoute templateRoute = (TemplateRoute) route; String path = templateRoute.getTemplate().getPattern(); collect(collectInfo, basePath + path, route.getNext(), scheme, introspectionHelper); } else { LOGGER.fine("Route type ignored. Class " + route.getClass()); } }
private static void collectForRoute(CollectInfo collectInfo, String basePath, Route route, ChallengeScheme scheme, List<? extends IntrospectionHelper> introspectionHelper) { if (route instanceof TemplateRoute) { TemplateRoute templateRoute = (TemplateRoute) route; String path = templateRoute.getTemplate().getPattern(); collect(collectInfo, basePath + path, route.getNext(), scheme, introspectionHelper); } else { LOGGER.fine("Route type ignored. Class " + route.getClass()); } }
private void describeRoutes(StringBuilder b, Router router, String path) { RouteList routes = router.getRoutes(); b.append("[").append(path).append("] = Router: ").append(router.getName()).append(": ").append(router.getDescription()).append("\n"); for (Route r : routes) { if (r instanceof TemplateRoute) { describe(b, r.getNext(), path + ((TemplateRoute)r).getTemplate().getPattern()); } } }
/** * Returns the WADL data about the given Route instance. * * @param applicationInfo * The parent application. * @param route * The Route instance to document. * @param basePath * The base path. * @param request * The current request. * @param response * The current response. * @return The WADL data about the given Route instance. */ private ResourceInfo getResourceInfo(ApplicationInfo applicationInfo, Route route, String basePath, Request request, Response response) { ResourceInfo result = null; if (route instanceof TemplateRoute) { TemplateRoute templateRoute = (TemplateRoute) route; String path = templateRoute.getTemplate().getPattern(); // WADL requires resource paths to be relative to parent path if (path.startsWith("/") && basePath.endsWith("/")) { path = path.substring(1); } result = getResourceInfo(applicationInfo, route.getNext(), path, request, response); } return result; }
/** * Removes all routes routing to a given target. * * @param target * The target Restlet to detach. */ public synchronized void removeAll(Restlet target) { for (int i = size() - 1; i >= 0; i--) { if (get(i).getNext() == target) { remove(i); } } }
/** * Detaches the target from this router. All routes routing to this target * Restlet are removed from the list of routes and the default route is set * to null. * * @param targetClass * The target class to detach. */ public void detach(Class<?> targetClass) { for (int i = getRoutes().size() - 1; i >= 0; i--) { Restlet target = getRoutes().get(i).getNext(); if (target != null && Finder.class.isAssignableFrom(target.getClass())) { Finder finder = (Finder) target; if (finder.getTargetClass().equals(targetClass)) { getRoutes().remove(i); } } } if (getDefaultRoute() != null) { Restlet target = getDefaultRoute().getNext(); if (target != null && Finder.class.isAssignableFrom(target.getClass())) { Finder finder = (Finder) target; if (finder.getTargetClass().equals(targetClass)) { setDefaultRoute(null); } } } }
/** * Detaches the target from this router. All routes routing to this target * Restlet are removed from the list of routes and the default route is set * to null. * * @param target * The target Restlet to detach. */ public void detach(Restlet target) { getRoutes().removeAll(target); if ((getDefaultRoute() != null) && (getDefaultRoute().getNext() == target)) { setDefaultRoute(null); } }
/** * Returns the next application available. * * @param current * The current Restlet to inspect. * @return The first application available. */ private static Application getNextApplication(Restlet current) { Application result = null; if (current instanceof Application) { result = (Application) current; } else if (current instanceof Filter) { result = getNextApplication(((Filter) current).getNext()); } else if (current instanceof Router) { Router router = (Router) current; for (Route route : router.getRoutes()) { result = getNextApplication(route.getNext()); if (result != null) { break; } } } return result; }
/** * Returns the next application available. * * @param current * The current Restlet to inspect. * @return The first application available. */ private static Application getNextApplication(Restlet current) { Application result = null; if (current instanceof Application) { result = (Application) current; } else if (current instanceof Filter) { result = getNextApplication(((Filter) current).getNext()); } else if (current instanceof Router) { Router router = (Router) current; for (Route route : router.getRoutes()) { result = getNextApplication(route.getNext()); if (result != null) { break; } } } return result; }
/** * Returns the next application available. * * @param current * The current Restlet to inspect. * @return The first application available. */ private static Application getNextApplication(Restlet current) { Application result = null; if (current instanceof Application) { result = (Application) current; } else if (current instanceof Filter) { result = getNextApplication(((Filter) current).getNext()); } else if (current instanceof Router) { Router router = (Router) current; for (Route route : router.getRoutes()) { result = getNextApplication(route.getNext()); if (result != null) { break; } } } return result; }
/** * Returns the next application available. * * @param current * The current Restlet to inspect. * @return The first application available. */ private static Application getNextApplication(Restlet current) { Application result = null; if (current instanceof Application) { result = (Application) current; } else if (current instanceof Filter) { result = getNextApplication(((Filter) current).getNext()); } else if (current instanceof Router) { Router router = (Router) current; for (Route route : router.getRoutes()) { result = getNextApplication(route.getNext()); if (result != null) { break; } } } return result; }
/** * Returns the next application available. * * @param current * The current Restlet to inspect. * @return The first application available. */ private static Application getNextApplication(Restlet current) { Application result = null; if (current instanceof Application) { result = (Application) current; } else if (current instanceof Filter) { result = getNextApplication(((Filter) current).getNext()); } else if (current instanceof Router) { Router router = (Router) current; for (Route route : router.getRoutes()) { result = getNextApplication(route.getNext()); if (result != null) { break; } } } return result; }