List of usage examples for org.springframework.http.server.reactive ReactorHttpHandlerAdapter ReactorHttpHandlerAdapter
public ReactorHttpHandlerAdapter(HttpHandler httpHandler)
From source file:com.example.config.ApplicationBuilder.java
public static void start(ConfigurableApplicationContext context) { if (!hasListeners(context)) { ((DefaultListableBeanFactory) context.getBeanFactory()).registerDisposableBean(SHUTDOWN_LISTENER, new ShutdownApplicationListener()); new BeanCountingApplicationListener().log(context); logger.info(STARTUP);/*from w ww . j a va2 s . c o m*/ } HttpHandler handler = WebHttpHandlerBuilder.applicationContext(context).build(); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(handler); HttpServer httpServer = HttpServer.create().host("localhost") .port(context.getEnvironment().getProperty("server.port", Integer.class, 8080)).handle(adapter); httpServer.bindUntilJavaShutdown(Duration.ofSeconds(60), disposable -> disposable.dispose()); }
From source file:top.zhacker.ms.reactor.spring.function.Server.java
public void startReactorServer() throws InterruptedException { RouterFunction<ServerResponse> route = routingFunction(); HttpHandler httpHandler = toHttpHandler(route); ReactorHttpHandlerAdapter adapter = new ReactorHttpHandlerAdapter(httpHandler); HttpServer server = HttpServer.create(HOST, PORT); server.newHandler(adapter).block();/*from w ww .java2s. c om*/ }