Search in sources :

Example 1 with Application

use of org.restlet.Application in project GeoGig by boundlessgeo.

the class Main method startServer.

static void startServer(String repo) throws Exception {
    GeoGIG geogig = loadGeoGIG(repo);
    org.restlet.Context context = new org.restlet.Context();
    Application application = new Main(geogig);
    application.setContext(context);
    Component comp = new Component();
    comp.getDefaultHost().attach(application);
    comp.getServers().add(Protocol.HTTP, 8182);
    comp.start();
}
Also used : Context(org.locationtech.geogig.api.Context) Component(org.restlet.Component) Application(org.restlet.Application) GeoGIG(org.locationtech.geogig.api.GeoGIG)

Example 2 with Application

use of org.restlet.Application in project pinot by linkedin.

the class StarTreeJsonNode method startServer.

private void startServer(final File segmentDirectory, final String json) throws Exception {
    Component component = new Component();
    int port = 8090;
    component.getServers().add(Protocol.HTTP, port);
    component.getClients().add(Protocol.FILE);
    Application application = new Application() {

        @Override
        public Restlet createInboundRoot() {
            Router router = new Router(getContext());
            StarTreeViewRestResource.json = json;
            router.attach("/data", StarTreeViewRestResource.class);
            Directory directory = new Directory(getContext(), getClass().getClassLoader().getResource("star-tree.html").toString());
            router.attach(directory);
            return router;
        }
    };
    VirtualHost defaultHost = component.getDefaultHost();
    defaultHost.attach(application);
    component.start();
    LOGGER.info("Go to http://{}:{}/  to view the star tree", VirtualHost.getLocalHostName(), port);
}
Also used : Router(org.restlet.routing.Router) VirtualHost(org.restlet.routing.VirtualHost) Component(org.restlet.Component) Application(org.restlet.Application) Directory(org.restlet.resource.Directory)

Example 3 with Application

use of org.restlet.Application in project GeoGig by boundlessgeo.

the class Serve method runInternal.

@Override
protected void runInternal(GeogigCLI cli) throws InvalidParameterException, CommandFailedException, IOException {
    String loc = repo != null && repo.size() > 0 ? repo.get(0) : ".";
    GeoGIG geogig = loadGeoGIG(loc, cli);
    Application application = new Main(geogig);
    Component comp = new Component();
    comp.getDefaultHost().attach(application);
    comp.getServers().add(Protocol.HTTP, port);
    cli.getConsole().println(String.format("Starting server on port %d, use CTRL+C to exit.", port));
    try {
        comp.start();
        cli.setExitOnFinish(false);
    } catch (BindException e) {
        String msg = String.format("Port %d already in use, use the --port parameter to specify a different port", port);
        throw new CommandFailedException(msg, e);
    } catch (Exception e) {
        throw new CommandFailedException("Unable to start server", e);
    }
}
Also used : BindException(java.net.BindException) Component(org.restlet.Component) Application(org.restlet.Application) Main(org.locationtech.geogig.web.Main) GeoGIG(org.locationtech.geogig.api.GeoGIG) CommandFailedException(org.locationtech.geogig.cli.CommandFailedException) IOException(java.io.IOException) BindException(java.net.BindException) InvalidParameterException(org.locationtech.geogig.cli.InvalidParameterException) CommandFailedException(org.locationtech.geogig.cli.CommandFailedException)

Aggregations

Application (org.restlet.Application)3 Component (org.restlet.Component)3 GeoGIG (org.locationtech.geogig.api.GeoGIG)2 IOException (java.io.IOException)1 BindException (java.net.BindException)1 Context (org.locationtech.geogig.api.Context)1 CommandFailedException (org.locationtech.geogig.cli.CommandFailedException)1 InvalidParameterException (org.locationtech.geogig.cli.InvalidParameterException)1 Main (org.locationtech.geogig.web.Main)1 Directory (org.restlet.resource.Directory)1 Router (org.restlet.routing.Router)1 VirtualHost (org.restlet.routing.VirtualHost)1