Browse Source

Use WebHttpHandlerBuilder in samples

DispatcherHandler.toHttpHandler was removed
Rob Winch 8 years ago
parent
commit
71b1720cfe

+ 3 - 2
samples/javaconfig/hellowebflux-method/src/main/java/sample/HelloWebfluxMethodApplication.java

@@ -21,8 +21,8 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.*;
 import org.springframework.http.server.reactive.HttpHandler;
 import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
-import org.springframework.web.reactive.DispatcherHandler;
 import org.springframework.web.reactive.config.EnableWebFlux;
+import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
 import reactor.ipc.netty.NettyContext;
 import reactor.ipc.netty.http.server.HttpServer;
 
@@ -47,7 +47,8 @@ public class HelloWebfluxMethodApplication {
 	@Profile("default")
 	@Bean
 	public NettyContext nettyContext(ApplicationContext context) {
-		HttpHandler handler = DispatcherHandler.toHttpHandler(context);
+		HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context)
+			.build();
 		ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
 		HttpServer httpServer = HttpServer.create("localhost", port);
 		return httpServer.newHandler(adapter).block();

+ 3 - 2
samples/javaconfig/hellowebflux/src/main/java/sample/HelloWebfluxApplication.java

@@ -21,8 +21,8 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.annotation.*;
 import org.springframework.http.server.reactive.HttpHandler;
 import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter;
-import org.springframework.web.reactive.DispatcherHandler;
 import org.springframework.web.reactive.config.EnableWebFlux;
+import org.springframework.web.server.adapter.WebHttpHandlerBuilder;
 import reactor.ipc.netty.NettyContext;
 import reactor.ipc.netty.http.server.HttpServer;
 
@@ -46,7 +46,8 @@ public class HelloWebfluxApplication {
 	@Profile("default")
 	@Bean
 	public NettyContext nettyContext(ApplicationContext context) {
-		HttpHandler handler = DispatcherHandler.toHttpHandler(context);
+		HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context)
+			.build();
 		ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler);
 		HttpServer httpServer = HttpServer.create("localhost", port);
 		return httpServer.newHandler(adapter).block();