Search in sources :

Example 1 with ConfigurableEmbeddedServletContainer

use of org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer in project microservices by pwillhan.

the class WebConfig method containerCustomizer.

@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
    return new EmbeddedServletContainerCustomizer() {

        @Override
        public void customize(ConfigurableEmbeddedServletContainer container) {
            // TODO Auto-generated method stub
            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);
        }
    };
}
Also used : ErrorPage(org.springframework.boot.context.embedded.ErrorPage) ConfigurableEmbeddedServletContainer(org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer) EmbeddedServletContainerCustomizer(org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer) Bean(org.springframework.context.annotation.Bean)

Example 2 with ConfigurableEmbeddedServletContainer

use of org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer in project x-pipe by ctripcorp.

the class CustomizedConfig method containerCustomizer.

@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {
    return new EmbeddedServletContainerCustomizer() {

        @Override
        public void customize(ConfigurableEmbeddedServletContainer container) {
            ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
            container.addErrorPages(error401Page);
        }
    };
}
Also used : ErrorPage(org.springframework.boot.context.embedded.ErrorPage) ConfigurableEmbeddedServletContainer(org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer) EmbeddedServletContainerCustomizer(org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer) Bean(org.springframework.context.annotation.Bean)

Example 3 with ConfigurableEmbeddedServletContainer

use of org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer in project metasfresh-webui-api by metasfresh.

the class WebRestApiApplication method servletContainerCustomizer.

@Bean
public EmbeddedServletContainerCustomizer servletContainerCustomizer() {
    return new EmbeddedServletContainerCustomizer() {

        @Override
        public void customize(final ConfigurableEmbeddedServletContainer servletContainer) {
            final TomcatEmbeddedServletContainerFactory tomcatContainerFactory = (TomcatEmbeddedServletContainerFactory) servletContainer;
            tomcatContainerFactory.addConnectorCustomizers(new TomcatConnectorCustomizer() {

                @Override
                public void customize(final Connector connector) {
                    final AbstractHttp11Protocol<?> httpProtocol = (AbstractHttp11Protocol<?>) connector.getProtocolHandler();
                    httpProtocol.setCompression("on");
                    httpProtocol.setCompressionMinSize(256);
                    final String mimeTypes = httpProtocol.getCompressibleMimeType();
                    final String mimeTypesWithJson = mimeTypes + "," + MediaType.APPLICATION_JSON_VALUE + ",application/javascript";
                    httpProtocol.setCompressibleMimeType(mimeTypesWithJson);
                }
            });
        }
    };
}
Also used : Connector(org.apache.catalina.connector.Connector) ConfigurableEmbeddedServletContainer(org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer) TomcatEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory) TomcatConnectorCustomizer(org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer) EmbeddedServletContainerCustomizer(org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer) AbstractHttp11Protocol(org.apache.coyote.http11.AbstractHttp11Protocol) Bean(org.springframework.context.annotation.Bean)

Aggregations

ConfigurableEmbeddedServletContainer (org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer)3 EmbeddedServletContainerCustomizer (org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer)3 Bean (org.springframework.context.annotation.Bean)3 ErrorPage (org.springframework.boot.context.embedded.ErrorPage)2 Connector (org.apache.catalina.connector.Connector)1 AbstractHttp11Protocol (org.apache.coyote.http11.AbstractHttp11Protocol)1 TomcatConnectorCustomizer (org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer)1 TomcatEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory)1