org.restlet.routing.Router Java Examples
The following examples show how to use
org.restlet.routing.Router.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdminApplication.java From scava with Eclipse Public License 2.0 | 7 votes |
@Override public Restlet createInboundRoot() { Router router = new Router(getContext()); Directory directory = new Directory(getContext(), ROOT_URI); router.attach("/", AdminIndex.class); router.attach("/status/{what}", Status.class); router.attach("/projects/{view}", Projects.class); router.attach("/performance/projects", ProjectListAnalysis.class); router.attach("/performance/metrics", MetricListAnalysis.class); router.attach("/performance/projects/{projectId}/m/{metricId}", ProjectMetricAnalysis.class); router.attach("/performance/metrics/{metricId}", FullMetricAnalysis.class); //router.attach("/logger", LoggingInformation.class); router.attach("/home", directory); return router; }
Example #2
Source File: WorkspaceApplicationTest.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Test public void should_attach_inbound_route_to_application() throws Exception { final Router inboundRoot = (Router) workspaceApplication.createInboundRoot(); assertThat(inboundRoot).isNotNull(); assertThat(inboundRoot.getRoutes()).hasSize(3); final TemplateRoute route1 = (TemplateRoute) inboundRoot.getRoutes().get(0); assertThat(route1.getTemplate().getPattern()).isEqualTo("/workspace/{filePath}/{action}"); assertThat(((Finder) route1.getNext()).getTargetClass()).isEqualTo(WorkspaceServerResource.class); final TemplateRoute route2 = (TemplateRoute) inboundRoot.getRoutes().get(1); assertThat(route2.getTemplate().getPattern()).isEqualTo("/workspace/{action}"); assertThat(((Finder) route2.getNext()).getTargetClass()).isEqualTo(WorkspaceServerResource.class); final TemplateRoute route3 = (TemplateRoute) inboundRoot.getRoutes().get(2); assertThat(route3.getTemplate().getPattern()).isEqualTo("/workspace/status/"); assertThat(((Finder) route3.getNext()).getTargetClass()).isEqualTo(APIStatus.class); }
Example #3
Source File: ManagerRestApplication.java From uReplicator with Apache License 2.0 | 6 votes |
@Override public Restlet createInboundRoot() { final Router router = new Router(getContext()); router.setDefaultMatchingMode(Template.MODE_EQUALS); // Topic Servlet router.attach("/topics", TopicManagementRestletResource.class); router.attach("/topics/", TopicManagementRestletResource.class); router.attach("/topics/{topicName}", TopicManagementRestletResource.class); router.attach("/topics/{topicName}/", TopicManagementRestletResource.class); // Admin Servlet router.attach("/admin", AdminRestletResource.class); router.attach("/admin/{opt}", AdminRestletResource.class); // Health Check Servlet router.attach("/health", HealthCheckRestletResource.class); router.attach("/health/", HealthCheckRestletResource.class); return router; }
Example #4
Source File: MapServer.java From open-rmbt with Apache License 2.0 | 6 votes |
@Override public Restlet createInboundRoot() { final Router router = new Router(getContext()); router.attach("/version", VersionResource.class); final PointTiles pointTiles = new PointTiles(); router.attach("/tiles/points/{zoom}/{x}/{y}.png", pointTiles); router.attach("/tiles/points", pointTiles); final HeatmapTiles heatmapTiles = new HeatmapTiles(); router.attach("/tiles/heatmap/{zoom}/{x}/{y}.png", heatmapTiles); router.attach("/tiles/heatmap", heatmapTiles); final ShapeTiles shapeTiles = new ShapeTiles(); router.attach("/tiles/shapes/{zoom}/{x}/{y}.png", shapeTiles); router.attach("/tiles/shapes", shapeTiles); router.attach("/tiles/markers", MarkerResource.class); router.attach("/tiles/info", InfoResource.class); router.attach("/v2/tiles/info", at.alladin.rmbt.mapServer.v2.InfoResource.class); return router; }
Example #5
Source File: RestApiServer.java From floodlight_with_topoguard with Apache License 2.0 | 6 votes |
@Override public Restlet createInboundRoot() { Router baseRouter = new Router(context); baseRouter.setDefaultMatchingMode(Template.MODE_STARTS_WITH); for (RestletRoutable rr : restlets) { baseRouter.attach(rr.basePath(), rr.getRestlet(context)); } Filter slashFilter = new Filter() { @Override protected int beforeHandle(Request request, Response response) { Reference ref = request.getResourceRef(); String originalPath = ref.getPath(); if (originalPath.contains("//")) { String newPath = originalPath.replaceAll("/+", "/"); ref.setPath(newPath); } return Filter.CONTINUE; } }; slashFilter.setNext(baseRouter); return slashFilter; }
Example #6
Source File: RestManager.java From lucene-solr with Apache License 2.0 | 6 votes |
/** * Attach managed resource paths to the given Restlet Router. * @param router - Restlet Router */ public synchronized void attachManagedResources(String routerPath, Router router) { if (SCHEMA_BASE_PATH.equals(routerPath)) { this.schemaRouter = router; } else { throw new SolrException(ErrorCode.SERVER_ERROR, routerPath+" not supported by the RestManager"); } int numAttached = 0; for (Map.Entry<String, ManagedResource> entry : managed.entrySet()) { String resourceId = entry.getKey(); if (resourceId.startsWith(routerPath)) { // the way restlet works is you attach a path w/o the routerPath String path = resourceId.substring(routerPath.length()); attachManagedResource(entry.getValue(), path, router); ++numAttached; } } log.info("Attached {} ManagedResource endpoints to Restlet router: {}", numAttached, routerPath); }
Example #7
Source File: ApiRestletApplication.java From geowave with Apache License 2.0 | 6 votes |
@Override public synchronized Restlet createInboundRoot() { // Create a router Restlet and map all the resources final Router router = new Router(getContext()); // set context attributes that resources may need access to here getContext().getAttributes().put("availableRoutes", availableRoutes); getContext().getAttributes().put("asyncOperationPool", asyncOperationPool); getContext().getAttributes().put("asyncOperationStatuses", asyncOperationStatuses); // actual mapping here router.attachDefault(MainResource.class); router.attach("/api", SwaggerResource.class); router.attach("/v0/fileupload", FileUploadResource.class); router.attach("/v0/operation_status", AsyncOperationStatusResource.class); attachApiRoutes(router); return router; }
Example #8
Source File: CoreWebRoutable.java From floodlight_with_topoguard with Apache License 2.0 | 6 votes |
@Override public Restlet getRestlet(Context context) { Router router = new Router(context); router.attach("/module/all/json", ModuleLoaderResource.class); router.attach("/module/loaded/json", LoadedModuleLoaderResource.class); router.attach("/switch/{switchId}/role/json", SwitchRoleResource.class); router.attach("/switch/all/{statType}/json", AllSwitchStatisticsResource.class); router.attach("/switch/{switchId}/{statType}/json", SwitchStatisticsResource.class); router.attach("/controller/switches/json", ControllerSwitchesResource.class); router.attach("/counter/{counterTitle}/json", CounterResource.class); router.attach("/counter/{switchId}/{counterName}/json", SwitchCounterResource.class); router.attach("/counter/categories/{switchId}/{counterName}/{layer}/json", SwitchCounterCategoriesResource.class); router.attach("/memory/json", ControllerMemoryResource.class); router.attach("/packettrace/json", PacketTraceResource.class); router.attach("/storage/tables/json", StorageSourceTablesResource.class); router.attach("/controller/summary/json", ControllerSummaryResource.class); router.attach("/role/json", ControllerRoleResource.class); router.attach("/health/json", HealthCheckResource.class); router.attach("/system/uptime/json", SystemUptimeResource.class); return router; }
Example #9
Source File: OntopiaRestApplication.java From ontopia with Apache License 2.0 | 6 votes |
@Override public Restlet createInboundRoot() { // encoding service that allows disabling setEncoderService(new OntopiaEncoderService()); Router versions = new Router(getContext()); versions.setDefaultMatchingMode(Template.MODE_STARTS_WITH); versions.setRoutingMode(Router.MODE_BEST_MATCH); versions.setName("Ontopia API root router"); versions.attach("/", APIInfoResource.class); for (APIVersions version : APIVersions.values()) { if (isEnabled(version)) { logger.info("Exposing API {}", version.getName()); versions.attach("/" + version.getName(), new OntopiaAPIVersionFilter(getContext(), version.createChain(this), version)); } } return versions; }
Example #10
Source File: TopologyWebRoutable.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
/** * Create the Restlet router and bind to the proper resources. */ @Override public Router getRestlet(Context context) { Router router = new Router(context); router.attach("/links/json", LinksResource.class); router.attach("/directed-links/json", DirectedLinksResource.class); router.attach("/external-links/json", ExternalLinksResource.class); router.attach("/tunnellinks/json", TunnelLinksResource.class); router.attach("/switchclusters/json", SwitchClustersResource.class); router.attach("/broadcastdomainports/json", BroadcastDomainPortsResource.class); router.attach("/enabledports/json", EnabledPortsResource.class); router.attach("/blockedports/json", BlockedPortsResource.class); router.attach("/route/{src-dpid}/{src-port}/{dst-dpid}/{dst-port}/json", RouteResource.class); return router; }
Example #11
Source File: CarApplication.java From microservices-comparison with Apache License 2.0 | 5 votes |
@Override public Restlet createInboundRoot() { Router router = newRouter(); router.attach("/cars", CarsResource.class); router.attach("/cars/{id}", CarResource.class); return router; }
Example #12
Source File: FirewallWebRoutable.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
/** * Create the Restlet router and bind to the proper resources. */ @Override public Router getRestlet(Context context) { Router router = new Router(context); router.attach("/module/{op}/json", FirewallResource.class); router.attach("/rules/json", FirewallRulesResource.class); return router; }
Example #13
Source File: RestApplication.java From attic-polygene-java with Apache License 2.0 | 5 votes |
/** * Creates a root Restlet that will receive all incoming calls. */ @Override public synchronized Restlet createInboundRoot() { Router router = new Router( getContext() ); router.attach( "/entity", newFinder( EntitiesResource.class ) ); router.attach( "/entity/{reference}", newFinder( EntityResource.class ) ); router.attach( "/query", newFinder( SPARQLResource.class ) ); router.attach( "/query/sparqlhtml", newFinder( SPARQLResource.class ) ); router.attach( "/query/index", newFinder( IndexResource.class ) ); return router; }
Example #14
Source File: PolygeneRestApplication.java From attic-polygene-java with Apache License 2.0 | 5 votes |
@Override public Restlet createInboundRoot() { Context context = getContext(); Engine.getInstance().getRegisteredConverters().add( new PolygeneConverter( objectFactory ) ); if( polygeneApplication.mode() == Application.Mode.development ) { setDebugging( true ); } router = new Router( context ); addRoutes( router ); router.attach( basePath, newPolygeneRestlet( EntryPointResource.class, EntryPoint.class ) ); Verifier verifier = createVerifier(); Enroler enroler = createEnroler(); if( verifier == null && enroler == null ) { return createInterceptors(new Filter() { } ); } else { ChallengeAuthenticator guard = new ChallengeAuthenticator( context, ChallengeScheme.HTTP_BASIC, getName() + " Realm" ); if( verifier != null ) { guard.setVerifier( verifier ); } if( enroler != null ) { guard.setEnroler( enroler ); } return createInterceptors( guard ); } }
Example #15
Source File: APIInfoResource.java From ontopia with Apache License 2.0 | 5 votes |
private void describe(StringBuilder b, Restlet restlet, String path) { if (restlet instanceof Router) { describeRoutes(b, (Router) restlet, path); } else if (restlet instanceof Finder) { Finder f = (Finder) restlet; b.append(path).append(" = ").append(ClassUtils.collapsedName(f.getTargetClass())).append("\n"); } else if (restlet instanceof Filter) { describe(b, ((Filter)restlet).getNext(), path); } }
Example #16
Source File: APIInfoResource.java From ontopia with Apache License 2.0 | 5 votes |
private void list(Map<Restlet, String> all, Restlet restlet, String path) { all.put(restlet, path); if (restlet instanceof Router) { for (Route r : ((Router)restlet).getRoutes()) { list(all, r, path + ((TemplateRoute)r).getTemplate().getPattern()); } } else if (restlet instanceof Filter) { list(all, ((Filter) restlet).getNext(), path); } }
Example #17
Source File: FoxbpmRestApplication.java From FoxBPM with Apache License 2.0 | 5 votes |
public Restlet createInboundRoot() { initializeAuthentication(); Router router = new Router(getContext()); RestServicesInit.attachResources(router); authenticator.setNext(router); return authenticator; }
Example #18
Source File: TraceRestApplication.java From activiti-in-action-codes with Apache License 2.0 | 5 votes |
/** * Creates a root Restlet that will receive all incoming calls. */ @Override public synchronized Restlet createInboundRoot() { Router router = new Router(getContext()); DiagramServicesInit.attachResources(router); JsonpFilter jsonpFilter = new JsonpFilter(getContext()); jsonpFilter.setNext(router); return jsonpFilter; }
Example #19
Source File: FlowSpaceFirewallWebRoutable.java From FlowSpaceFirewall with Apache License 2.0 | 5 votes |
@Override public Restlet getRestlet(Context context) { Router router = new Router(context); router.attach("/admin/reloadConfig/json",FlowSpaceFirewallResource.class); router.attach("/admin/set_state/{slice}/{dpid}/{status}/json", FlowSpaceFirewallSetState.class); router.attach("/status/{slice}/{dpid}/json",SlicerStatusResource.class); router.attach("/flows/{slice}/{dpid}/json", SlicerFlowResource.class); router.attach("/admin/switches/json",FlowSpaceFirewallSwitches.class); router.attach("/admin/slices/json", FlowSpaceFirewallSlices.class); return router; }
Example #20
Source File: RestletApplication.java From AGDISTIS with GNU Affero General Public License v3.0 | 5 votes |
/** * Creates a root Restlet that will receive all incoming calls. */ @Override public Restlet createInboundRoot() { // Create a router Restlet that routes each call to a // new instance of GetDisambiguation. final Router router = new Router(getContext()); // Defines only one route router.attachDefault(GetDisambiguation.class); //System.gc(); return router; }
Example #21
Source File: RestletApplication.java From open-rmbt with Apache License 2.0 | 5 votes |
@Override public Restlet createInboundRoot() { Router router = new Router(getContext()); router.attach("/", StatusResource.class); router.attach("/info/{type}", InfoResource.class); router.attach("/info/", InfoResource.class); router.attachDefault(ErrorHandlerResource.class); return router; }
Example #22
Source File: WorkspaceApplication.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Override public Restlet createInboundRoot() { final Router router = new Router(getContext()); router.attach( "/workspace/{filePath}/{action}", WorkspaceServerResource.class); router.attach("/workspace/{action}", WorkspaceServerResource.class); router.attach("/workspace/status/", APIStatus.class); return router; }
Example #23
Source File: ActRestApplication.java From Shop-for-JavaWeb with MIT License | 5 votes |
/** * Creates a root Restlet that will receive all incoming calls. */ @Override public synchronized Restlet createInboundRoot() { Router router = new Router(getContext()); router.attachDefault(DefaultResource.class); ModelerServicesInit.attachResources(router); DiagramServicesInit.attachResources(router); JsonpFilter jsonpFilter = new JsonpFilter(getContext()); jsonpFilter.setNext(router); return jsonpFilter; }
Example #24
Source File: PerfWebRoutable.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
@Override public Restlet getRestlet(Context context) { Router router = new Router(context); router.attach("/data/json", PerfMonDataResource.class); router.attach("/{perfmonstate}/json", PerfMonToggleResource.class); // enable, disable, or reset return router; }
Example #25
Source File: DeviceRoutable.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
@Override public Restlet getRestlet(Context context) { Router router = new Router(context); router.attach("/", DeviceResource.class); router.attach("/debug", DeviceEntityResource.class); return router; }
Example #26
Source File: DebugEventRoutable.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
@Override public Restlet getRestlet(Context context) { Router router = new Router(context); router.attach("/{param1}/{param2}/", DebugEventResource.class); router.attach("/{param1}/{param2}", DebugEventResource.class); router.attach("/{param1}/", DebugEventResource.class); router.attach("/{param1}", DebugEventResource.class); router.attach("/", DebugEventResource.class); return router; }
Example #27
Source File: RestManager.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Attaches a ManagedResource and optionally a path for child resources * to the given Restlet Router. */ protected void attachManagedResource(ManagedResource res, String path, Router router) { router.attach(path, res.getServerResourceClass()); log.info("Attached managed resource at path: {}",path); // Determine if we should also route requests for child resources // ManagedResource.ChildResourceSupport is a marker interface that // indicates the ManagedResource also manages child resources at // a path one level down from the main resourceId if (ManagedResource.ChildResourceSupport.class.isAssignableFrom(res.getClass())) { router.attach(path+"/{child}", res.getServerResourceClass()); } }
Example #28
Source File: RestletApplication.java From uReplicator with Apache License 2.0 | 5 votes |
@Override public Restlet createInboundRoot() { final Router router = new Router(getContext()); router.setDefaultMatchingMode(Template.MODE_EQUALS); // Servlet router.attach("/ratelimiter", RateLimiterResource.class); return router; }
Example #29
Source File: VirtualNetworkWebRoutable.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
@Override public Restlet getRestlet(Context context) { Router router = new Router(context); router.attach("/tenants/{tenant}/networks", NetworkResource.class); // GET router.attach("/tenants/{tenant}/networks/{network}", NetworkResource.class); // PUT, DELETE router.attach("/tenants/{tenant}/networks", NetworkResource.class); // POST router.attach("/tenants/{tenant}/networks/{network}/ports/{port}/attachment", HostResource.class); router.attachDefault(NoOp.class); return router; }
Example #30
Source File: LinkDiscoveryWebRoutable.java From floodlight_with_topoguard with Apache License 2.0 | 5 votes |
/** * Create the Restlet router and bind to the proper resources. */ @Override public Router getRestlet(Context context) { Router router = new Router(context); router.attach("/autoportfast/{state}/json", AutoPortFast.class); // enable/true or disable/false return router; }