public synchronized Restlet createRoot() { Router router = new Router(getContext()); router.attach("/",new Redirector(null,"/engine",Redirector.MODE_CLIENT_TEMPORARY)); router.attach("/engine",EngineResource.class) .setMatchingMode(Template.MODE_EQUALS); router.attach("/engine/",EngineResource.class) .setMatchingMode(Template.MODE_EQUALS); engine.getJobsDir().toURI().toString()); alljobsdir.setListingAllowed(true); router.attach("/engine/jobsdir",alljobsdir); anypath.setEditFilter(JobResource.EDIT_FILTER); router.attach("/engine/anypath/",anypath); jobdir.setModifiable(true); jobdir.setEditFilter(JobResource.EDIT_FILTER); router.attach("/engine/job/{job}/jobdir",jobdir); router.attach("/engine/job/{job}",JobResource.class); router.attach("/engine/job/{job}/report/{reportClass}",ReportGenResource.class); router.attach("/engine/job/{job}/beans",BeanBrowseResource.class); router.attach("/engine/job/{job}/beans/{beanPath}",BeanBrowseResource.class); router.attach("/engine/job/{job}/script",ScriptResource.class); router.attach("/engine/static/",staticDir);
/** * Attaches a target Restlet to this router with an empty URI pattern. A new * route will be added routing to the target when any call is received. * * @param target * The target Restlet to attach. * @return The created route. */ public Route attach(Restlet target) { return attach("", target); }
if (target != null) { if ((uriPattern != null) && !defaultRoute) { route = router.attach(uriPattern, target); } else { route = router.attachDefault(target);
private void addRoutes(Map<String, Object> m){ Iterator<Entry<String,Object>> it = m.entrySet().iterator(); while (it.hasNext()){ Entry<String,Object> entry = it.next(); if (entry.getValue() instanceof GWCResource){ myRouter.attach(entry.getKey().toString(), ((GWCResource) entry.getValue()).getClass()); } else if (entry.getValue() instanceof Restlet){ myRouter.attach(entry.getKey().toString(), (Restlet) entry.getValue()); } else { log.error("Unexpected " + entry.getValue()); } } } }
/** * Attaches a target Resource class to this router based on a given URI * pattern. A new route will be added routing to the target when calls with * a URI matching the pattern will be received. * * @param uriPattern * The URI pattern that must match the relative part of the * resource URI. * @param targetClass * The target Resource class to attach. * @return The created route. */ public Route attach(String uriPattern, Class<? extends Resource> targetClass) { return attach(uriPattern, createFinder(targetClass)); }
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 synchronized Restlet createRoot() { Router router = new Router(getContext()); router.attach("/",new Redirector(null,"/engine",Redirector.MODE_CLIENT_TEMPORARY)); router.attach("/engine",EngineResource.class) .setMatchingMode(Template.MODE_EQUALS); router.attach("/engine/",EngineResource.class) .setMatchingMode(Template.MODE_EQUALS); engine.getJobsDir().toURI().toString()); alljobsdir.setListingAllowed(true); router.attach("/engine/jobsdir",alljobsdir); anypath.setEditFilter(JobResource.EDIT_FILTER); router.attach("/engine/anypath/",anypath); jobdir.setModifiable(true); jobdir.setEditFilter(JobResource.EDIT_FILTER); router.attach("/engine/job/{job}/jobdir",jobdir); router.attach("/engine/job/{job}",JobResource.class); router.attach("/engine/job/{job}/report/{reportClass}",ReportGenResource.class); router.attach("/engine/job/{job}/beans",BeanBrowseResource.class); router.attach("/engine/job/{job}/beans/{beanPath}",BeanBrowseResource.class); router.attach("/engine/job/{job}/script",ScriptResource.class); router.attach("/engine/static/",staticDir);
public RESTDispatcher() { super(); setSupportedMethods(new String[] { METHOD_GET, METHOD_POST, METHOD_PUT, METHOD_DELETE, METHOD_HEAD }); int numRoutes = 0; for (RESTMapping mapping : GeoWebCacheExtensions.extensions(RESTMapping.class)) { Map<String, Object> routes = mapping.getRoutes(); addRoutes(routes); numRoutes += routes.size(); } myRouter.attach("", new IndexRestlet(myRouter)); log.info("Created RESTDispatcher with " + numRoutes + " paths"); }
/** * Attaches a target Restlet to this router with an empty URI pattern. A new * route will be added routing to the target when any call is received. * * In addition to super class behavior, this method will set the context of * the target if it is empty by creating a protected context via the * {@link Context#createChildContext()} method. * * @param target * The target Restlet to attach. * @return The created route. */ @Override public Route attach(Restlet target) { if ((target.getContext() == null) && (this.parentContext != null)) { target.setContext(this.parentContext.createChildContext()); } return super.attach(target); }
@Override public Route attach(String uriPattern, Restlet target) { if (target.getContext() == null) { target .setContext(getContext() .createChildContext()); } return super.attach(uriPattern, target); }
@Override public Route attach(Restlet target) { if (target.getContext() == null) { target .setContext(getContext() .createChildContext()); } return super.attach(target); }
/** * Attaches a target Restlet to this router based on a given URI pattern. A * new route will be added routing to the target when calls with a URI * matching the pattern will be received. * * In addition to super class behavior, this method will set the context of * the target if it is empty by creating a protected context via the * {@link Context#createChildContext()} method. * * @param uriPattern * The URI pattern that must match the relative part of the * resource URI. * @param target * The target Restlet to attach. * @return The created route. */ @Override public Route attach(String uriPattern, Restlet target) { if ((target.getContext() == null) && (this.parentContext != null)) { target.setContext(this.parentContext.createChildContext()); } return super.attach(uriPattern, target); }
myRouter.attach("", new IndexRestlet(myRouter));