Package org.restlet.routing

Examples of org.restlet.routing.Router


public class RestServerRedirector extends Application {

    @Override
    public Restlet createInboundRoot() {

        Router router = new Router(getContext());

        String restapihost = getContext().getParameters().getFirstValue("restapi.host", "localhost");
        String restapiport = getContext().getParameters().getFirstValue("restapi.port", "8111");

        String target = "http://" + restapihost + ":" + restapiport + "/v2{rr}";
        router.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
        Redirector redirector = new Redirector(getContext(), target, Redirector.MODE_SERVER_OUTBOUND);
        router.attach("/v2", redirector);
        router.attach("/", new Directory(getContext(), "war:///"));
        return router;
    }
View Full Code Here


    /**
     * Returns the root Restlet of this application.
     */
    @Override
    public Restlet createInboundRoot() {
        Router router = new Router(getContext());
        router.attach(ENVIRONMENT_PATH+"/", EnvironmentsServerResource.class);
        router.attach(ENVIRONMENT_PATH+"/{number}", EnvironmentServerResource.class);
        router.attach(ENVIRONMENT_PATH+"/{env}/zones/", ZonesServerResource.class);
        router.attach(ENVIRONMENT_PATH+"/{env}/zones/{number}", ZoneServerResource.class);
        router.attach(FREEDOMOTIC_PATH+"/objects/", ObjectsServerResource.class);
        router.attach(FREEDOMOTIC_PATH+"/objects/{name}", ObjectServerResource.class);
        router.attach(FREEDOMOTIC_PATH+"/plugins/", PluginsServerResource.class);
        router.attach(FREEDOMOTIC_PATH+"/commands/hardware/", HardwareCommandsServerResource.class);
        router.attach(FREEDOMOTIC_PATH+"/commands/user/", UserCommandsServerResource.class);
        router.attach(FREEDOMOTIC_PATH+"/triggers/", TriggersServerResource.class);
        router.attach(FREEDOMOTIC_PATH+"/resources/{filename}", ImageResourceServerResource.class);   
        router.attach(USER_PATH + "/{useraction}", UserServerResource.class);
        //Expose the resources dir as static server
        Directory dir = new Directory(getContext(), FILE_AND_SLASHES + resourcesPath);
        dir.setListingAllowed(true);
        //System.out.println("FILE_AND_SLASHES+resourcesPath "+  FILE_AND_SLASHES+resourcesPath);
        router.attach(RESOURCES_PATH + "/", dir);
        return router;
    }
View Full Code Here

public class RestServerRedirector extends Application {
 
  @Override
  public Restlet createInboundRoot(){
   
    Router router = new Router(getContext());
 
    String restapihost = getContext().getParameters().getFirstValue("restapi.host","localhost");
    String restapiport = getContext().getParameters().getFirstValue("restapi.port","8111");
       
    String target = "http://"+restapihost+":"+restapiport+"/v1{rr}";
    router.setDefaultMatchingMode(Template.MODE_STARTS_WITH);
    Redirector redirector = new Redirector(getContext(),target, Redirector.MODE_SERVER_OUTBOUND);
    router.attach("/v1", redirector);
    router.attach("/", new Directory(getContext(), "war:///"));
    return  router;
  };
View Full Code Here

    /* (non-Javadoc)
     * @see org.restlet.Application#createRoot()
     */
    @Override
    public Restlet createInboundRoot() {
        final Router router = new Router(getContext());
        // Prevent that "/path" is also matched by "/path/"
        router.setDefaultMatchingMode(Template.MODE_EQUALS);
        final String collId = "{" + COLLECTION_ID + "}";
        final String fragmentId = "{" + FRAGMENT_ID + "}";
        final String snapshotId = "{" + SNAPSHOT_ID + "}";
        router.attach("/", OverviewResource.class);
        router.attach("/" + collId + "/" , CollectionResource.class);
        router.attach("/" + collId + "/snapshots/", SnapshotsResource.class);
        router.attach("/" + collId + "/snapshots/" + snapshotId, SnapshotResource.class);
        router.attach("/" + collId + "/fragments/", FragmentsResource.class);
        router.attach("/" + collId + "/fragments/" + fragmentId, FragmentResource.class);
        return router;
    }
View Full Code Here

    }

    @Override
    public Restlet createInboundRoot() {
        // Create a root router
        Router router = new Router(getContext());

        // Attach the handlers to the root router
        router.attach("/pipelines", Pipelines.class);
        router.attach("/pipelines/{id}", Pipeline.class);
        router.attach("/pipelines/{id}/inputs/{port}", Input.class);
        router.attach("/pipelines/{id}/outputs/{port}", Output.class);
        router.attach("/pipelines/{id}/options", Options.class);
        router.attach("/pipelines/{id}/options/{option}", Option.class);
        router.attach("/pipelines/{id}/parameters", Parameters.class);
        router.attach("/pipelines/{id}/parameters/{port}", Parameters.class);
        router.attach("/pipelines/{id}/parameters/{port}/{param}", Parameter.class);
        router.attach("/pipelines/{id}/run", Run.class);
        router.attach("/pipelines/{id}/reset", Reset.class);
        router.attach("/status", Status.class);
        router.attach("/help", Help.class);
        router.attach("/stop", Stop.class);
        router.attach("/", Help.class);

        // Return the root router
        return router;
    }
View Full Code Here

   */
  @Override
  public Restlet createInboundRoot() {
    // Create a router Restlet that routes each call to a
    // new instance of HelloWorldResource.
    Router router = new Router(getContext());

    // Defines only one route
    //router.attachDefault(ManageMetric.class);
    router.attach("/metric/{metricName}", ManageMetric.class);
    router.attach("/metricgoal/{metricName}", ManageMetricGoal.class);
    router.attach("/metricvalue/{metricName}", ManageMetricValue.class);
  //  router.attach("/getmetricstream/{metricName}", MetricStream.class);

    return router;
  }
View Full Code Here

public class LoadBalancerWebRoutable implements RestletRoutable {

    @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;
     }
View Full Code Here

public class PerfWebRoutable implements RestletRoutable {

    @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;
    }
View Full Code Here

    /**
     * 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;
    }
View Full Code Here

       
    }

  @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;
  }
View Full Code Here

TOP

Related Classes of org.restlet.routing.Router

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.