Browse Source

Merge pull request #1347 from bclozel/boot12

Upgrade Boot and customize Undertow
Mike Smith 10 years ago
parent
commit
0c264bf4ec

+ 2 - 2
frameworks/Java/spring/README.md

@@ -61,8 +61,8 @@ Check out [SampleApplication, the main Application file](src/main/java/com/teche
 ## Infrastructure Software Versions
 The tests were run with:
 
-* [Spring 4.1.3.RELEASE](http://projects.spring.io/spring-framework/)
-* [Spring Boot 1.2.0.RELEASE](http://projects.spring.io/spring-boot/)
+* [Spring 4.1.4.RELEASE](http://projects.spring.io/spring-framework/)
+* [Spring Boot 1.2.1.RELEASE](http://projects.spring.io/spring-boot/)
 * [Spring Data JPA 1.7.1.RELEASE](http://projects.spring.io/spring-data-jpa/)
 * [Java OpenJDK 1.7.0_09](http://openjdk.java.net/)
 * [Undertow 1.1.1.Final](http://undertow.io/)

+ 1 - 1
frameworks/Java/spring/pom.xml

@@ -8,7 +8,7 @@
     <parent>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-parent</artifactId>
-        <version>1.2.0.RELEASE</version>
+        <version>1.2.1.RELEASE</version>
     </parent>
 
     <groupId>com.techempower</groupId>

+ 26 - 0
frameworks/Java/spring/src/main/java/com/techempower/spring/SampleApplication.java

@@ -1,9 +1,16 @@
 package com.techempower.spring;
 
+import io.undertow.Undertow;
+import io.undertow.UndertowOptions;
+import org.xnio.Options;
+
 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
 import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
 import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.context.embedded.undertow.UndertowBuilderCustomizer;
+import org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory;
 import org.springframework.boot.context.web.SpringBootServletInitializer;
+import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 
@@ -21,4 +28,23 @@ public class SampleApplication extends SpringBootServletInitializer {
 		new SpringApplicationBuilder(SampleApplication.class).run(args);
 	}
 
+	@Bean
+	public UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
+		UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
+		factory.addBuilderCustomizers(new UndertowBuilderCustomizer() {
+
+			@Override
+			public void customize(Undertow.Builder builder) {
+				builder.setBufferSize(1024 * 16)
+						.setIoThreads(Runtime.getRuntime().availableProcessors() * 2)
+						.setSocketOption(Options.BACKLOG, 10000)
+						.setServerOption(UndertowOptions.ALWAYS_SET_KEEP_ALIVE, false)
+						.setServerOption(UndertowOptions.ALWAYS_SET_DATE, true)
+						.setWorkerThreads(200);
+			}
+
+		});
+		return factory;
+	}
+
 }