use of org.eclipse.jetty.server.handler.HandlerList in project graphql-java by graphql-java.
the class HttpMain method main.
public static void main(String[] args) throws Exception {
//
// This example uses Jetty as an embedded HTTP server
Server server = new Server(PORT);
//
// In Jetty, handlers are how your get called backed on a request
HttpMain main_handler = new HttpMain();
ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(false);
resource_handler.setWelcomeFiles(new String[] { "index.html" });
resource_handler.setResourceBase("./src/test/resources/httpmain");
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { resource_handler, main_handler });
server.setHandler(handlers);
server.start();
server.join();
}
use of org.eclipse.jetty.server.handler.HandlerList in project selenium_java by sergueik.
the class AngularAndWebDriverTest method before_suite.
@BeforeSuite
public void before_suite() throws Exception {
// Launch Protractor's own test app on http://localhost:8080
((StdErrLog) Log.getRootLogger()).setLevel(StdErrLog.LEVEL_OFF);
webServer = new Server(new QueuedThreadPool(6));
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();
MovedContextHandler effective_symlink = new MovedContextHandler(webServer, "/lib/angular", "/lib/angular_v1.2.9");
handlers.setHandlers(new Handler[] { effective_symlink, resource_handler, new DefaultHandler() });
webServer.setHandler(handlers);
webServer.start();
setupBrowser("chrome");
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);
ngWebDriver = new NgWebDriver(driver);
}
use of org.eclipse.jetty.server.handler.HandlerList in project yacy_grid_mcp by yacy.
the class APIServer method open.
private static void open(int port, String htmlPath) throws IOException {
try {
QueuedThreadPool pool = new QueuedThreadPool();
pool.setMaxThreads(500);
server = new Server(pool);
ServerConnector connector = new ServerConnector(server);
HttpConfiguration http_config = new HttpConfiguration();
http_config.setRequestHeaderSize(65536);
http_config.setResponseHeaderSize(65536);
connector.addConnectionFactory(new HttpConnectionFactory(http_config));
connector.setPort(port);
connector.setName("httpd:" + port);
// timout in ms when no bytes send / received
connector.setIdleTimeout(20000);
server.addConnector(connector);
server.setStopAtShutdown(true);
// add services
ServletContextHandler servletHandler = new ServletContextHandler();
for (Class<? extends Servlet> service : services) try {
servletHandler.addServlet(service, ((APIHandler) (service.getConstructor().newInstance())).getAPIPath());
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
Data.logger.warn(service.getName() + " instantiation error", e);
}
ErrorHandler errorHandler = new ErrorHandler();
errorHandler.setShowStacks(true);
servletHandler.setErrorHandler(errorHandler);
HandlerList handlerlist2 = new HandlerList();
if (htmlPath == null) {
handlerlist2.setHandlers(new Handler[] { servletHandler, new DefaultHandler() });
} else {
FileHandler fileHandler = new FileHandler();
fileHandler.setDirectoriesListed(true);
fileHandler.setWelcomeFiles(new String[] { "index.html" });
fileHandler.setResourceBase(htmlPath);
handlerlist2.setHandlers(new Handler[] { fileHandler, servletHandler, new DefaultHandler() });
}
server.setHandler(handlerlist2);
server.start();
} catch (Throwable e) {
throw new IOException(e.getMessage());
}
}
use of org.eclipse.jetty.server.handler.HandlerList in project JsonPath by json-path.
the class Main method main.
public static void main(String[] args) throws Exception {
String configPort = "8080";
if (args.length > 0) {
configPort = args[0];
}
String port = System.getProperty("server.http.port", configPort);
System.out.println("Server started on port: " + port);
Server server = new Server();
server.setConnectors(new Connector[] { createConnector(server, Integer.parseInt(port)) });
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
context.setContextPath("/api");
ServletHolder servletHolder = new ServletHolder(createJerseyServlet());
servletHolder.setInitOrder(1);
context.addServlet(servletHolder, "/*");
WebAppContext webAppContext = new WebAppContext();
webAppContext.setServer(server);
webAppContext.setContextPath("/");
String resourceBase = System.getProperty("resourceBase");
if (resourceBase != null) {
webAppContext.setResourceBase(resourceBase);
} else {
webAppContext.setResourceBase(Main.class.getResource("/webapp").toExternalForm());
}
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { context, webAppContext });
server.setHandler(handlers);
server.start();
server.join();
}
use of org.eclipse.jetty.server.handler.HandlerList in project stagen by wiztools.
the class RunnerRun method run.
@Override
public void run(final File baseDir) throws IOException, ExecutorException {
// Generate site:
clean.run(baseDir);
gen.run(baseDir);
// Start monitoring service:
startMonitoring(baseDir);
// Start server:
try {
LOG.log(Level.INFO, "Starting HTTP server at port: {0}", cmd.port);
Server server = new Server(cmd.port);
ResourceHandler rh = new ResourceHandler();
rh.setDirectoriesListed(true);
rh.setWelcomeFiles(new String[] { "index.html" });
rh.setResourceBase(Constants.getOutDir(baseDir).getPath());
HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { rh, new DefaultHandler() });
server.setHandler(handlers);
server.start();
server.join();
} catch (Exception ex) {
throw new ExecutorException(ex);
}
}
Aggregations