Search in sources :

Example 6 with TomcatEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory in project seldon-core by SeldonIO.

the class TomcatConfig method servletContainer.

@Bean
public EmbeddedServletContainerFactory servletContainer() {
    TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
    Connector[] additionalConnectors = this.additionalConnector();
    if (additionalConnectors != null && additionalConnectors.length > 0) {
        tomcat.addAdditionalTomcatConnectors(additionalConnectors);
    }
    return tomcat;
}
Also used : Connector(org.apache.catalina.connector.Connector) TomcatEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory) Bean(org.springframework.context.annotation.Bean)

Example 7 with TomcatEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory in project gpconnect-demonstrator by nhsconnect.

the class RestConfig method servletContainer.

@Bean
public EmbeddedServletContainerFactory servletContainer() {
    TomcatEmbeddedServletContainerFactory tomcat;
    if (enableHsts && httpPort != null && httpPort > 0) {
        tomcat = new TomcatEmbeddedServletContainerFactory() {

            @Override
            protected void postProcessContext(Context context) {
                SecurityConstraint securityConstraint = new SecurityConstraint();
                securityConstraint.setUserConstraint("CONFIDENTIAL");
                SecurityCollection collection = new SecurityCollection();
                collection.addPattern("/*");
                securityConstraint.addCollection(collection);
                context.addConstraint(securityConstraint);
            }
        };
    } else {
        tomcat = new TomcatEmbeddedServletContainerFactory();
    }
    tomcat.addAdditionalTomcatConnectors(createHttpConnector());
    return tomcat;
}
Also used : Context(org.apache.catalina.Context) TomcatEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory) SecurityConstraint(org.apache.tomcat.util.descriptor.web.SecurityConstraint) SecurityCollection(org.apache.tomcat.util.descriptor.web.SecurityCollection) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 8 with TomcatEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory in project apollo by ctripcorp.

the class TomcatContainerCustomizer method customize.

@Override
public void customize(ConfigurableEmbeddedServletContainer container) {
    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;
                int acceptCount = Integer.parseInt(environment.getProperty(TOMCAT_ACCEPTOR_COUNT));
                http.setBacklog(acceptCount);
                logger.info("Setting tomcat accept count to {}", acceptCount);
            }
        }
    });
}
Also used : ProtocolHandler(org.apache.coyote.ProtocolHandler) Connector(org.apache.catalina.connector.Connector) Http11NioProtocol(org.apache.coyote.http11.Http11NioProtocol) TomcatEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory) TomcatConnectorCustomizer(org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer)

Example 9 with TomcatEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory in project webanno by webanno.

the class WebAnno method servletContainer.

@Bean
public EmbeddedServletContainerFactory servletContainer() {
    TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
    if (ajpPort > 0) {
        Connector ajpConnector = new Connector(PROTOCOL);
        ajpConnector.setPort(ajpPort);
        tomcat.addAdditionalTomcatConnectors(ajpConnector);
    }
    return tomcat;
}
Also used : Connector(org.apache.catalina.connector.Connector) TomcatEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory) Bean(org.springframework.context.annotation.Bean) LocalValidatorFactoryBean(org.springframework.validation.beanvalidation.LocalValidatorFactoryBean)

Example 10 with TomcatEmbeddedServletContainerFactory

use of org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory in project spring-boot-examples by ityouknow.

the class FileUploadWebApplication method tomcatEmbedded.

// Tomcat large file upload connection reset
@Bean
public TomcatEmbeddedServletContainerFactory tomcatEmbedded() {
    TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
    tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> {
        if ((connector.getProtocolHandler() instanceof AbstractHttp11Protocol<?>)) {
            ((AbstractHttp11Protocol<?>) connector.getProtocolHandler()).setMaxSwallowSize(-1);
        }
    });
    return tomcat;
}
Also used : SpringApplication(org.springframework.boot.SpringApplication) TomcatEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory) SpringBootApplication(org.springframework.boot.autoconfigure.SpringBootApplication) AbstractHttp11Protocol(org.apache.coyote.http11.AbstractHttp11Protocol) Bean(org.springframework.context.annotation.Bean) TomcatConnectorCustomizer(org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer) TomcatEmbeddedServletContainerFactory(org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory) AbstractHttp11Protocol(org.apache.coyote.http11.AbstractHttp11Protocol) Bean(org.springframework.context.annotation.Bean)

Aggregations

TomcatEmbeddedServletContainerFactory (org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory)14 Bean (org.springframework.context.annotation.Bean)11 Connector (org.apache.catalina.connector.Connector)6 TomcatConnectorCustomizer (org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer)4 Context (org.apache.catalina.Context)3 AbstractHttp11Protocol (org.apache.coyote.http11.AbstractHttp11Protocol)3 SecurityCollection (org.apache.tomcat.util.descriptor.web.SecurityCollection)3 SecurityConstraint (org.apache.tomcat.util.descriptor.web.SecurityConstraint)3 SpringApplication (org.springframework.boot.SpringApplication)2 SpringBootApplication (org.springframework.boot.autoconfigure.SpringBootApplication)2 ConsumerContextConfig (com.dell.cpsd.service.common.client.context.ConsumerContextConfig)1 IOException (java.io.IOException)1 Base64 (java.util.Base64)1 ServletException (javax.servlet.ServletException)1 Request (org.apache.catalina.connector.Request)1 Response (org.apache.catalina.connector.Response)1 CombinedRealm (org.apache.catalina.realm.CombinedRealm)1 RealmBase (org.apache.catalina.realm.RealmBase)1 ValveBase (org.apache.catalina.valves.ValveBase)1 ProtocolHandler (org.apache.coyote.ProtocolHandler)1