|
|
@ -18,7 +18,6 @@ package org.springframework.reactive.web.http.reactor; |
|
|
|
import org.springframework.beans.factory.InitializingBean; |
|
|
|
import org.springframework.beans.factory.InitializingBean; |
|
|
|
import org.springframework.reactive.web.http.HttpServer; |
|
|
|
import org.springframework.reactive.web.http.HttpServer; |
|
|
|
import org.springframework.reactive.web.http.HttpServerSupport; |
|
|
|
import org.springframework.reactive.web.http.HttpServerSupport; |
|
|
|
import org.springframework.reactive.web.http.reactor.RequestHandlerAdapter; |
|
|
|
|
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import reactor.bus.selector.Selectors; |
|
|
|
import reactor.bus.selector.Selectors; |
|
|
|
import reactor.io.buffer.Buffer; |
|
|
|
import reactor.io.buffer.Buffer; |
|
|
@ -50,24 +49,33 @@ public class ReactorHttpServer extends HttpServerSupport implements Initializing |
|
|
|
this.reactorHandler = new RequestHandlerAdapter(getHttpHandler()); |
|
|
|
this.reactorHandler = new RequestHandlerAdapter(getHttpHandler()); |
|
|
|
|
|
|
|
|
|
|
|
this.reactorServer = (getPort() != -1 ? |
|
|
|
this.reactorServer = (getPort() != -1 ? |
|
|
|
NetStreams.httpServer(getPort()) : |
|
|
|
NetStreams.httpServer(getPort()) : NetStreams.httpServer()); |
|
|
|
NetStreams.httpServer()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void start() { |
|
|
|
public void start() { |
|
|
|
if (!this.running) { |
|
|
|
if (!this.running) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
this.reactorServer.route(Selectors.matchAll(), this.reactorHandler).start().await(); |
|
|
|
this.running = true; |
|
|
|
this.running = true; |
|
|
|
this.reactorServer.route(Selectors.matchAll(), this.reactorHandler).start(); |
|
|
|
} |
|
|
|
|
|
|
|
catch (InterruptedException ex) { |
|
|
|
|
|
|
|
throw new IllegalStateException(ex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void stop() { |
|
|
|
public void stop() { |
|
|
|
if (this.running) { |
|
|
|
if (this.running) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
this.reactorServer.shutdown().await(); |
|
|
|
this.running = false; |
|
|
|
this.running = false; |
|
|
|
this.reactorServer.shutdown(); |
|
|
|
} |
|
|
|
|
|
|
|
catch (InterruptedException ex) { |
|
|
|
|
|
|
|
throw new IllegalStateException(ex); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|