org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer Java Examples
The following examples show how to use
org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer.
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: TomcatConfiguration.java From spring-boot-inside with MIT License | 6 votes |
@Bean public EmbeddedServletContainerCustomizer staticResourceCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer container) { if (container instanceof TomcatEmbeddedServletContainerFactory) { ((TomcatEmbeddedServletContainerFactory) container) .addContextCustomizers(new TomcatContextCustomizer() { @Override public void customize(Context context) { context.addLifecycleListener(new StaticResourceConfigurer(context)); } }); } } }; }
Example #2
Source File: _WebConfigurer.java From jhipster-ribbon-hystrix with GNU General Public License v3.0 | 6 votes |
/** * Set up Mime types and, if needed, set the document root. */ @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", "text/html;charset=utf-8"); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", "text/html;charset=utf-8"); container.setMimeMappings(mappings);<% if (!skipClient) { %> // When running in an IDE or with <% if (buildTool == 'gradle') { %>./gradlew bootRun<% } else { %>./mvnw spring-boot:run<% } %>, set location of the static web assets. File root; if (env.acceptsProfiles(Constants.SPRING_PROFILE_PRODUCTION)) { root = new File("<%= CLIENT_DIST_DIR %>"); } else { root = new File("<%= CLIENT_MAIN_SRC_DIR %>"); } if (root.exists() && root.isDirectory()) { container.setDocumentRoot(root); }<% } %> }
Example #3
Source File: ProxiesAutoConfiguration.java From booties with Apache License 2.0 | 6 votes |
@Bean public EmbeddedServletContainerCustomizer embeddedServletContainerCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(final ConfigurableEmbeddedServletContainer container) { if (container instanceof TomcatEmbeddedServletContainerFactory) { TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container; for (TomcatConnectorCustomizer customizer : tomcatConnectorCustomizers) { tomcat.addConnectorCustomizers(customizer); } } } }; }
Example #4
Source File: WebAppConfig.java From tinker-manager with Apache License 2.0 | 6 votes |
@Bean public EmbeddedServletContainerCustomizer containerCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer container) { ErrorPage page404 = new ErrorPage(HttpStatus.NOT_FOUND,"/404"); container.addErrorPages(page404); } }; // return (container -> { // ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html"); // ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html"); // ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html"); // // container.addErrorPages(error401Page, error404Page, error500Page); // }); }
Example #5
Source File: SslServletContainerCustomizer.java From haven-platform with Apache License 2.0 | 6 votes |
@Override public void customize(ConfigurableEmbeddedServletContainer container) { KeystoreConfig cert = configureKeystore(); if(cert == null) { log.debug("Ssl is not enabled due to no any configured keystore."); return; } String keystorePath = cert.getKeystore().getAbsolutePath(); log.debug("Configure ssl with {} keystore.", keystorePath); Ssl ssl = new Ssl(); ssl.setEnabled(true); ssl.setKeyStore(keystorePath); ssl.setKeyStorePassword(cert.getKeystorePassword()); ssl.setKeyPassword(cert.getKeyPassword()); container.setSsl(ssl); }
Example #6
Source File: TomcatConfiguration.java From spring-boot-fat-jar-jsp-sample with MIT License | 6 votes |
@Bean public EmbeddedServletContainerCustomizer staticResourceCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer container) { if (container instanceof TomcatEmbeddedServletContainerFactory) { ((TomcatEmbeddedServletContainerFactory) container) .addContextCustomizers(new TomcatContextCustomizer() { @Override public void customize(Context context) { context.addLifecycleListener(new StaticResourceConfigurer(context)); } }); } } }; }
Example #7
Source File: TomcatConfig.java From karate with MIT License | 6 votes |
@Bean public EmbeddedServletContainerCustomizer cookieProcessorCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer container) { if (container instanceof TomcatEmbeddedServletContainerFactory) { TomcatEmbeddedServletContainerFactory factory = (TomcatEmbeddedServletContainerFactory) container; factory.addContextCustomizers(new TomcatContextCustomizer() { @Override public void customize(Context context) { context.setCookieProcessor(new LegacyCookieProcessor()); } }); } } }; }
Example #8
Source File: WebConfigurer.java From flair-engine with Apache License 2.0 | 6 votes |
/** * Customize the Servlet engine: Mime types, the document root, the cache. */ @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", "text/html;charset=utf-8"); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", "text/html;charset=utf-8"); container.setMimeMappings(mappings); // When running in an IDE or with ./mvnw spring-boot:run, set location of the static web assets. setLocationForStaticAssets(container); /* * Enable HTTP/2 for Undertow - https://twitter.com/ankinson/status/829256167700492288 * HTTP/2 requires HTTPS, so HTTP requests will fallback to HTTP/1.1. * See the JHipsterProperties class and your application-*.yml configuration files * for more information. */ if (jHipsterProperties.getHttp().getVersion().equals(JHipsterProperties.Http.Version.V_2_0) && container instanceof UndertowEmbeddedServletContainerFactory) { ((UndertowEmbeddedServletContainerFactory) container) .addBuilderCustomizers(builder -> builder.setServerOption(UndertowOptions.ENABLE_HTTP2, true)); } }
Example #9
Source File: BootServletContainerCustomizer.java From onetwo with Apache License 2.0 | 5 votes |
@Override public void customize(ConfigurableEmbeddedServletContainer container) { if (container instanceof TomcatEmbeddedServletContainerFactory) { TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container; tomcat.addConnectorCustomizers( (connector) -> { //connector 本身默认是 2 mb connector.setMaxPostSize(FileUtils.parseSize(multipartProperties.getMaxRequestSize())); Http11NioProtocol handler = (Http11NioProtocol)connector.getProtocolHandler(); if(tomcatProperties.getBacklog()!=-1){ //socket 连接队列大小 // handler.setBacklog(tomcatProperties.getBacklog()); handler.setAcceptCount(tomcatProperties.getAcceptCount()); } if(tomcatProperties.getMaxConnections()!=-1){ //最大连接数,默认10000 handler.setMaxConnections(tomcatProperties.getMaxConnections()); } if(tomcatProperties.getConnectionTimeout()!=-1){ handler.setConnectionTimeout(tomcatProperties.getConnectionTimeout()); } if(tomcatProperties.getConnectionUploadTimeout()>0){ //为true,则上传文件时使用connectionTimeout, 为false,则使用connectionUploadTimeout handler.setDisableUploadTimeout(false); handler.setConnectionUploadTimeout(tomcatProperties.getConnectionUploadTimeout()); } connector.setAsyncTimeout(tomcatProperties.getAsyncTimeout()); } ); } /*if(container instanceof TomcatEmbeddedServletContainerFactory){ TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container; tomcat.addContextCustomizers(context->{ context.setReloadable(true); }); }*/ }
Example #10
Source File: WebConfigurer.java From expper with GNU General Public License v3.0 | 5 votes |
/** * Set up Mime types. */ @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", "text/html;charset=utf-8"); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", "text/html;charset=utf-8"); container.setMimeMappings(mappings); }
Example #11
Source File: WebConfigurer.java From jhipster-ribbon-hystrix with GNU General Public License v3.0 | 5 votes |
/** * Set up Mime types and, if needed, set the document root. */ @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", "text/html;charset=utf-8"); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", "text/html;charset=utf-8"); container.setMimeMappings(mappings); }
Example #12
Source File: WebConfigurer.java From gpmr with Apache License 2.0 | 5 votes |
/** * Set up Mime types and, if needed, set the document root. */ @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", "text/html;charset=utf-8"); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", "text/html;charset=utf-8"); container.setMimeMappings(mappings); // When running in an IDE or with ./gradlew bootRun, set location of the static web assets. setLocationForStaticAssets(container); }
Example #13
Source File: WebConfigurer.java From OpenIoE with Apache License 2.0 | 5 votes |
/** * Set up Mime types and, if needed, set the document root. */ @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", "text/html;charset=utf-8"); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", "text/html;charset=utf-8"); container.setMimeMappings(mappings); // When running in an IDE or with ./gradlew bootRun, set location of the static web assets. setLocationForStaticAssets(container); }
Example #14
Source File: App.java From bluemix-cloud-connectors with Apache License 2.0 | 5 votes |
@Override public void customize(ConfigurableEmbeddedServletContainer container) { //Enabled UTF-8 as the default character encoding for static HTML resources. //If you would like to disable this comment out the 3 lines below or change //the encoding to whatever you would like. MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("html", "text/html;charset=utf-8"); container.setMimeMappings(mappings); }
Example #15
Source File: Application.java From youkefu with Apache License 2.0 | 5 votes |
@Bean public EmbeddedServletContainerCustomizer containerCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer container) { ErrorPage error = new ErrorPage("/error.html"); container.addErrorPages(error); } }; }
Example #16
Source File: AjpConfiguration.java From osiam with MIT License | 5 votes |
@Override public void customize(ConfigurableEmbeddedServletContainer container) { if (container instanceof TomcatEmbeddedServletContainerFactory) { TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container; Connector ajpConnector = new Connector("AJP/1.3"); ajpConnector.setAttribute("address", bindAddress); ajpConnector.setPort(port); ajpConnector.setSecure(false); ajpConnector.setAllowTrace(false); ajpConnector.setScheme("http"); tomcat.addAdditionalTomcatConnectors(ajpConnector); } }
Example #17
Source File: Bootstrap.java From mywx with Apache License 2.0 | 5 votes |
@Override public void customize(ConfigurableEmbeddedServletContainer container) { container.addErrorPages( new ErrorPage(HttpStatus.BAD_REQUEST, "/error/notfound"), new ErrorPage(HttpStatus.NOT_FOUND, "/error/notfound") ); }
Example #18
Source File: WebConfigurer.java From angularjs-springboot-bookstore with MIT License | 5 votes |
/** * Set up Mime types. */ @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", "text/html;charset=utf-8"); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", "text/html;charset=utf-8"); container.setMimeMappings(mappings); }
Example #19
Source File: PlatformWebFontMimeMapper.java From abixen-platform with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("woff", "application/font-woff"); mappings.add("woff2", "application/font-woff2"); mappings.add("ttf", "application/x-font-truetype"); mappings.add("eot", "application/vnd.ms-fontobject"); mappings.add("svg", "image/svg+xml"); mappings.add("otf", "application/x-font-opentype"); container.setMimeMappings(mappings); }
Example #20
Source File: WebConfigurer.java From ServiceCutter with Apache License 2.0 | 5 votes |
/** * Set up Mime types. */ @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", "text/html;charset=utf-8"); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", "text/html;charset=utf-8"); container.setMimeMappings(mappings); }
Example #21
Source File: OAuth2SecurityConfiguration.java From mobilecloud-15 with Apache License 2.0 | 5 votes |
@Bean EmbeddedServletContainerCustomizer containerCustomizer( @Value("${keystore.file:src/main/resources/private/keystore}") String keystoreFile, @Value("${keystore.pass:changeit}") final String keystorePass) throws Exception { // If you were going to reuse this class in another // application, this is one of the key sections that you // would want to change final String absoluteKeystoreFile = new File(keystoreFile).getAbsolutePath(); return new EmbeddedServletContainerCustomizer () { @Override public void customize(ConfigurableEmbeddedServletContainer container) { TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container; tomcat.addConnectorCustomizers( new TomcatConnectorCustomizer() { @Override public void customize(Connector connector) { connector.setPort(8443); connector.setSecure(true); connector.setScheme("https"); Http11NioProtocol proto = (Http11NioProtocol) connector.getProtocolHandler(); proto.setSSLEnabled(true); proto.setKeystoreFile(absoluteKeystoreFile); proto.setKeystorePass(keystorePass); proto.setKeystoreType("JKS"); proto.setKeyAlias("tomcat"); } }); } }; }
Example #22
Source File: CustomizedConfig.java From x-pipe with Apache License 2.0 | 5 votes |
@Bean public EmbeddedServletContainerCustomizer containerCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer container) { ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html"); container.addErrorPages(error401Page); } }; }
Example #23
Source File: Application.java From spring-boot-quickstart with Apache License 2.0 | 5 votes |
@Bean public EmbeddedServletContainerCustomizer containerCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer container) { ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/WEB-INF/views/error/401.jsp"); ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/WEB-INF/views/error/404.jsp"); ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/WEB-INF/views/error/500.jsp"); container.addErrorPages(error401Page, error404Page, error500Page); } }; }
Example #24
Source File: WebConfig.java From jee-universal-bms with Apache License 2.0 | 5 votes |
@Bean public EmbeddedServletContainerCustomizer containerCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer container) { ErrorPage error403Page = new ErrorPage(HttpStatus.FORBIDDEN, "/403.html"); ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html"); ErrorPage error405Page = new ErrorPage(HttpStatus.METHOD_NOT_ALLOWED, "/405.html"); ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html"); container.addErrorPages(error403Page, error404Page, error405Page, error500Page); } }; }
Example #25
Source File: ServletContainerConfig.java From portal-de-servicos with MIT License | 5 votes |
private void addMimeMappingsForFonts(ConfigurableEmbeddedServletContainer servletContainer) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("eot", "application/vnd.ms-fontobject"); mappings.add("ttf", "application/font-sfnt"); mappings.add("otf", "application/font-sfnt"); mappings.add("woff", "application/font-woff"); mappings.add("woff2", "application/font-woff"); servletContainer.setMimeMappings(mappings); }
Example #26
Source File: ErrorPageConfig.java From xxl-conf with GNU General Public License v3.0 | 5 votes |
@Bean public EmbeddedServletContainerCustomizer containerCustomizer() { return new EmbeddedServletContainerCustomizer() { public void customize(ConfigurableEmbeddedServletContainer container) { ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/static/html/500.html"); ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/static/html/500.html"); container.addErrorPages(error404Page, error500Page); } }; }
Example #27
Source File: Application.java From ethereum-secure-proxy with GNU Affero General Public License v3.0 | 5 votes |
@Bean public EmbeddedServletContainerCustomizer containerCustomizer() { return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer container) { container.setPort(cmdLineResult.getPort()); } }; }
Example #28
Source File: WebConfigurer.java From JiwhizBlogWeb with Apache License 2.0 | 5 votes |
/** * Set up Mime types. */ @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", "text/html;charset=utf-8"); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", "text/html;charset=utf-8"); container.setMimeMappings(mappings); }
Example #29
Source File: ContainerConfiguration.java From spring-boot-security-example with MIT License | 5 votes |
@Bean EmbeddedServletContainerCustomizer containerCustomizer( @Value("${keystore.file}") String keystoreFile, @Value("${server.port}") final String serverPort, @Value("${keystore.pass}") final String keystorePass) throws Exception { // This is boiler plate code to setup https on embedded Tomcat // with Spring Boot: final String absoluteKeystoreFile = new File(keystoreFile) .getAbsolutePath(); return new EmbeddedServletContainerCustomizer() { @Override public void customize(ConfigurableEmbeddedServletContainer container) { TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container; tomcat.addConnectorCustomizers(connector -> { connector.setPort(Integer.parseInt(serverPort)); connector.setSecure(true); connector.setScheme("https"); Http11NioProtocol proto = (Http11NioProtocol) connector .getProtocolHandler(); proto.setSSLEnabled(true); proto.setKeystoreFile(absoluteKeystoreFile); proto.setKeystorePass(keystorePass); proto.setKeystoreType("JKS"); proto.setKeyAlias("tomcat"); }); } }; }
Example #30
Source File: TomcatContainerCustomizer.java From radar with Apache License 2.0 | 5 votes |
@Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); mappings.add("woff", "application/x-font-woff"); mappings.add("eot", "application/vnd.ms-fontobject"); mappings.add("ttf", "application/x-font-ttf"); container.setMimeMappings(mappings); if (!(container instanceof TomcatEmbeddedServletContainerFactory)) { return; } if (!environment.containsProperty(TOMCAT_ACCEPTOR_COUNT)) { return; } TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container; tomcat.addConnectorCustomizers(new TomcatConnectorCustomizer() { @Override public void customize(Connector connector) { ProtocolHandler handler = connector.getProtocolHandler(); if (handler instanceof Http11NioProtocol) { Http11NioProtocol http = (Http11NioProtocol) handler; acceptCount = soaConfig.getTomcatAcceptCount(); soaConfig.registerChanged(() -> { if (acceptCount != soaConfig.getTomcatAcceptCount()) { acceptCount = soaConfig.getTomcatAcceptCount(); http.setBacklog(acceptCount); } }); http.setBacklog(acceptCount); logger.info("Setting tomcat accept count to {}", acceptCount); } } }); }