use of org.eclipse.jetty.server.handler.ResourceHandler in project tycho by eclipse.
the class ProxySupportTest method startHttpServer.
private void startHttpServer() throws Exception {
httpServer = new Server();
Connector connector = new SocketConnector();
httpServerPort = findFreePort();
connector.setPort(httpServerPort);
httpServer.addConnector(connector);
ContextHandler context = new ContextHandler(httpServer, "/test");
context.setResourceBase(new File(baseDir, "repo").getAbsolutePath());
context.setHandler(new ResourceHandler());
httpServer.setHandler(context);
httpServer.start();
}
use of org.eclipse.jetty.server.handler.ResourceHandler in project incubator-gobblin by apache.
the class AdminWebServer method buildStaticResourceHandler.
private ResourceHandler buildStaticResourceHandler() {
ResourceHandler staticResourceHandler = new ResourceHandler();
staticResourceHandler.setDirectoriesListed(true);
staticResourceHandler.setWelcomeFiles(new String[] { "index.html" });
String staticDir = getClass().getClassLoader().getResource("static").toExternalForm();
staticResourceHandler.setResourceBase(staticDir);
return staticResourceHandler;
}
use of org.eclipse.jetty.server.handler.ResourceHandler in project Universal-G-Code-Sender by winder.
the class PendantUI method start.
/**
* Launches the local web server.
*
* @return the url for the pendant interface
*/
public List<PendantURLBean> start() {
server = new Server(port);
ResourceHandler staticResourceHandler = new ResourceHandler();
staticResourceHandler.setDirectoriesListed(true);
staticResourceHandler.setWelcomeFiles(new String[] { "index.html" });
staticResourceHandler.setBaseResource(getBaseResource("/resources/ugs-pendant"));
ContextHandler staticResourceHandlerContext = new ContextHandler();
staticResourceHandlerContext.setContextPath("/");
staticResourceHandlerContext.setHandler(staticResourceHandler);
// Create a servlet servletContextHandler
ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
servletContextHandler.setContextPath("/api");
ServletHolder servletHolder = servletContextHandler.addServlet(ServletContainer.class, "/*");
servletHolder.setInitOrder(1);
servletHolder.setInitParameter("javax.ws.rs.Application", AppConfig.class.getCanonicalName());
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { servletContextHandler, staticResourceHandlerContext, new DefaultHandler() });
server.setHandler(handlers);
try {
server.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
return getUrlList();
}
Aggregations