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();
}
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);
}
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);
}
}
Aggregations