org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory Java Examples
The following examples show how to use
org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory.
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: BrokerApplication.java From WeEvent with Apache License 2.0 | 6 votes |
@Bean public ConfigurableServletWebServerFactory configurableServletWebServerFactory() { log.info("custom TomcatServletWebServerFactory"); TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); factory.setProtocol(TomcatServletWebServerFactory.DEFAULT_PROTOCOL); factory.addConnectorCustomizers((connector) -> { // default max connections = 10000 // default connection timeout = 20000 // default max accept count = 100 // default max worker thread = 200 connector.setEnableLookups(false); connector.setAllowTrace(false); Http11NioProtocol http11NioProtocol = (Http11NioProtocol) connector.getProtocolHandler(); http11NioProtocol.setKeepAliveTimeout(60000); http11NioProtocol.setMaxKeepAliveRequests(10000); http11NioProtocol.setDisableUploadTimeout(true); http11NioProtocol.setTcpNoDelay(true); } ); return factory; }
Example #2
Source File: CustomizationWebServerBean.java From wind-im with Apache License 2.0 | 6 votes |
@Override public void customize(ConfigurableServletWebServerFactory server) { String adminAddress = ConfigHelper.getStringConfig(ConfigKey.SITE_ADMIN_ADDRESS); String adminPort = ConfigHelper.getStringConfig(ConfigKey.SITE_ADMIN_PORT); // set admin port if (StringUtils.isNumeric(adminPort)) { server.setPort(Integer.valueOf(adminPort)); } else { server.setPort(8288); } // set admin address if (StringUtils.isNotEmpty(adminAddress)) { try { InetAddress address = InetAddress.getByName(adminAddress); server.setAddress(address); } catch (UnknownHostException e) { } } server.setContextPath("/akaxin"); }
Example #3
Source File: Bucket4JAutoConfigurationServletFilter.java From bucket4j-spring-boot-starter with Apache License 2.0 | 6 votes |
@Override public void customize(ConfigurableServletWebServerFactory factory) { AtomicInteger filterCount = new AtomicInteger(0); properties .getFilters() .stream() .filter(filter -> !StringUtils.isEmpty(filter.getUrl()) && filter.getFilterMethod().equals(FilterMethod.SERVLET)) .forEach(filter -> { filterCount.incrementAndGet(); FilterConfiguration<HttpServletRequest> filterConfig = buildFilterConfig(filter, cacheResolver.resolve(filter.getCacheName()), servletFilterExpressionParser(), beanFactory); servletConfigurationHolder().addFilterConfiguration(filter); context.registerBean("bucket4JServletRequestFilter" + filterCount, Filter.class, () -> new ServletRequestFilter(filterConfig)); log.info("create-servlet-filter;{};{};{}", filterCount, filter.getCacheName(), filter.getUrl()); }); }
Example #4
Source File: EmbeddedTomcatConfig.java From blog with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void customize(ConfigurableServletWebServerFactory factory) { ((TomcatServletWebServerFactory) factory).addConnectorCustomizers(new TomcatConnectorCustomizer() { @Override public void customize(Connector connector) { Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler(); protocol.setMaxConnections(200); protocol.setMaxThreads(200); protocol.setSelectorTimeout(3000); protocol.setSessionTimeout(3000); protocol.setConnectionTimeout(3000); connector.setPort(8888); } }); }
Example #5
Source File: CustomizationWebServerBean.java From openzaly with Apache License 2.0 | 6 votes |
@Override public void customize(ConfigurableServletWebServerFactory server) { String adminAddress = ConfigHelper.getStringConfig(ConfigKey.SITE_ADMIN_ADDRESS); String adminPort = ConfigHelper.getStringConfig(ConfigKey.SITE_ADMIN_PORT); // set admin port if (StringUtils.isNumeric(adminPort)) { server.setPort(Integer.valueOf(adminPort)); } else { server.setPort(8288); } // set admin address if (StringUtils.isNotEmpty(adminAddress)) { try { InetAddress address = InetAddress.getByName(adminAddress); server.setAddress(address); } catch (UnknownHostException e) { } } server.setContextPath("/akaxin"); }
Example #6
Source File: WebFragmentRegistrationBean.java From joinfaces with Apache License 2.0 | 6 votes |
@Override public void customize(ConfigurableServletWebServerFactory factory) { if (factory instanceof TomcatServletWebServerFactory) { ((TomcatServletWebServerFactory) factory).addContextCustomizers(new TomcatListenerAdder(this.listeners)); } else if (factory instanceof JettyServletWebServerFactory) { ((JettyServletWebServerFactory) factory).addConfigurations(new JettyListenerAdder(this.listeners)); } else if (factory instanceof UndertowServletWebServerFactory) { ((UndertowServletWebServerFactory) factory).addDeploymentInfoCustomizers(new UndertowListenerAdder(this.listeners)); } else { log.warn("Unkown WebServerFactory implementation: {}", factory.getClass()); factory.addInitializers(servletContext -> this.listeners.forEach(servletContext::addListener)); } factory.addInitializers(servletContext -> this.contextParams.forEach(servletContext::setInitParameter)); this.errorPages.forEach(factory::addErrorPages); }
Example #7
Source File: HttpsServerConfig.java From micro-service with MIT License | 6 votes |
@Bean public ConfigurableServletWebServerFactory configurableServletWebServerFactory() { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); factory.setSsl(getSsl()); factory.setPort(8443); factory.addAdditionalTomcatConnectors(getHttpConnector()); factory.addContextCustomizers(context -> { addSecurityConstraint(context); }); // factory.addConnectorCustomizers(connector -> { // connector.setAllowTrace(true); // }); return factory; }
Example #8
Source File: CustomizationWebServerBean.java From openzaly with Apache License 2.0 | 6 votes |
@Override public void customize(ConfigurableServletWebServerFactory server) { String adminAddress = ConfigHelper.getStringConfig(ConfigKey.SITE_ADMIN_ADDRESS); String adminPort = ConfigHelper.getStringConfig(ConfigKey.SITE_ADMIN_PORT); // set admin port if (StringUtils.isNumeric(adminPort)) { server.setPort(Integer.valueOf(adminPort)); } else { server.setPort(8288); } // set admin address if (StringUtils.isNotEmpty(adminAddress)) { try { InetAddress address = InetAddress.getByName(adminAddress); server.setAddress(address); } catch (UnknownHostException e) { } } server.setContextPath("/akaxin"); }
Example #9
Source File: TomcatConfig.java From OneBlog with GNU General Public License v3.0 | 5 votes |
@Bean public ConfigurableServletWebServerFactory webServerFactory() { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); factory.addConnectorCustomizers( connector -> { Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler(); protocol.setDisableUploadTimeout(false); } ); return factory; }
Example #10
Source File: ErrorPagesConfig.java From OneBlog with GNU General Public License v3.0 | 5 votes |
/** * 自定义异常处理路径 * * @return */ @Bean public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> containerCustomizer() { return factory -> { factory.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/error/400")); factory.addErrorPages(new ErrorPage(HttpStatus.UNAUTHORIZED, "/error/401")); factory.addErrorPages(new ErrorPage(HttpStatus.FORBIDDEN, "/error/403")); factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/error/404")); factory.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/500")); factory.addErrorPages(new ErrorPage(Throwable.class, "/error/500")); }; }
Example #11
Source File: WebConfigurer.java From albedo with GNU Lesser General Public License v3.0 | 5 votes |
private void setMimeMappings(WebServerFactory server) { if (server instanceof ConfigurableServletWebServerFactory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server; servletWebServer.setMimeMappings(mappings); } }
Example #12
Source File: WebConfigurer.java From jhipster-online with Apache License 2.0 | 5 votes |
private void setMimeMappings(WebServerFactory server) { if (server instanceof ConfigurableServletWebServerFactory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server; servletWebServer.setMimeMappings(mappings); } }
Example #13
Source File: BootStrap.java From MyBlog with Apache License 2.0 | 5 votes |
/*********************************************************************************************************/ // 设置内嵌tomcat,我还是习惯在yml配置,下面那种方式设置的不全,是内嵌服务器的通用配置 // implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> // @Bean public ConfigurableServletWebServerFactory webServerFactory() { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); factory.setPort(9000); return factory; }
Example #14
Source File: ServletContainerInitializerRegistrationBean.java From joinfaces with Apache License 2.0 | 5 votes |
@Override public void customize(ConfigurableServletWebServerFactory factory) { factory.addInitializers(servletContext -> { T servletContextInitializer = BeanUtils.instantiateClass(getServletContainerInitializerClass()); servletContextInitializer.onStartup(getClasses(servletContext.getClassLoader()), servletContext); }); }
Example #15
Source File: WebConfig.java From jshERP with GNU General Public License v3.0 | 5 votes |
@Override public void customize(ConfigurableServletWebServerFactory factory) { if (!baseDir.exists()) { if (!baseDir.mkdir()) { logger.info("create web.front base path:" + baseDir + " failed!already exists!"); } else { logger.info("create web.front base path:" + baseDir + " success!"); } } factory.setDocumentRoot(baseDir); }
Example #16
Source File: WebConfigurer.java From ehcache3-samples with Apache License 2.0 | 5 votes |
private void setMimeMappings(WebServerFactory server) { if (server instanceof ConfigurableServletWebServerFactory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server; servletWebServer.setMimeMappings(mappings); } }
Example #17
Source File: ServletCustomizer.java From openvidu with Apache License 2.0 | 5 votes |
@Override public void customize(ConfigurableServletWebServerFactory factory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("mp4", "video/mp4"); mappings.add("webm", "video/webm"); factory.setMimeMappings(mappings); }
Example #18
Source File: WebConfigurer.java From jhipster-registry with Apache License 2.0 | 5 votes |
private void setMimeMappings(WebServerFactory server) { if (server instanceof ConfigurableServletWebServerFactory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server; servletWebServer.setMimeMappings(mappings); } }
Example #19
Source File: WebXmlSpringBoot.java From sitemonitoring-production with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void customize(ConfigurableServletWebServerFactory factory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("eot", "application/vnd.ms-fontobject"); mappings.add("otf", "font/opentype"); mappings.add("ttf", "application/x-font-ttf"); mappings.add("woff", "application/x-font-woff"); mappings.add("svg", "image/svg+xml"); mappings.add("woff2", "application/x-font-woff2"); factory.setMimeMappings(mappings); }
Example #20
Source File: LealoneServletWebServerFactoryCustomizer.java From Lealone-Plugins with Apache License 2.0 | 5 votes |
@Override public void customize(ConfigurableServletWebServerFactory factory) { PropertyMapper map = PropertyMapper.get().alwaysApplyingWhenNonNull(); map.from(this.serverProperties::getPort).to(factory::setPort); map.from(this.serverProperties::getAddress).to(factory::setAddress); map.from(this.serverProperties.getServlet()::getContextPath).to(factory::setContextPath); map.from(this.serverProperties.getServlet()::getApplicationDisplayName).to(factory::setDisplayName); map.from(this.serverProperties.getServlet()::getSession).to(factory::setSession); map.from(this.serverProperties::getSsl).to(factory::setSsl); map.from(this.serverProperties.getServlet()::getJsp).to(factory::setJsp); map.from(this.serverProperties::getCompression).to(factory::setCompression); map.from(this.serverProperties::getHttp2).to(factory::setHttp2); map.from(this.serverProperties::getServerHeader).to(factory::setServerHeader); map.from(this.serverProperties.getServlet()::getContextParameters).to(factory::setInitParameters); }
Example #21
Source File: WebConfigurer.java From 21-points with Apache License 2.0 | 5 votes |
private void setMimeMappings(WebServerFactory server) { if (server instanceof ConfigurableServletWebServerFactory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server; servletWebServer.setMimeMappings(mappings); } }
Example #22
Source File: ServletConfig.java From EasyReport with Apache License 2.0 | 5 votes |
@Bean public ConfigurableServletWebServerFactory containerCustomizer() { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); factory.addErrorPages(new ErrorPage(HttpStatus.UNAUTHORIZED, "/customError/401")); factory.addErrorPages(new ErrorPage(HttpStatus.FORBIDDEN, "/customError/403")); factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/customError/404")); factory.addErrorPages(new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/customError")); return factory; }
Example #23
Source File: WebXmlSpringBoot.java From sitemonitoring-production with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void customize(ConfigurableServletWebServerFactory factory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("eot", "application/vnd.ms-fontobject"); mappings.add("otf", "font/opentype"); mappings.add("ttf", "application/x-font-ttf"); mappings.add("woff", "application/x-font-woff"); mappings.add("svg", "image/svg+xml"); mappings.add("woff2", "application/x-font-woff2"); factory.setMimeMappings(mappings); }
Example #24
Source File: MyServletContainerCustomizationBean.java From tutorials with MIT License | 5 votes |
@Override public void customize(ConfigurableServletWebServerFactory container) { container.setPort(8084); container.setContextPath("/springbootapp"); container.addErrorPages(new ErrorPage(HttpStatus.BAD_REQUEST, "/400")); container.addErrorPages(new ErrorPage("/errorHaven")); }
Example #25
Source File: WebConfigurer.java From tutorials with MIT License | 5 votes |
private void setMimeMappings(WebServerFactory server) { if (server instanceof ConfigurableServletWebServerFactory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server; servletWebServer.setMimeMappings(mappings); } }
Example #26
Source File: WebConfigurer.java From tutorials with MIT License | 5 votes |
private void setMimeMappings(WebServerFactory server) { if (server instanceof ConfigurableServletWebServerFactory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server; servletWebServer.setMimeMappings(mappings); } }
Example #27
Source File: WebConfigurer.java From tutorials with MIT License | 5 votes |
private void setMimeMappings(WebServerFactory server) { if (server instanceof ConfigurableServletWebServerFactory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server; servletWebServer.setMimeMappings(mappings); } }
Example #28
Source File: WebConfigurer.java From tutorials with MIT License | 5 votes |
private void setMimeMappings(WebServerFactory server) { if (server instanceof ConfigurableServletWebServerFactory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server; servletWebServer.setMimeMappings(mappings); } }
Example #29
Source File: WebConfigurer.java From e-commerce-microservice with Apache License 2.0 | 5 votes |
private void setMimeMappings(WebServerFactory server) { if (server instanceof ConfigurableServletWebServerFactory) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", MediaType.TEXT_HTML_VALUE + ";charset=" + StandardCharsets.UTF_8.name().toLowerCase()); ConfigurableServletWebServerFactory servletWebServer = (ConfigurableServletWebServerFactory) server; servletWebServer.setMimeMappings(mappings); } }
Example #30
Source File: WebConfig.java From flash-waimai with MIT License | 5 votes |
@Bean public ConfigurableServletWebServerFactory webServerFactory() { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); factory.addConnectorCustomizers(new TomcatConnectorCustomizer() { @Override public void customize(Connector connector) { connector.setProperty("relaxedQueryChars", "|{}[]"); } }); return factory; }