/** * 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; }
public void addRoutes(Map m, Router r){ Iterator it = m.entrySet().iterator(); while (it.hasNext()){ Map.Entry entry = (Map.Entry) it.next(); // LOG.info("Found mapping: " + entry.getKey().toString()); Restlet restlet = (getApplicationContext().getBean(entry.getValue().toString()) instanceof Resource) ? new BeanResourceFinder(getApplicationContext(), entry.getValue().toString()) : new BeanDelegatingRestlet(getApplicationContext(), entry.getValue().toString()); String path = entry.getKey().toString(); r.attach(path, restlet); if (path.indexOf("?") == -1){ r.attach(path + "?{q}", restlet); } else LOG.fine("Query string already listed in restlet mapping: " + path); } }
public void handle(Request req, Response res){ Restlet restlet = (Restlet)getBean(); restlet.handle(req, res); }
@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); } } }