org.restlet.Restlet Java Examples

The following examples show how to use org.restlet.Restlet. 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 vote down vote up
@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: CoreWebRoutable.java    From floodlight_with_topoguard with Apache License 2.0 6 votes vote down vote up
@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 #3
Source File: RestApiServer.java    From floodlight_with_topoguard with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: PolygeneRestApplication.java    From attic-polygene-java with Apache License 2.0 6 votes vote down vote up
private Restlet createInterceptors( Filter guard )
{
    Filter inner = createInnerInterceptor();
    if( inner != null )
    {
        inner.setNext( router );
        guard.setNext( inner );             // guard -> interceptor -> router
    }
    else
    {
        guard.setNext( router );            // guard -> router
    }
    inner = guard;                      // inner = guard

    Filter outer = createOuterInterceptor();
    if( outer != null )
    {
        outer.setNext( inner );             // outer -> inner
        return outer;
    }
    return inner;
}
 
Example #5
Source File: APIInfoResource.java    From ontopia with Apache License 2.0 6 votes vote down vote up
@Get
public Representation getAPIInfo() throws IOException {
	TemplateRepresentation r = new TemplateRepresentation("net/ontopia/topicmaps/rest/resources/info.html", MediaType.TEXT_HTML);
	r.getEngine().addProperty(VelocityEngine.RESOURCE_LOADER, "classpath");
	r.getEngine().addProperty("classpath." + VelocityEngine.RESOURCE_LOADER + ".class", ClasspathResourceLoader.class.getName());
	
	Map<Restlet, String> allRoutes = new HashMap<>();
	list(allRoutes, getApplication().getInboundRoot(), "");
	Map<String, Object> data = new HashMap<>();
	data.put("util", this);
	data.put("root", getApplication().getInboundRoot());
	data.put("routes", allRoutes);
	data.put("cutil", ClassUtils.class);
	
	r.setDataModel(data);

	return r;
}
 
Example #6
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 #7
Source File: ApiRestletApplication.java    From geowave with Apache License 2.0 6 votes vote down vote up
@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: ManagerRestApplication.java    From uReplicator with Apache License 2.0 6 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);

  // 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 #9
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 #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: TraceRestApplication.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #12
Source File: FoxbpmRestApplication.java    From FoxBPM with Apache License 2.0 5 votes vote down vote up
public Restlet createInboundRoot() {
	initializeAuthentication();
	Router router = new Router(getContext());
	RestServicesInit.attachResources(router);
	authenticator.setNext(router);
	return authenticator;
}
 
Example #13
Source File: RestletApplication.java    From AGDISTIS with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 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 #14
Source File: APIInfoResource.java    From ontopia with Apache License 2.0 5 votes vote down vote up
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 #15
Source File: APIInfoResource.java    From ontopia with Apache License 2.0 5 votes vote down vote up
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: 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 #17
Source File: PolygeneRestApplication.java    From attic-polygene-java with Apache License 2.0 5 votes vote down vote up
private <K extends HasIdentity, T extends ServerResource<K>> Restlet newPolygeneRestlet( Class<T> resourceClass, Class<K> entityClass )
{

    @SuppressWarnings( "unchecked" )
    ResourceFactory<K, T> factory = objectFactory.newObject( DefaultResourceFactoryImpl.class,
                                                             resourceClass, router
                                                           );
    PolygeneConverter converter = new PolygeneConverter( objectFactory );
    return objectFactory.newObject( PolygeneEntityRestlet.class,
                                    factory,
                                    router,
                                    entityClass,
                                    converter
                                  );
}
 
Example #18
Source File: PolygeneRestApplication.java    From attic-polygene-java with Apache License 2.0 5 votes vote down vote up
@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 #19
Source File: RestApplication.java    From attic-polygene-java with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #20
Source File: RestComponent.java    From microservices-comparison with Apache License 2.0 5 votes vote down vote up
private Restlet secure(Application app, Verifier verifier, String realm) {
    ChallengeAuthenticator guard = new ChallengeAuthenticator(getContext().createChildContext(),
            ChallengeScheme.HTTP_OAUTH_BEARER, realm);
    guard.setVerifier(verifier);
    guard.setNext(app);
    return guard;
}
 
Example #21
Source File: CarApplication.java    From microservices-comparison with Apache License 2.0 5 votes vote down vote up
@Override
public Restlet createInboundRoot() {
    Router router = newRouter();
    router.attach("/cars", CarsResource.class);
    router.attach("/cars/{id}", CarResource.class);
    return router;
}
 
Example #22
Source File: WorkspaceApplication.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@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: 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 #24
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 #25
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 #26
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 #27
Source File: VirtualNetworkWebRoutable.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("/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 #28
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 #29
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 #30
Source File: ActRestApplication.java    From Shop-for-JavaWeb with MIT License 5 votes vote down vote up
/**
 * 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;
}