/** * unwraps the restlet passed to dispatched() to find the actual target. */ Restlet unwrap(Restlet next) { if (next instanceof Route) { next = ((Route)next).getNext(); } if (next instanceof BeanDelegatingRestlet) { next = ((BeanDelegatingRestlet) next).getBean(); } return next; }
@Override public void dispatched(Request request, Response response, Restlet restlet) { Method m = request.getMethod(); if (restlet instanceof Route) { restlet = ((Route) restlet).getNext(); } if (restlet instanceof BeanDelegatingRestlet) { restlet = ((BeanDelegatingRestlet) restlet).getBean(); } if (restlet != null) { // these are the restlets we have to lock if (restlet.getClass().getPackage().getName().startsWith("org.geoserver.catalog.rest")) { // choose a lok type based on the method LockType type; if ((m == Method.DELETE || m == Method.COPY || m == Method.MKCOL || m == Method.MOVE || m == Method.PROPPATCH || m == Method.POST || m == Method.PUT)) { type = LockType.WRITE; } else { type = LockType.READ; } THREAD_LOCK.set(type); locker.lock(type); } } }
/** * 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 target * The target Restlet to detach. */ public void detach(Restlet target) { getRoutes().removeAll(target); if ((getDefaultRoute() != null) && (getDefaultRoute().getNext() == target)) { setDefaultRoute(null); } }
.getPattern()); log("[Noelios Restlet Engine] - Attaching restlet: " + defaultRoute.getNext() + " to URI: " + offsetPath .getRoutes()) { log("[Noelios Restlet Engine] - Attaching restlet: " + route.getNext() + " to URI: " + offsetPath .getPattern()); log("[Noelios Restlet Engine] - Attaching restlet: " + defaultRoute.getNext() + " to URI: " + offsetPath + route.getNext() + " to URI: " + offsetPath