private void createServer(final Map<String, String> sslProperties) { jetty = new Server(); // create the unsecure connector createConnector(); // create the secure connector if sslProperties are specified if (sslProperties != null) { createSecureConnector(sslProperties); } jetty.setHandler(new HandlerCollection(true)); }
@Override protected void startUp() throws Exception { LOGGER.info("Starting the admin web server"); this.server = new Server(new InetSocketAddress(this.serverUri.getHost(), this.serverUri.getPort())); HandlerCollection handlerCollection = new HandlerCollection(); handlerCollection.addHandler(buildSettingsHandler()); handlerCollection.addHandler(buildStaticResourceHandler()); this.server.setHandler(handlerCollection); this.server.start(); }
private void setUpRequestLogging(final Path stateDirectory) { // Set up request logging final Handler originalHandler = server.getHandler(); final HandlerCollection handlerCollection; if (originalHandler instanceof HandlerCollection) { handlerCollection = (HandlerCollection) originalHandler; } else { handlerCollection = new HandlerCollection(); handlerCollection.addHandler(originalHandler); } final RequestLogHandler requestLogHandler = new RequestLogHandler(); final RequestLogImpl requestLog = new RequestLogImpl(); requestLog.setQuiet(true); if (stateDirectory.resolve(LOGBACK_ACCESS_CONFIG).toFile().exists()) { requestLog.setFileName(stateDirectory.resolve(LOGBACK_ACCESS_CONFIG).toString()); } else if (this.getClass().getResource(LOGBACK_ACCESS_RESOURCE) != null) { requestLog.setResource(LOGBACK_ACCESS_RESOURCE); } requestLogHandler.setRequestLog(requestLog); handlerCollection.addHandler(requestLogHandler); server.setHandler(handlerCollection); }
contexts.addHandler(requestLogHandler); final HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers(new Handler[] { contexts }); server.setHandler(handlers);
Server server = new Server(); // Note: if you don't want control over type of connector, etc. you can simply // call new Server(<port>); ServerConnector connector = new ServerConnector(server); connector.setHost("0.0.0.0"); connector.setPort(8085); // Setting the name allows you to serve different app contexts from different connectors. connector.setName("main"); server.addConnector(connector); WebAppContext context = new WebAppContext(); context.setContextPath("/"); // For development within an IDE like Eclipse, you can directly point to the web.xml context.setWar("src/main/webapp"); context.addFilter(MyFilter.class, "/", 1); HandlerCollection collection = new HandlerCollection(); RequestLogHandler rlh = new RequestLogHandler(); // Slf4j - who uses anything else? Slf4jRequestLog requestLog = new Slf4jRequestLog(); requestLog.setExtended(false); rlh.setRequestLog(requestLog); collection.setHandlers(new Handler[] { context, rlh }); server.setHandler(collection); try { server.start(); server.join(); } catch (Exception e) { // Google guava way throw Throwables.propagate(e); }
contexts.addHandler(requestLogHandler); final HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers(new Handler[] { contexts }); server.setHandler(handlers);
componentUiExtensions = new UiExtensionMapping(extensionUiInfo.getComponentUiExtensionsByType()); final HandlerCollection webAppContextHandlers = new HandlerCollection(); final Collection<WebAppContext> extensionUiContexts = extensionUiInfo.getWebAppContexts(); extensionUiContexts.stream().forEach(c -> webAppContextHandlers.addHandler(c));
private HttpServer2(final Builder b) throws IOException { final String appDir = getWebAppsPath(b.name); this.webServer = new Server(); this.adminsAcl = b.adminsAcl; this.handlers = new HandlerCollection(); this.webAppContext = createWebAppContext(b, adminsAcl, appDir); this.xFrameOptionIsEnabled = b.xFrameEnabled; this.xFrameOption = b.xFrameOption; try { this.secretProvider = constructSecretProvider(b, webAppContext.getServletContext()); this.webAppContext.getServletContext().setAttribute (AuthenticationFilter.SIGNER_SECRET_PROVIDER_ATTRIBUTE, secretProvider); } catch(IOException e) { throw e; } catch (Exception e) { throw new IOException(e); } this.findPort = b.findPort; this.portRanges = b.portRanges; initializeWebServer(b.name, b.hostName, b.conf, b.pathSpecs); }
Server server = new Server(conf.net_http_port); HandlerCollection handlers = new HandlerCollection(); NCSARequestLog requestLog = new NCSARequestLog(); requestLog.setFilename(conf.log_dir + "/http-request-yyyy_mm_dd.log");
HandlerCollection handlerCollection = new HandlerCollection();
@Override public void configure() throws Exception { server.addEventListener(mbeans()); server.addConnector(plainConnector()); server.addConnector(sslConnector()); ContextHandlerCollection handlers = new ContextHandlerCollection(); deploymentManager.setContexts(handlers); createWebAppContext(); JettyCustomErrorPageHandler errorHandler = new JettyCustomErrorPageHandler(); webAppContext.setErrorHandler(errorHandler); webAppContext.setGzipHandler(gzipHandler()); server.addBean(errorHandler); server.addBean(deploymentManager); HandlerCollection serverLevelHandlers = new HandlerCollection(); serverLevelHandlers.setHandlers(new Handler[]{handlers}); server.setHandler(serverLevelHandlers); performCustomConfiguration(); server.setStopAtShutdown(true); }
httpServer.setHandler(new HandlerCollection(true)); ServerConnector connector = null;
HandlerCollection collection = new HandlerCollection(); adminServer.setHandler(collection); collection.setHandlers(new Handler[] { contexts, new DefaultHandler() });
public static void main(String[] args) throws Exception { WebAppMain.standAloneMode = true; Logo.print(true); initializeLogDir(); final ConfigureAdaptor conf = ConfigureManager.getConfigure(); connectScouterCollector(); final Server server = new Server(conf.getNetHttpPort()); HandlerCollection handlers = new HandlerCollection(); RequestLogHandler requestLogHandler = setRequestLogHandler(); handlers.addHandler(requestLogHandler); ServletContextHandler servletContextHandler = setWebAppContext(); if (conf.isNetHttpApiGzipEnabled()) { GzipHandler gzipHandler = new GzipHandler(); gzipHandler.setIncludedMethods("GET", "POST", "PUT", "DELETE"); gzipHandler.setMinGzipSize(1024); gzipHandler.setHandler(servletContextHandler); handlers.addHandler(gzipHandler); } else { handlers.addHandler(servletContextHandler); } server.setHandler(handlers); setWebSocketServer(servletContextHandler); try { server.start(); waitOnExit(server); } catch (Exception e) { e.printStackTrace(); } }
private HandlerCollection createHandlers() { final WebAppContext webApp = new WebAppContext(); webApp.setContextPath(contextPath); webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false"); webApp.getSessionHandler().setMaxInactiveInterval(sessionTimeout * 60); // GZIP handler final GzipHandler gzipHandler = new GzipHandler(); gzipHandler.addIncludedMimeTypes("text/html", "text/xml", "text/css", "text/plain", "text/javascript", "application/javascript", "application/json", "application/xml"); gzipHandler.setIncludedMethods("GET", "POST"); gzipHandler.setCompressionLevel(9); gzipHandler.setHandler(webApp); if (Strings.isNullOrEmpty(webAppLocation)) { webApp.setWar(getShadedWarUrl()); } else { webApp.setWar(webAppLocation); } // Request log handler final RequestLogHandler log = new RequestLogHandler(); log.setRequestLog(createRequestLog()); // Redirect root context handler MovedContextHandler rootRedirect = new MovedContextHandler(); rootRedirect.setContextPath("/"); rootRedirect.setNewContextURL(contextPath); rootRedirect.setPermanent(true); // Put rootRedirect at the end! return new HandlerCollection(log, gzipHandler, rootRedirect); }
public void createServer(int maxThreads) { // Setup Thread pool QueuedThreadPool threadPool = new QueuedThreadPool(); threadPool.setMaxThreads(maxThreads); server = new Server(threadPool); handlers = new HandlerCollection(); server.setHandler(handlers); }
private void createServer(final Map<String, String> sslProperties) { jetty = new Server(); // create the unsecure connector createConnector(); // create the secure connector if sslProperties are specified if (sslProperties != null) { createSecureConnector(sslProperties); } jetty.setHandler(new HandlerCollection(true)); }
private void startServer() throws Exception { server = new Server(8080); HandlerCollection handlers = new HandlerCollection(); server.setHandler(handlers); handlers.addHandler(createContext("/", "a.company.com")); handlers.addHandler(createContext("/", "b.company.com")); server.start(); }
protected HandlerCollection createHandlers(WebAppContext webAppContext) { HandlerList contexts = new HandlerList(); contexts.setHandlers(new Handler[]{webAppContext}); HandlerCollection result = new HandlerCollection(); result.setHandlers(new Handler[]{contexts}); return result; }
protected HandlerCollection createHandlers(WebAppContext webAppContext) { HandlerList contexts = new HandlerList(); contexts.setHandlers(new Handler[]{webAppContext}); HandlerCollection result = new HandlerCollection(); result.setHandlers(new Handler[]{contexts}); return result; }