use of org.eclipse.jetty.server.handler.ResourceHandler in project Anserini by castorini.
the class TweetSearcher method main.
public static void main(String[] args) throws IOException, InterruptedException, ParseException {
Options options = new Options();
options.addOption(INDEX_OPTION, true, "index path");
options.addOption(PORT_OPTION, true, "port");
CommandLine cmdline = null;
CommandLineParser parser = new GnuParser();
try {
cmdline = parser.parse(options, args);
} catch (org.apache.commons.cli.ParseException e) {
System.err.println("Error parsing command line: " + e.getMessage());
System.exit(-1);
}
if (!cmdline.hasOption(INDEX_OPTION)) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(TweetSearcher.class.getName(), options);
System.exit(-1);
}
int port = cmdline.hasOption(PORT_OPTION) ? Integer.parseInt(cmdline.getOptionValue(PORT_OPTION)) : 8080;
TweetSearcher nrtsearch = new TweetSearcher(cmdline.getOptionValue(INDEX_OPTION));
TweetStreamIndexer its = new TweetStreamIndexer();
Thread itsThread = new Thread(its);
itsThread.start();
LOG.info("Starting HTTP server on port " + port);
HandlerList mainHandler = new HandlerList();
Server server = new Server(port);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setWelcomeFiles(new String[] { "index.html" });
resource_handler.setResourceBase("src/main/java/io/anserini/nrts/public");
ServletContextHandler handler = new ServletContextHandler(ServletContextHandler.SESSIONS);
handler.setContextPath("/");
ServletHolder jerseyServlet = new ServletHolder(ServletContainer.class);
jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", TweetSearcherAPI.class.getCanonicalName());
handler.addServlet(jerseyServlet, "/*");
mainHandler.addHandler(resource_handler);
mainHandler.addHandler(handler);
server.setHandler(mainHandler);
try {
server.start();
LOG.info("Accepting connections on port " + port);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
server.join();
itsThread.join();
nrtsearch.close();
}
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 resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(false);
resourceHandler.setWelcomeFiles(new String[] { "index.html" });
resourceHandler.setBaseResource(getBaseResource());
resourceHandler.setDirectoriesListed(true);
ContextHandler sendGcodeContext = new ContextHandler();
sendGcodeContext.setContextPath("/sendGcode");
sendGcodeContext.setBaseResource(getBaseResource());
sendGcodeContext.setClassLoader(Thread.currentThread().getContextClassLoader());
sendGcodeContext.setHandler(new SendGcodeHandler());
ContextHandler adjustManualLocationContext = new ContextHandler();
adjustManualLocationContext.setContextPath("/adjustManualLocation");
adjustManualLocationContext.setBaseResource(getBaseResource());
adjustManualLocationContext.setClassLoader(Thread.currentThread().getContextClassLoader());
adjustManualLocationContext.setHandler(new AdjustManualLocationHandler());
ContextHandler getSystemStateContext = new ContextHandler();
getSystemStateContext.setContextPath("/getSystemState");
getSystemStateContext.setBaseResource(getBaseResource());
getSystemStateContext.setClassLoader(Thread.currentThread().getContextClassLoader());
getSystemStateContext.setHandler(new GetSystemStateHandler());
ContextHandler configContext = new ContextHandler();
configContext.setContextPath("/config");
configContext.setBaseResource(getBaseResource());
configContext.setClassLoader(Thread.currentThread().getContextClassLoader());
configContext.setHandler(new ConfigHandler());
configContext.setInitParameter("cacheControl", "max-age=0, public");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { configContext, sendGcodeContext, adjustManualLocationContext, getSystemStateContext, resourceHandler, new DefaultHandler() });
server.setHandler(handlers);
try {
server.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
return getUrlList();
}
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 archiva by apache.
the class RemoteRepositoryConnectivityCheckTest method buildStaticServer.
protected Server buildStaticServer(Path path) {
Server repoServer = new Server();
ResourceHandler resourceHandler = new ResourceHandler();
resourceHandler.setDirectoriesListed(true);
resourceHandler.setWelcomeFiles(new String[] { "index.html" });
resourceHandler.setResourceBase(path.toAbsolutePath().toString());
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resourceHandler, new DefaultHandler() });
repoServer.setHandler(handlers);
return repoServer;
}
use of org.eclipse.jetty.server.handler.ResourceHandler in project selenium_java by sergueik.
the class RunScriptTest method beforeSuiteMethod.
@BeforeSuite
public void beforeSuiteMethod() throws Exception {
((StdErrLog) Log.getRootLogger()).setLevel(StdErrLog.LEVEL_OFF);
webServer = new Server(new QueuedThreadPool(5));
ServerConnector connector = new ServerConnector(webServer, new HttpConnectionFactory());
connector.setPort(8080);
webServer.addConnector(connector);
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[] { "index.html" });
resource_handler.setResourceBase("src/test/webapp");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() });
webServer.setHandler(handlers);
webServer.start();
driver = new FirefoxDriver();
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);
wait = new WebDriverWait(driver, flexibleWait);
wait.pollingEvery(pollingInterval, TimeUnit.MILLISECONDS);
hashesFinderScript = getScriptContent("hashesFinder.js");
resultFinderScript = getScriptContent("resultFinder.js");
}
Aggregations