use of org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer 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);
}
}
});
}
use of org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer 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;
}
use of org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer in project spring-boot-examples by ityouknow.
the class FastDFSApplication 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;
}
use of org.springframework.boot.context.embedded.tomcat.TomcatConnectorCustomizer 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);
}
});
}
};
}
Aggregations