Search in sources :

Example 1 with VirtualHost

use of org.restlet.routing.VirtualHost 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)

Aggregations

Application (org.restlet.Application)1 Component (org.restlet.Component)1 Directory (org.restlet.resource.Directory)1 Router (org.restlet.routing.Router)1 VirtualHost (org.restlet.routing.VirtualHost)1