Java Code Examples for org.restlet.routing.Router#attach()

The following examples show how to use org.restlet.routing.Router#attach() . 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: MapServer.java    From open-rmbt with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: OntopiaRestApplication.java    From ontopia with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: DeviceRoutable.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
@Override
public Restlet getRestlet(Context context) {
    Router router = new Router(context);
    router.attach("/", DeviceResource.class);
    router.attach("/debug", DeviceEntityResource.class);
    return router;
}
 
Example 4
Source File: RestletApplication.java    From open-rmbt with Apache License 2.0 5 votes vote down vote up
@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 5
Source File: DebugCounterRoutable.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
@Override
public Restlet getRestlet(Context context) {
    Router router = new Router(context);
    router.attach("/{param1}/{param2}/{param3}/{param4}/", DebugCounterResource.class);
    router.attach("/{param1}/{param2}/{param3}/{param4}", DebugCounterResource.class);
    router.attach("/{param1}/{param2}/{param3}/", DebugCounterResource.class);
    router.attach("/{param1}/{param2}/{param3}", DebugCounterResource.class);
    router.attach("/{param1}/{param2}/", DebugCounterResource.class);
    router.attach("/{param1}/{param2}", DebugCounterResource.class);
    router.attach("/{param1}/", DebugCounterResource.class);
    router.attach("/{param1}", DebugCounterResource.class);
    router.attach("/", DebugCounterResource.class);
    router.attach("", DebugCounterResource.class);
    return router;
}
 
Example 6
Source File: StaticFlowEntryWebRoutable.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
/**
 * Create the Restlet router and bind to the proper resources.
 */
@Override
public Restlet getRestlet(Context context) {
    Router router = new Router(context);
    router.attach("/json", StaticFlowEntryPusherResource.class);
    router.attach("/json/store", StaticFlowEntryPusherResource.class);
    router.attach("/json/delete", StaticFlowEntryDeleteResource.class);
    router.attach("/clear/{switch}/json", ClearStaticFlowEntriesResource.class);
    router.attach("/list/{switch}/json", ListStaticFlowEntriesResource.class);
    return router;
}
 
Example 7
Source File: StaticWebRoutable.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
@Override
public Restlet getRestlet(Context context) {
       Router router = new Router(context);
       router.attach("", new Directory(context, "clap://classloader/web/"));
       context.setClientDispatcher(new Client(context, Protocol.CLAP));
       return router;
}
 
Example 8
Source File: LoadBalancerWebRoutable.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
@Override
public Restlet getRestlet(Context context) {
    Router router = new Router(context);
    router.attach("/vips/", VipsResource.class); // GET, POST
    router.attach("/vips/{vip}", VipsResource.class); // GET, PUT, DELETE 
    router.attach("/pools/", PoolsResource.class); // GET, POST
    router.attach("/pools/{pool}", PoolsResource.class); // GET, PUT, DELETE
    router.attach("/members/", MembersResource.class); // GET, POST
    router.attach("/members/{member}", MembersResource.class); // GET, PUT, DELETE
    router.attach("/pools/{pool}/members", PoolMemberResource.class); //GET
    router.attach("/health_monitors/", MonitorsResource.class); //GET, POST
    router.attach("/health_monitors/{monitor}", MonitorsResource.class); //GET, PUT, DELETE        
    router.attachDefault(NoOp.class);
    return router;
 }
 
Example 9
Source File: LinkDiscoveryWebRoutable.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 10
Source File: FlowSpaceFirewallWebRoutable.java    From FlowSpaceFirewall with Apache License 2.0 5 votes vote down vote up
@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 11
Source File: DebugEventRoutable.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
@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 12
Source File: PerfWebRoutable.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
@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 13
Source File: RestManager.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
/**
 * 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 14
Source File: RestletApplication.java    From uReplicator with Apache License 2.0 5 votes vote down vote up
@Override
public Restlet createInboundRoot() {
  final Router router = new Router(getContext());
  router.setDefaultMatchingMode(Template.MODE_EQUALS);

  // Servlet
  router.attach("/ratelimiter", RateLimiterResource.class);

  return router;
}
 
Example 15
Source File: Api.java    From vicinity-gateway-api with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a root RESTLET that will receive all incoming calls.
 */
@Override
public synchronized Restlet createInboundRoot() {
	
	
	// create a router Restlet that routes each call to a new instance of 
	Router router = new Router(getContext());

	// define routes
	
	// AUTHENTICATION
	router.attach("/objects/login", ObjectsLogin.class);
	router.attach("/objects/logout", ObjectsLogout.class);
	
	
	// CONSUMPTION
	router.attach("/objects/{oid}/properties", ObjectsOidProperties.class);
	router.attach("/objects/{oid}/properties/{pid}", ObjectsOidPropertiesPid.class);
	router.attach("/objects/{oid}/actions", ObjectsOidActions.class);
	router.attach("/objects/{oid}/actions/{aid}", ObjectsOidActionsAid.class);
	router.attach("/objects/{oid}/actions/{aid}/tasks/{tid}", ObjectsOidActionsAidTasksTid.class);
	
	
	// EXPOSING
	router.attach("/objects/{oid}/events", ObjectsOidEvents.class);
	router.attach("/objects/{oid}/events/{eid}", ObjectsOidEventsEid.class);
	router.attach("/events/{eid}", EventsEid.class);
	
	
	// DISCOVERY
	router.attach("/objects", Objects.class);
	router.attach("/objects/{oid}", ObjectsOid.class);
	//get
	router.attach("/agents/{agid}/objects", AgentsAgidObjects.class);
	
	
	// REGISTRY
	// post, put
	router.attach("/agents/{agid}/objects", AgentsAgidObjects.class);
	// put
	router.attach("/agents/{agid}/objects/update", AgentsAgidObjectsUpdate.class);
	// post
	router.attach("/agents/{agid}/objects/delete", AgentsAgidObjectsDelete.class);
	
	
	// SEARCH
	// sparql query (VCNT)
	router.attach("/search/sparql", SearchSparql.class);
	// semantic query (SHQ)
	router.attach("/search/semantic", SearchSemantic.class);
	
	// solve the question of API authentication
	if (useAuthentication){
		// create authenticator
		ChallengeAuthenticator authenticator = createAuthenticator();
		
		// enable authentication
		authenticator.setNext(router);
		return authenticator;
	} 
	
	return router;
}
 
Example 16
Source File: HelloApplication.java    From microservices-comparison with Apache License 2.0 4 votes vote down vote up
@Override
public Restlet createInboundRoot() {
    Router router = newRouter();
    router.attach("/hello", HelloResource.class);
    return router;
}
 
Example 17
Source File: ControllerRestApplication.java    From uReplicator with Apache License 2.0 4 votes vote down vote up
@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);

  // Health Check Servlet
  router.attach("/health", HealthCheckRestletResource.class);
  router.attach("/health/", HealthCheckRestletResource.class);

  // Validation Servlet
  router.attach("/validation", ValidationRestletResource.class);
  router.attach("/validation/", ValidationRestletResource.class);
  router.attach("/validation/{option}", ValidationRestletResource.class);
  router.attach("/validation/{option}/", ValidationRestletResource.class);

  // Admin Servlet
  router.attach("/admin", AdminRestletResource.class);
  router.attach("/admin/{opt}", AdminRestletResource.class);

  // MirrorMakerManager Servlet
  router.attach("/instances", MirrorMakerManagerRestletResource.class);
  router.attach("/instances/", MirrorMakerManagerRestletResource.class);
  router.attach("/instances/{instanceName}", MirrorMakerManagerRestletResource.class);
  router.attach("/instances/{instanceName}/", MirrorMakerManagerRestletResource.class);

  router.attach("/offset", TopicParitionOffsetRestletResource.class);
  router.attach("/offset/", TopicParitionOffsetRestletResource.class);
  router.attach("/offset/{topic}/{partition}", TopicParitionOffsetRestletResource.class);
  router.attach("/offset/{topic}/{partition}/", TopicParitionOffsetRestletResource.class);
  router.attach("/noprogress", NoProgressTopicPartitionRestletResource.class);

  // TopicPartition Blacklist Servlet
  router.attach("/blacklist", TopicPartitionBlacklistRestletResource.class);

  return router;
}
 
Example 18
Source File: ApiApplication.java    From scava with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Restlet createInboundRoot() {
	Router router = new Router(getContext());

	router.attach("/", PingResource.class);	
	router.attach("/search", SearchProjectResource.class);
	router.attach("/search/", SearchProjectResource.class);
	router.attach("/metrics", MetricListResource.class);
	router.attach("/metrics/", MetricListResource.class);
	router.attach("/factoids", FactoidListResource.class);
	router.attach("/factoids/", FactoidListResource.class);
	router.attach("/projects", ProjectListResource.class);
	router.attach("/projects/", ProjectListResource.class);
	router.attach("/analysis/task/create", AnalysisCreationTaskResource.class);
	router.attach("/analysis/task/update", AnalysisUpdateTaskResource.class);
	router.attach("/analysis/task/start", AnalysisStartTaskResource.class);
	router.attach("/analysis/task/stop", AnalysisStopTaskResource.class);
	router.attach("/analysis/task/reset", AnalysisResetTaskResource.class);
	router.attach("/analysis/task/promote", AnalysisPromoteTaskResource.class);
	router.attach("/analysis/task/demote", AnalysisDemoteTaskResource.class);
	router.attach("/analysis/task/pushOnWorker", AnalysisTaskPushOnWorkerResource.class);
	router.attach("/analysis/task/delete", AnalysisDeleteTaskResource.class);
	router.attach("/analysis/tasks/project/{projectid}", AnalysisTasksByProjectResource.class);
	router.attach("/analysis/tasks/status/project/{projectid}", AnalysisTasksStatusByProjectResource.class);
	router.attach("/analysis/task", AnalysisTaskByAnalysisTaskResource.class);
	router.attach("/analysis/tasks", AnalysisTasksResource.class);
	router.attach("/analysis/metricproviders", AnalysisMetricProvidersResource.class);
	router.attach("/analysis/workers", AnalysisWorkerResource.class);
	router.attach("/analysis/stacktraces", AnalysisStackTracesResource.class);
	router.attach("/platform/properties/create", PlatformCreationPropertiesResource.class);
	router.attach("/platform/properties/update", PlatformUpdatePropertiesResource.class);
	router.attach("/platform/properties/delete/{key}", PlatformDeletePropertiesResource.class);
	router.attach("/platform/properties/{key}", PlatformPropertiesByKeyResource.class);
	router.attach("/platform/properties", PlatformListPropertiesResource.class);
	router.attach("/projects/import", ProjectImportResource.class);
	router.attach("/projects/create", ProjectCreationResource.class);
	router.attach("/projects/edit", ProjectEditionResource.class);
	router.attach("/projects/delete/{projectid}", ProjectDeleteResource.class);
	router.attach("/projects/p/{projectid}", ProjectResource.class);
	router.attach("/projects/p/{projectid}/", ProjectResource.class);
	router.attach("/projects/p/{projectid}/m/{metricid}", MetricVisualisationResource.class);
	router.attach("/projects/p/{projectid}/m/{metricid}/", MetricVisualisationResource.class);
	router.attach("/metrics/p/{projectid}", MetricVisualisationListByProjectResource.class);
	router.attach("/projects/p/{projectid}/f", FactoidResource.class);
	router.attach("/projects/p/{projectid}/f/", FactoidResource.class);
	router.attach("/projects/p/{projectid}/f/{factoidid}", FactoidResource.class);
	router.attach("/projects/p/{projectid}/f/{factoidid}/", FactoidResource.class);
	router.attach("/projects/p/{projectid}/s/{metricid}", SparkResource.class);
	router.attach("/projects/p/{projectid}/s/{metricid}/", SparkResource.class);
	router.attach("/spark/{sparkid}", SparkImageResource.class);
	
	router.attach("/raw/metrics", RawMetricListResource.class);
	router.attach("/raw/metrics/", RawMetricListResource.class);
	router.attach("/raw/metrics/p/{projectid}", RawMetricListByProjectResource.class);
	router.attach("/raw/projects", ProjectListResource.class);
	router.attach("/raw/projects/", ProjectListResource.class);
	router.attach("/raw/projects/{page}", ProjectListResource.class);
	router.attach("/raw/projects/{page}/", ProjectListResource.class);
	router.attach("/raw/projects/p/{projectid}", ProjectResource.class);
	router.attach("/raw/projects/p/{projectid}/", ProjectResource.class);
	router.attach("/raw/projects/p/{projectid}/m/{metricid}", RawMetricResource.class);
	router.attach("/raw/projects/p/{projectid}/m/{metricid}/", RawMetricResource.class);
	
	return router;
}
 
Example 19
Source File: RestServicesInit.java    From FoxBPM with Apache License 2.0 4 votes vote down vote up
public static void attachResources(Router router) {
	
	//设计器测试是否网络连通
	router.attach("/testConnection", TestConnectionResource.class);
	router.attach("/clearCache",ClearCacheResource.class);
	
	router.attach("/model/deployments", DeploymentCollectionResource.class);
	router.attach("/model/deployments/{deploymentId}", DeploymentResource.class);
	router.attach("/model/deployments/{deploymentId}/resources/{resourceName}", ResourceResource.class);
	
	router.attach("/model/process-definitions", ProcessDefinitionCollectionResouce.class);
	router.attach("/model/process-definitions/{processDefinitionId}", ProcessDefinitionResouce.class);
	router.attach("/model/process-definitions/{processDefinitionKey}/{version}", ProcessDefinitionResouce.class);
	router.attach("/model/process-definitions/{processDefinitionKey}/{version}/taskCommands", ProcessDefinitionResouce.class);
	
	router.attach("/runtime/tasks", TaskCollectionResource.class);
	router.attach("/runtime/tasks/{taskId}", TaskCollectionResource.class);
	router.attach("/runtime/tasks/{taskId}/identityLinks", TaskCollectionResource.class);
	router.attach("/runtime/tasks/{taskId}/taskCommands", TaskCommandCollectionResource.class);
	router.attach("/runtime/tasks/{taskId}/operations", TaskOperationCollectionResource.class);
	router.attach("/runtime/tasks/{taskId}/rollbackTasks", RollbackTaskCollectionResource.class);
	router.attach("/runtime/tasks/{taskId}/rollbackNodes", RollbackNodeCollectionResource.class);

	router.attach("/runtime/process-instances", ProcessInstanceCollectionResource.class);
	router.attach("/runtime/process-instances/{processInstanceId}", ProcessInstanceResource.class);
    router.attach("/runtime/process-instances/{processInstanceId}/variables", TaskCollectionResource.class);
    router.attach("/runtime/process-instances/{processInstanceId}/variables/{variableKey}", TaskCollectionResource.class);
    
    router.attach("/runtime/tokens", TaskCollectionResource.class);
	
    router.attach("/identity/groups/{groupType}", TaskCollectionResource.class);
    router.attach("/identity/groups/{groupType}/{groupId}", TaskCollectionResource.class);
    router.attach("/identity/groups/{groupType}/{groupId}/members", TaskCollectionResource.class);
	router.attach("/identity/users", UserCollectionResource.class);
    router.attach("/identity/users/{userId}", UserResource.class);
    router.attach("/identity/users/{userId}/picture", UserPictureResource.class);
    
    router.attach("/attachments", TaskCollectionResource.class);
    router.attach("/attachments/{attachmentId}", TaskCollectionResource.class);
    
	router.attach("/designer/flowconfig", FlowConfigResouce.class);
	router.attach("/designer/identity/allGroups", GroupCollectionResouce.class);
	router.attach("/designer/identity/allRelations", GroupRelationCollectionResouce.class);
	router.attach("/designer/identity/allUsers", UserCollectionResouce.class);
	router.attach("/designer/identity/allGroupDefinitions", GroupDefinitionCollection.class);
	
	/***********************************详细页面*******************************************************/
	//type all,endData,notEnd
	router.attach("/task/taskInfor", TaskInforResource.class);
	router.attach("/task/runTrack", TaskRunTrackResource.class);
	router.attach("/flowGraphic/position",FlowGraphicPositionResource.class);
	router.attach("/flowGraphic/flowImg", FlowGraphicImgResource.class);
	router.attach("/flowGraphic/flowSvg", FlowGraphicSvgResource.class);
	
}
 
Example 20
Source File: StuffApplication.java    From spring-5-examples with MIT License 4 votes vote down vote up
@Override
public synchronized void start() throws Exception {
  Router router = new Router(getContext());


  Properties props = new Properties();
  props.load(getClass().getResourceAsStream("/velocity.properties"));

  VelocityEngine velocity = new VelocityEngine(props);

  Function<String, Function<Identifier, ? extends Entity>> entityFactory =
      type -> identifier ->
      {
        switch (type) {
          case "task":
            return new Task(identifier);

          case "project":
            return new Project(identifier);
        }

        throw new IllegalArgumentException(type);
      };

  eventStore = new InMemoryEventStore();
  Repository repository = new InMemoryRepository(eventStore, eventStore, entityFactory);

  graphDb = new GraphDatabaseFactory().newEmbeddedDatabase("graphdb");

  InboxModel inboxModel = new Neo4jInboxModel(graphDb);
  eventStore.addInteractionContextSink(inboxModel);

  ObjectMapper mapper = new ObjectMapper();
  mapper.registerModule(new SimpleModule("EventSourcing", new Version(1, 0, 0, null, "eventsourcing", "eventsourcing")).
      addSerializer(InteractionContext.class, new InteractionContextSerializer()).
      addDeserializer(InteractionContext.class, new InteractionContextDeserializer()).setMixInAnnotation(Event.class, JacksonEvent.class)
  );

  File file = new File("events.log").getAbsoluteFile();
  LoggerFactory.getLogger(getClass()).info("Event log:" + file);
  storage = new FileEventStorage(mapper);

  if (file.exists())
    storage.load(file, eventStore);

  storage.save(file, eventStore);

  eventStore.addInteractionContextSink(new LoggingModel(mapper));

  InboxResource inboxResource = new InboxResource(velocity, repository,
      new TaskResource(velocity, repository, inboxModel), inboxModel);
  router.attach("inbox/{task}/{command}", inboxResource);
  router.attach("inbox/{task}/", inboxResource);
  router.attach("inbox/{command}", inboxResource);
  router.attach("inbox/", inboxResource);

  Reference staticContent = new Reference(new File(getClass().getResource("/htdocs/index.html").getFile()).getParentFile().toURI());
  router.attachDefault(new Directory(getContext(), staticContent)).setMatchingMode(Template.MODE_STARTS_WITH);

  setInboundRoot(router);

  super.start();
}