Java Code Examples for org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory#setContextPath()
The following examples show how to use
org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory#setContextPath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TraderUMainConfiguration.java From java-trader with Apache License 2.0 | 5 votes |
@Bean public ConfigurableServletWebServerFactory webServerFactory() { JettyServletWebServerFactory factory = new JettyServletWebServerFactory(); int port = ConfigUtil.getInt("/BasisService/web.httpPort", 10080); factory.setPort(port); factory.setContextPath(""); factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/notfound.html")); factory.setSelectors(1); factory.setAcceptors(1); factory.setThreadPool(new ExecutorThreadPool(executorService())); return factory; }
Example 2
Source File: TraderMainConfiguration.java From java-trader with Apache License 2.0 | 5 votes |
@Bean public ConfigurableServletWebServerFactory webServerFactory() { JettyServletWebServerFactory factory = new JettyServletWebServerFactory(); int port = ConfigUtil.getInt("/BasisService/web.httpPort", 10080); factory.setPort(port); factory.setContextPath(""); factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/notfound.html")); factory.setSelectors(1); factory.setAcceptors(1); factory.setThreadPool(new ExecutorThreadPool(executorService())); return factory; }
Example 3
Source File: IntegrationTestBase.java From nifi-registry with Apache License 2.0 | 4 votes |
@Bean public JettyServletWebServerFactory jettyEmbeddedServletContainerFactory() { JettyServletWebServerFactory jettyContainerFactory = new JettyServletWebServerFactory(); jettyContainerFactory.setContextPath(CONTEXT_PATH); return jettyContainerFactory; }
Example 4
Source File: ParaServer.java From para with Apache License 2.0 | 4 votes |
/** * @return Jetty config bean */ @Bean public ServletWebServerFactory jettyConfigBean() { JettyServletWebServerFactory jef = new JettyServletWebServerFactory(); jef.addServerCustomizers((JettyServerCustomizer) (Server server) -> { if (Config.getConfigBoolean("access_log_enabled", true)) { // enable access log via Logback HandlerCollection handlers = new HandlerCollection(); for (Handler handler : server.getHandlers()) { handlers.addHandler(handler); } RequestLogHandler reqLogs = new RequestLogHandler(); reqLogs.setServer(server); RequestLogImpl rli = new RequestLogImpl(); rli.setResource("/logback-access.xml"); rli.setQuiet(true); rli.start(); reqLogs.setRequestLog(rli); handlers.addHandler(reqLogs); server.setHandler(handlers); } for (Connector y : server.getConnectors()) { for (ConnectionFactory cf : y.getConnectionFactories()) { if (cf instanceof HttpConnectionFactory) { HttpConnectionFactory dcf = (HttpConnectionFactory) cf; // support for X-Forwarded-Proto // redirect back to https if original request uses it if (Config.IN_PRODUCTION) { ForwardedRequestCustomizer frc = new ForwardedRequestCustomizer() { public void customize(Connector connector, HttpConfiguration config, Request request) { super.customize(connector, config, request); String cfProto = request.getHeader("CloudFront-Forwarded-Proto"); if (StringUtils.equalsIgnoreCase(cfProto, config.getSecureScheme())) { request.setScheme(cfProto); request.setSecure(true); } } }; HttpConfiguration httpConfiguration = dcf.getHttpConfiguration(); httpConfiguration.addCustomizer(frc); } // Disable Jetty version header dcf.getHttpConfiguration().setSendServerVersion(false); // Increase idle timeout dcf.getHttpConfiguration().setIdleTimeout(TimeUnit.MINUTES.toMillis(5)); } } } }); String contextPath = Config.getConfigParam("context_path", ""); if (StringUtils.length(contextPath) > 1 && contextPath.charAt(0) == '/') { jef.setContextPath(contextPath); } jef.setPort(getServerPort()); logger.info("Listening on port {}...", jef.getPort()); return jef; }