Skip to content

Commit

Permalink
serverProperties for embedded tomcat (spring boot 2.x)
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Jun 22, 2018
1 parent 6eae061 commit f02a143
Showing 1 changed file with 8 additions and 4 deletions.
Expand Up @@ -39,9 +39,11 @@
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityFilterAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.MultipartAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryCustomizer;
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
Expand Down Expand Up @@ -103,7 +105,6 @@
HttpMessageConvertersAutoConfiguration.class,
PropertyPlaceholderAutoConfiguration.class,
SecurityFilterAutoConfiguration.class,
EmbeddedWebServerFactoryCustomizerAutoConfiguration.class,
MultipartAutoConfiguration.class
})
@SpringBootConfiguration
Expand Down Expand Up @@ -255,9 +256,15 @@ public class ServerCustomization implements WebServerFactoryCustomizer<Configura
@Value("${server.servlet.session.timeout}")
private int sessionTimeout;

@Autowired
ServerProperties serverProperties;

@Override
public void customize(ConfigurableServletWebServerFactory server) {

ServletWebServerFactoryCustomizer servletWebServerFactoryCustomizer = new ServletWebServerFactoryCustomizer(this.serverProperties);
servletWebServerFactoryCustomizer.customize(server);

server.addErrorPages(new ErrorPage(HttpStatus.UNAUTHORIZED,
"/error/401"));
server.addErrorPages(new ErrorPage(HttpStatus.FORBIDDEN,
Expand All @@ -273,9 +280,6 @@ public void customize(ConfigurableServletWebServerFactory server) {
session.setTimeout(Duration.ofMinutes(sessionTimeout));
server.setSession(session);

server.setContextPath("/midpoint");


if (server instanceof TomcatServletWebServerFactory) {
customizeTomcat((TomcatServletWebServerFactory) server);
}
Expand Down

0 comments on commit f02a143

Please sign in to comment.