use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class SampleTomcatTwoConnectorsApplication method servletContainer.
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addAdditionalTomcatConnectors(createStandardConnector());
return tomcat;
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class DefaultServletWebServerFactoryCustomizer method customize.
@Override
public void customize(ConfigurableServletWebServerFactory factory) {
if (this.serverProperties.getPort() != null) {
factory.setPort(this.serverProperties.getPort());
}
if (this.serverProperties.getAddress() != null) {
factory.setAddress(this.serverProperties.getAddress());
}
if (this.serverProperties.getServlet().getContextPath() != null) {
factory.setContextPath(this.serverProperties.getServlet().getContextPath());
}
if (this.serverProperties.getDisplayName() != null) {
factory.setDisplayName(this.serverProperties.getDisplayName());
}
if (this.serverProperties.getSession().getTimeout() != null) {
factory.setSessionTimeout(this.serverProperties.getSession().getTimeout());
}
factory.setPersistSession(this.serverProperties.getSession().isPersistent());
factory.setSessionStoreDir(this.serverProperties.getSession().getStoreDir());
if (this.serverProperties.getSsl() != null) {
factory.setSsl(this.serverProperties.getSsl());
}
if (this.serverProperties.getServlet() != null) {
factory.setJsp(this.serverProperties.getServlet().getJsp());
}
if (this.serverProperties.getCompression() != null) {
factory.setCompression(this.serverProperties.getCompression());
}
factory.setServerHeader(this.serverProperties.getServerHeader());
if (factory instanceof TomcatServletWebServerFactory) {
TomcatCustomizer.customizeTomcat(this.serverProperties, this.environment, (TomcatServletWebServerFactory) factory);
}
if (factory instanceof JettyServletWebServerFactory) {
JettyCustomizer.customizeJetty(this.serverProperties, this.environment, (JettyServletWebServerFactory) factory);
}
if (factory instanceof UndertowServletWebServerFactory) {
UndertowCustomizer.customizeUndertow(this.serverProperties, this.environment, (UndertowServletWebServerFactory) factory);
}
factory.addInitializers(new SessionConfiguringInitializer(this.serverProperties.getSession()));
factory.addInitializers(new InitParameterConfiguringServletContextInitializer(this.serverProperties.getServlet().getContextParameters()));
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class DefaultServletWebServerFactoryCustomizerTests method tomcatAccessLogFileDateFormatCanBeRedefined.
@Test
public void tomcatAccessLogFileDateFormatCanBeRedefined() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
Map<String, String> map = new HashMap<String, String>();
map.put("server.tomcat.accesslog.enabled", "true");
map.put("server.tomcat.accesslog.file-date-format", "yyyy-MM-dd.HH");
bindProperties(map);
this.customizer.customize(factory);
assertThat(((AccessLogValve) factory.getEngineValves().iterator().next()).getFileDateFormat()).isEqualTo("yyyy-MM-dd.HH");
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class DefaultServletWebServerFactoryCustomizerTests method customizeTomcatDisplayName.
@Test
public void customizeTomcatDisplayName() throws Exception {
Map<String, String> map = new HashMap<>();
map.put("server.display-name", "MyBootApp");
bindProperties(map);
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
this.customizer.customize(factory);
assertThat(factory.getDisplayName()).isEqualTo("MyBootApp");
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class DefaultServletWebServerFactoryCustomizerTests method customTomcatMaxHttpPostSize.
@Test
public void customTomcatMaxHttpPostSize() {
Map<String, String> map = new HashMap<>();
map.put("server.tomcat.max-http-post-size", "10000");
bindProperties(map);
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
this.customizer.customize(factory);
TomcatWebServer embeddedFactory = (TomcatWebServer) factory.getWebServer();
embeddedFactory.start();
try {
assertThat(embeddedFactory.getTomcat().getConnector().getMaxPostSize()).isEqualTo(10000);
} finally {
embeddedFactory.stop();
}
}
Aggregations