| .. | .. |
|---|
| 1 | 1 | package it.digione.dg1cloud.app; |
|---|
| 2 | 2 | |
|---|
| 3 | | -import org.apache.catalina.connector.Connector; |
|---|
| 4 | | -import org.apache.coyote.http11.AbstractHttp11Protocol; |
|---|
| 5 | | -import org.springframework.beans.factory.annotation.Value; |
|---|
| 6 | 3 | import org.springframework.boot.SpringApplication; |
|---|
| 7 | 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
|---|
| 8 | 5 | import org.springframework.boot.builder.SpringApplicationBuilder; |
|---|
| 9 | | -import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; |
|---|
| 10 | 6 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
|---|
| 11 | | -import org.springframework.context.annotation.Bean; |
|---|
| 12 | 7 | import org.springframework.context.annotation.ComponentScan; |
|---|
| 13 | 8 | import org.springframework.context.annotation.Configuration; |
|---|
| 14 | 9 | |
|---|
| .. | .. |
|---|
| 17 | 12 | @SpringBootApplication |
|---|
| 18 | 13 | public class Dg1cloudCoreApplication extends SpringBootServletInitializer { |
|---|
| 19 | 14 | |
|---|
| 20 | | - @Value("${tomcat.MaxSwallowSize}") |
|---|
| 21 | | - private int maxFileSize; |
|---|
| 22 | 15 | |
|---|
| 23 | 16 | public static void main(String[] args) { |
|---|
| 24 | 17 | SpringApplication.run(Dg1cloudCoreApplication.class, args); |
|---|
| .. | .. |
|---|
| 27 | 20 | @Override |
|---|
| 28 | 21 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { |
|---|
| 29 | 22 | return application.sources(Dg1cloudCoreApplication.class); |
|---|
| 30 | | - } |
|---|
| 31 | | - |
|---|
| 32 | | - @Bean |
|---|
| 33 | | - public TomcatServletWebServerFactory containerFactory() { |
|---|
| 34 | | - return new TomcatServletWebServerFactory() { |
|---|
| 35 | | - protected void customizeConnector(Connector connector) { |
|---|
| 36 | | - int maxSize = maxFileSize * 1024 * 1024 * 10; |
|---|
| 37 | | - super.customizeConnector(connector); |
|---|
| 38 | | - connector.setMaxPostSize(maxSize); |
|---|
| 39 | | - connector.setMaxSavePostSize(maxSize); |
|---|
| 40 | | - if (connector.getProtocolHandler() instanceof AbstractHttp11Protocol) { |
|---|
| 41 | | - ((AbstractHttp11Protocol <?>) connector.getProtocolHandler()).setMaxSwallowSize(-1); |
|---|
| 42 | | - logger.info("Set MaxSwallowSize "+ maxSize); |
|---|
| 43 | | - } |
|---|
| 44 | | - } |
|---|
| 45 | | - }; |
|---|
| 46 | 23 | } |
|---|
| 47 | 24 | } |
|---|