private Server createServer(final DummyServlet servlet) throws Exception { int port; try (ServerSocket socket = new ServerSocket()) { socket.bind(new InetSocketAddress(0)); port = socket.getLocalPort(); } baseUri = new URI("http", null, "127.0.0.1", port, null, null, null); HttpConfiguration httpConfiguration = new HttpConfiguration(); httpConfiguration.setSendServerVersion(false); httpConfiguration.setSendXPoweredBy(false); server = new Server(); ServerConnector httpConnector = new ServerConnector(server, new HttpConnectionFactory(httpConfiguration)); httpConnector.setPort(port); httpConnector.setName("http"); server.addConnector(httpConnector); ServletHolder servletHolder = new ServletHolder(servlet); ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); context.addServlet(servletHolder, "/*"); HandlerCollection handlers = new HandlerCollection(); handlers.addHandler(context); server.setHandler(handlers); return server; }
protected final void doConfigure(final HttpConnectionFactory factory) { factory.getHttpConfiguration().addCustomizer(new ForwardedRequestCustomizer()); final HttpConfiguration config = factory.getHttpConfiguration(); // HTTP/1.1 requires Date header if possible config.setSendDateHeader(true); config.setSendServerVersion(this.config.sendServerHeader()); config.setSendXPoweredBy(this.config.sendServerHeader()); }
public void startServletContainer(Configuration conf) throws Exception { if (server != null) { LOG.error("ServletContainer already running"); return; } // Inject the conf for the test by being first to make singleton RESTServlet.getInstance(conf, UserProvider.instantiate(conf)); // set up the Jersey servlet container for Jetty ResourceConfig app = new ResourceConfig() .packages("org.apache.hadoop.hbase.rest") .register(Jackson1Feature.class); ServletHolder sh = new ServletHolder(new ServletContainer(app)); // set up Jetty and run the embedded server server = new Server(0); LOG.info("configured " + ServletContainer.class.getName()); HttpConfiguration httpConfig = new HttpConfiguration(); httpConfig.setSendDateHeader(false); httpConfig.setSendServerVersion(false); ServerConnector serverConnector = new ServerConnector(server, new HttpConnectionFactory(httpConfig)); serverConnector.setPort(testServletPort); server.addConnector(serverConnector); // set up context ServletContextHandler ctxHandler = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS); ctxHandler.addServlet(sh, "/*"); // Load filters specified from configuration. String[] filterClasses = conf.getStrings(Constants.FILTER_CLASSES, ArrayUtils.EMPTY_STRING_ARRAY); for (String filter : filterClasses) { filter = filter.trim(); ctxHandler.addFilter(filter, "/*", EnumSet.of(DispatcherType.REQUEST)); } LOG.info("Loaded filter classes :" + filterClasses); conf.set(RESTServer.REST_CSRF_BROWSER_USERAGENTS_REGEX_KEY, ".*"); RESTServer.addCSRFFilter(ctxHandler, conf); HttpServerUtil.constrainHttpMethods(ctxHandler); // start the server server.start(); // get the port testServletPort = ((ServerConnector) server.getConnectors()[0]).getLocalPort(); LOG.info("started " + server.getClass().getName() + " on port " + testServletPort); }
private void prepareProxy(Map<String, String> initParams) throws Exception { proxy = new Server(); HttpConfiguration configuration = new HttpConfiguration(); configuration.setSendDateHeader(false); configuration.setSendServerVersion(false); String value = initParams.get("outputBufferSize"); if (value != null) configuration.setOutputBufferSize(Integer.valueOf(value)); proxyConnector = new ServerConnector(proxy, new HttpConnectionFactory(configuration)); proxy.addConnector(proxyConnector); proxyContext = new ServletContextHandler(proxy, "/", true, false); ServletHolder proxyServletHolder = new ServletHolder(proxyServlet); proxyServletHolder.setInitParameters(initParams); proxyContext.addServlet(proxyServletHolder, "/*"); proxy.start(); client = prepareClient(); }
/** * Loads jetty configuration from the given URL. * * @param cfgUrl URL to load configuration from. * @throws GridException if load failed. */ private void loadJettyConfiguration(@Nullable URL cfgUrl) throws GridException { if (cfgUrl == null) { HttpConfiguration httpCfg = new HttpConfiguration(); httpCfg.setSecureScheme("https"); httpCfg.setSecurePort(8443); httpCfg.setSendServerVersion(true); httpCfg.setSendDateHeader(true); String srvPortStr = System.getProperty(GG_JETTY_PORT, "8080"); int srvPort; try { srvPort = Integer.valueOf(srvPortStr); } catch (NumberFormatException ignore) { throw new GridException( "Failed to start Jetty server because GRIDGAIN_JETTY_PORT system property " + "cannot be cast to integer: " + srvPortStr); } httpSrv = new Server(new QueuedThreadPool(20, 200)); ServerConnector srvConn = new ServerConnector(httpSrv, new HttpConnectionFactory(httpCfg)); srvConn.setHost(System.getProperty(GG_JETTY_HOST, "localhost")); srvConn.setPort(srvPort); srvConn.setIdleTimeout(30000L); srvConn.setReuseAddress(true); httpSrv.addConnector(srvConn); httpSrv.setStopAtShutdown(false); } else { XmlConfiguration cfg; try { cfg = new XmlConfiguration(cfgUrl); } catch (FileNotFoundException e) { throw new GridSpiException("Failed to find configuration file: " + cfgUrl, e); } catch (SAXException e) { throw new GridSpiException("Failed to parse configuration file: " + cfgUrl, e); } catch (IOException e) { throw new GridSpiException("Failed to load configuration file: " + cfgUrl, e); } catch (Exception e) { throw new GridSpiException( "Failed to start HTTP server with configuration file: " + cfgUrl, e); } try { httpSrv = (Server) cfg.configure(); } catch (Exception e) { throw new GridException("Failed to start Jetty HTTP server.", e); } } assert httpSrv != null; httpSrv.setHandler(jettyHnd); override(getJettyConnector()); }
@Override public void run() { try { // Set GAE SystemProperties setSystemProperties(); // Create the server, connector and associated instances QueuedThreadPool threadpool = new QueuedThreadPool(); server = new Server(threadpool); HttpConfiguration httpConfig = new HttpConfiguration(); ServerConnector connector = new ServerConnector(server, new HttpConnectionFactory(httpConfig)); connector.setPort(port); server.addConnector(connector); MappedByteBufferPool bufferpool = new MappedByteBufferPool(); // Basic jetty.xml handler setup HandlerCollection handlers = new HandlerCollection(); ContextHandlerCollection contexts = new ContextHandlerCollection(); // TODO is a context handler collection needed for a // single context? handlers.setHandlers(new Handler[] {contexts, new DefaultHandler()}); server.setHandler(handlers); // Configuration as done by gae.mod/gae.ini httpConfig.setOutputAggregationSize(32768); threadpool.setMinThreads(10); threadpool.setMaxThreads(500); threadpool.setIdleTimeout(60000); httpConfig.setOutputBufferSize(32768); httpConfig.setRequestHeaderSize(8192); httpConfig.setResponseHeaderSize(8192); httpConfig.setSendServerVersion(true); httpConfig.setSendDateHeader(false); httpConfig.setDelayDispatchUntilContent(false); // Setup Server as done by gae.xml server.addBean(bufferpool); httpConfig.setHeaderCacheSize(512); RequestLogHandler requestLogHandler = new RequestLogHandler(); handlers.addHandler(requestLogHandler); File logs = File.createTempFile("logs", "logs"); logs.delete(); logs.mkdirs(); NCSARequestLog requestLog = new NCSARequestLog(logs.getCanonicalPath() + "/request.yyyy_mm_dd.log"); requestLogHandler.setRequestLog(requestLog); requestLog.setRetainDays(2); requestLog.setAppend(true); requestLog.setExtended(true); requestLog.setLogTimeZone("GMT"); requestLog.setLogLatency(true); requestLog.setPreferProxiedForAddress(true); // Ugly hack to delete possible previous run lock file new File("target/log.0.lck").delete(); new File("target/log.0.1.lck").delete(); // configuration from root.xml VmRuntimeWebAppContext context = new VmRuntimeWebAppContext(); context.setContextPath("/"); // find the sibling testwebapp target File currentDir = new File("").getAbsoluteFile(); File webAppLocation = new File(currentDir, "target/webapps/testwebapp"); context.setResourceBase(webAppLocation.getAbsolutePath()); context.init("WEB-INF/appengine-web.xml"); context.setParentLoaderPriority(true); // true in tests for easier mocking // Hack to find the webdefault.xml File webDefault = new File(currentDir.getParentFile(), "docker/etc/webdefault.xml"); context.setDefaultsDescriptor(webDefault.getAbsolutePath()); contexts.addHandler(context); // start and join server.start(); } catch (Exception e) { e.printStackTrace(); } finally { started.countDown(); } try { if (Log.getLogger(Server.class).isDebugEnabled()) server.dumpStdErr(); server.join(); } catch (Exception e) { e.printStackTrace(); } }
public static void main(String[] args) throws Exception { String jetty_home = System.getProperty("jetty.home", "../../jetty-distribution/target/distribution"); System.setProperty("jetty.home", jetty_home); // Setup Threadpool QueuedThreadPool threadPool = new QueuedThreadPool(512); Server server = new Server(threadPool); server.manage(threadPool); server.setDumpAfterStart(false); server.setDumpBeforeStop(false); // Setup JMX MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer()); server.addBean(mbContainer); // Common HTTP configuration HttpConfiguration config = new HttpConfiguration(); config.setSecurePort(8443); config.addCustomizer(new ForwardedRequestCustomizer()); config.addCustomizer(new SecureRequestCustomizer()); config.setSendServerVersion(true); // Http Connector HttpConnectionFactory http = new HttpConnectionFactory(config); ServerConnector httpConnector = new ServerConnector(server, http); httpConnector.setPort(8080); httpConnector.setIdleTimeout(10000); server.addConnector(httpConnector); // SSL configurations SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setKeyStorePath(jetty_home + "/etc/keystore"); sslContextFactory.setKeyStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"); sslContextFactory.setKeyManagerPassword("OBF:1u2u1wml1z7s1z7a1wnl1u2g"); sslContextFactory.setTrustStorePath(jetty_home + "/etc/keystore"); sslContextFactory.setTrustStorePassword("OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"); sslContextFactory.setExcludeCipherSuites( "SSL_RSA_WITH_DES_CBC_SHA", "SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA", "SSL_RSA_EXPORT_WITH_RC4_40_MD5", "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"); // Spdy Connector SPDYServerConnectionFactory.checkNPNAvailable(); PushStrategy push = new ReferrerPushStrategy(); HTTPSPDYServerConnectionFactory spdy2 = new HTTPSPDYServerConnectionFactory(2, config, push); spdy2.setInputBufferSize(8192); spdy2.setInitialWindowSize(32768); HTTPSPDYServerConnectionFactory spdy3 = new HTTPSPDYServerConnectionFactory(3, config, push); spdy2.setInputBufferSize(8192); NPNServerConnectionFactory npn = new NPNServerConnectionFactory( spdy3.getProtocol(), spdy2.getProtocol(), http.getProtocol()); npn.setDefaultProtocol(http.getProtocol()); npn.setInputBufferSize(1024); SslConnectionFactory ssl = new SslConnectionFactory(sslContextFactory, npn.getProtocol()); ServerConnector spdyConnector = new ServerConnector(server, ssl, npn, spdy3, spdy2, http); spdyConnector.setPort(8443); server.addConnector(spdyConnector); // Setup handlers HandlerCollection handlers = new HandlerCollection(); ContextHandlerCollection contexts = new ContextHandlerCollection(); RequestLogHandler requestLogHandler = new RequestLogHandler(); handlers.setHandlers(new Handler[] {contexts, new DefaultHandler(), requestLogHandler}); StatisticsHandler stats = new StatisticsHandler(); stats.setHandler(handlers); server.setHandler(stats); // Setup deployers DeploymentManager deployer = new DeploymentManager(); deployer.setContexts(contexts); server.addBean(deployer); WebAppProvider webapp_provider = new WebAppProvider(); webapp_provider.setMonitoredDirName(jetty_home + "/webapps"); webapp_provider.setParentLoaderPriority(false); webapp_provider.setExtractWars(true); webapp_provider.setScanInterval(2); webapp_provider.setDefaultsDescriptor(jetty_home + "/etc/webdefault.xml"); deployer.addAppProvider(webapp_provider); HashLoginService login = new HashLoginService(); login.setName("Test Realm"); login.setConfig(jetty_home + "/etc/realm.properties"); server.addBean(login); NCSARequestLog requestLog = new AsyncNCSARequestLog(); requestLog.setFilename(jetty_home + "/logs/jetty-yyyy_mm_dd.log"); requestLog.setExtended(false); requestLogHandler.setRequestLog(requestLog); server.setStopAtShutdown(true); server.start(); server.dumpStdErr(); server.join(); }
protected AbstractConnector createConnectorJettyInternal( Server server, JettyHttpEndpoint endpoint, SslContextFactory sslcf) { try { String hosto = endpoint.getHttpUri().getHost(); int porto = endpoint.getPort(); org.eclipse.jetty.server.HttpConfiguration httpConfig = new org.eclipse.jetty.server.HttpConfiguration(); httpConfig.setSendServerVersion(endpoint.isSendServerVersion()); httpConfig.setSendDateHeader(endpoint.isSendDateHeader()); httpConfig.setSendDateHeader(endpoint.isSendDateHeader()); if (requestBufferSize != null) { // Does not work // httpConfig.setRequestBufferSize(requestBufferSize); } if (requestHeaderSize != null) { httpConfig.setRequestHeaderSize(requestHeaderSize); } if (responseBufferSize != null) { httpConfig.setOutputBufferSize(responseBufferSize); } if (responseHeaderSize != null) { httpConfig.setResponseHeaderSize(responseHeaderSize); } if (useXForwardedForHeader) { httpConfig.addCustomizer(new ForwardedRequestCustomizer()); } HttpConnectionFactory httpFactory = new org.eclipse.jetty.server.HttpConnectionFactory(httpConfig); ArrayList<ConnectionFactory> connectionFactories = new ArrayList<ConnectionFactory>(); ServerConnector result = new org.eclipse.jetty.server.ServerConnector(server); if (sslcf != null) { httpConfig.addCustomizer(new org.eclipse.jetty.server.SecureRequestCustomizer()); SslConnectionFactory scf = new org.eclipse.jetty.server.SslConnectionFactory(sslcf, "HTTP/1.1"); connectionFactories.add(scf); // The protocol name can be "SSL" or "SSL-HTTP/1.1" depending on the version of Jetty result.setDefaultProtocol(scf.getProtocol()); } connectionFactories.add(httpFactory); result.setConnectionFactories(connectionFactories); result.setPort(porto); if (hosto != null) { result.setHost(hosto); } /* if (getSocketConnectorProperties() != null && !"https".equals(endpoint.getProtocol())) { // must copy the map otherwise it will be deleted Map<String, Object> properties = new HashMap<String, Object>(getSocketConnectorProperties()); IntrospectionSupport.setProperties(httpConfig, properties); if (properties.size() > 0) { throw new IllegalArgumentException("There are " + properties.size() + " parameters that couldn't be set on the SocketConnector." + " Check the uri if the parameters are spelt correctly and that they are properties of the SelectChannelConnector." + " Unknown parameters=[" + properties + "]"); } } else*/ if (getSslSocketConnectorProperties() != null && "https".equals(endpoint.getProtocol())) { // must copy the map otherwise it will be deleted Map<String, Object> properties = new HashMap<String, Object>(getSslSocketConnectorProperties()); IntrospectionSupport.setProperties(sslcf, properties); if (properties.size() > 0) { throw new IllegalArgumentException( "There are " + properties.size() + " parameters that couldn't be set on the SocketConnector." + " Check the uri if the parameters are spelt correctly and that they are properties of the SelectChannelConnector." + " Unknown parameters=[" + properties + "]"); } } return result; } catch (Exception e) { throw ObjectHelper.wrapRuntimeCamelException(e); } }
public void start() throws Exception { // Configure Server server = new Server(); if (ssl) { // HTTP Configuration HttpConfiguration http_config = new HttpConfiguration(); http_config.setSecureScheme("https"); http_config.setSecurePort(0); http_config.setOutputBufferSize(32768); http_config.setRequestHeaderSize(8192); http_config.setResponseHeaderSize(8192); http_config.setSendServerVersion(true); http_config.setSendDateHeader(false); sslContextFactory = new SslContextFactory(); sslContextFactory.setKeyStorePath( MavenTestingUtils.getTestResourceFile("keystore").getAbsolutePath()); sslContextFactory.setKeyStorePassword("storepwd"); sslContextFactory.setKeyManagerPassword("keypwd"); sslContextFactory.setExcludeCipherSuites( "SSL_RSA_WITH_DES_CBC_SHA", "SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA", "SSL_RSA_EXPORT_WITH_RC4_40_MD5", "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA", "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"); // SSL HTTP Configuration HttpConfiguration https_config = new HttpConfiguration(http_config); https_config.addCustomizer(new SecureRequestCustomizer()); // SSL Connector connector = new ServerConnector( server, new SslConnectionFactory(sslContextFactory, "http/1.1"), new HttpConnectionFactory(https_config)); connector.setPort(0); } else { // Basic HTTP connector connector = new ServerConnector(server); connector.setPort(0); } server.addConnector(connector); ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); server.setHandler(context); // Serve capture servlet context.addServlet(new ServletHolder(servlet), "/*"); // Start Server server.start(); // Establish the Server URI String host = connector.getHost(); if (host == null) { host = "localhost"; } int port = connector.getLocalPort(); serverUri = new URI(String.format("%s://%s:%d/", ssl ? "wss" : "ws", host, port)); // Some debugging if (LOG.isDebugEnabled()) { LOG.debug(server.dump()); } }
@SuppressWarnings({"deprecation"}) public HttpServer( HttpServerInfo httpServerInfo, NodeInfo nodeInfo, HttpServerConfig config, Servlet theServlet, Map<String, String> parameters, Set<Filter> filters, Set<HttpResourceBinding> resources, Servlet theAdminServlet, Map<String, String> adminParameters, Set<Filter> adminFilters, MBeanServer mbeanServer, LoginService loginService, TraceTokenManager tokenManager, RequestStats stats, EventClient eventClient) throws IOException { Preconditions.checkNotNull(httpServerInfo, "httpServerInfo is null"); Preconditions.checkNotNull(nodeInfo, "nodeInfo is null"); Preconditions.checkNotNull(config, "config is null"); Preconditions.checkNotNull(theServlet, "theServlet is null"); QueuedThreadPool threadPool = new QueuedThreadPool(config.getMaxThreads()); threadPool.setMinThreads(config.getMinThreads()); threadPool.setIdleTimeout(Ints.checkedCast(config.getThreadMaxIdleTime().toMillis())); threadPool.setName("http-worker"); server = new Server(threadPool); if (config.isShowStackTrace()) { server.addBean(new ErrorHandler()); } if (mbeanServer != null) { // export jmx mbeans if a server was provided MBeanContainer mbeanContainer = new MBeanContainer(mbeanServer); server.addBean(mbeanContainer); } // set up HTTP connector if (config.isHttpEnabled()) { HttpConfiguration httpConfiguration = new HttpConfiguration(); httpConfiguration.setSendServerVersion(false); httpConfiguration.setSendXPoweredBy(false); if (config.getMaxRequestHeaderSize() != null) { httpConfiguration.setRequestHeaderSize( Ints.checkedCast(config.getMaxRequestHeaderSize().toBytes())); } // if https is enabled, set the CONFIDENTIAL and INTEGRAL redirection information if (config.isHttpsEnabled()) { httpConfiguration.setSecureScheme("https"); httpConfiguration.setSecurePort(httpServerInfo.getHttpsUri().getPort()); } Integer acceptors = config.getHttpAcceptorThreads(); Integer selectors = config.getHttpSelectorThreads(); httpConnector = new ServerConnector( server, null, null, null, acceptors == null ? -1 : acceptors, selectors == null ? -1 : selectors, new HttpConnectionFactory(httpConfiguration)); httpConnector.setName("http"); httpConnector.setPort(httpServerInfo.getHttpUri().getPort()); httpConnector.setIdleTimeout(config.getNetworkMaxIdleTime().toMillis()); httpConnector.setHost(nodeInfo.getBindIp().getHostAddress()); httpConnector.setAcceptQueueSize(config.getHttpAcceptQueueSize()); server.addConnector(httpConnector); } else { httpConnector = null; } // set up NIO-based HTTPS connector if (config.isHttpsEnabled()) { HttpConfiguration httpsConfiguration = new HttpConfiguration(); httpsConfiguration.setSendServerVersion(false); httpsConfiguration.setSendXPoweredBy(false); if (config.getMaxRequestHeaderSize() != null) { httpsConfiguration.setRequestHeaderSize( Ints.checkedCast(config.getMaxRequestHeaderSize().toBytes())); } httpsConfiguration.addCustomizer(new SecureRequestCustomizer()); SslContextFactory sslContextFactory = new SslContextFactory(config.getKeystorePath()); sslContextFactory.setKeyStorePassword(config.getKeystorePassword()); SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, "http/1.1"); Integer acceptors = config.getHttpsAcceptorThreads(); Integer selectors = config.getHttpsSelectorThreads(); httpsConnector = new ServerConnector( server, null, null, null, acceptors == null ? -1 : acceptors, selectors == null ? -1 : selectors, sslConnectionFactory, new HttpConnectionFactory(httpsConfiguration)); httpsConnector.setName("https"); httpsConnector.setPort(httpServerInfo.getHttpsUri().getPort()); httpsConnector.setIdleTimeout(config.getNetworkMaxIdleTime().toMillis()); httpsConnector.setHost(nodeInfo.getBindIp().getHostAddress()); httpsConnector.setAcceptQueueSize(config.getHttpAcceptQueueSize()); server.addConnector(httpsConnector); } else { httpsConnector = null; } // set up NIO-based Admin connector if (theAdminServlet != null && config.isAdminEnabled()) { HttpConfiguration adminConfiguration = new HttpConfiguration(); adminConfiguration.setSendServerVersion(false); adminConfiguration.setSendXPoweredBy(false); if (config.getMaxRequestHeaderSize() != null) { adminConfiguration.setRequestHeaderSize( Ints.checkedCast(config.getMaxRequestHeaderSize().toBytes())); } QueuedThreadPool adminThreadPool = new QueuedThreadPool(config.getAdminMaxThreads()); adminThreadPool.setName("http-admin-worker"); adminThreadPool.setMinThreads(config.getAdminMinThreads()); adminThreadPool.setIdleTimeout(Ints.checkedCast(config.getThreadMaxIdleTime().toMillis())); if (config.isHttpsEnabled()) { adminConfiguration.addCustomizer(new SecureRequestCustomizer()); SslContextFactory sslContextFactory = new SslContextFactory(config.getKeystorePath()); sslContextFactory.setKeyStorePassword(config.getKeystorePassword()); SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(sslContextFactory, "http/1.1"); adminConnector = new ServerConnector( server, adminThreadPool, null, null, 0, -1, sslConnectionFactory, new HttpConnectionFactory(adminConfiguration)); } else { adminConnector = new ServerConnector( server, adminThreadPool, null, null, 0, -1, new HttpConnectionFactory(adminConfiguration)); } adminConnector.setName("admin"); adminConnector.setPort(httpServerInfo.getAdminUri().getPort()); adminConnector.setIdleTimeout(config.getNetworkMaxIdleTime().toMillis()); adminConnector.setHost(nodeInfo.getBindIp().getHostAddress()); adminConnector.setAcceptQueueSize(config.getHttpAcceptQueueSize()); server.addConnector(adminConnector); } else { adminConnector = null; } /** * structure is: * * <p>server |--- statistics handler |--- context handler | |--- trace token filter | |--- gzip * response filter | |--- gzip request filter | |--- security handler | |--- user provided * filters | |--- the servlet (normally GuiceContainer) | |--- resource handlers |--- log * handler |-- admin context handler \ --- the admin servlet */ HandlerCollection handlers = new HandlerCollection(); for (HttpResourceBinding resource : resources) { handlers.addHandler( new ClassPathResourceHandler( resource.getBaseUri(), resource.getClassPathResourceBase(), resource.getWelcomeFiles())); } handlers.addHandler( createServletContext( theServlet, parameters, filters, tokenManager, loginService, "http", "https")); if (config.isLogEnabled()) { handlers.addHandler(createLogHandler(config, tokenManager, eventClient)); } RequestLogHandler statsRecorder = new RequestLogHandler(); statsRecorder.setRequestLog(new StatsRecordingHandler(stats)); handlers.addHandler(statsRecorder); // add handlers to Jetty StatisticsHandler statsHandler = new StatisticsHandler(); statsHandler.setHandler(handlers); HandlerList rootHandlers = new HandlerList(); if (theAdminServlet != null && config.isAdminEnabled()) { rootHandlers.addHandler( createServletContext( theAdminServlet, adminParameters, adminFilters, tokenManager, loginService, "admin")); } rootHandlers.addHandler(statsHandler); server.setHandler(rootHandlers); }