Make ReactiveWebServerFactory functional interface

Update `ReactiveWebServerFactory` to contain only a single method.

Fixes gh-8559
pull/8621/head
Phillip Webb 8 years ago
parent ca5e566deb
commit 4100360ceb

@ -41,12 +41,6 @@ public class MockReactiveWebServerFactory extends AbstractReactiveWebServerFacto
return this.webServer;
}
@Override
public WebServer getWebServer(Map<String, HttpHandler> handlerMap) {
this.webServer = spy(new MockReactiveWebServer(handlerMap, getPort()));
return this.webServer;
}
public MockReactiveWebServer getWebServer() {
return this.webServer;
}

@ -17,7 +17,6 @@
package org.springframework.boot.web.embedded.jetty;
import java.net.InetSocketAddress;
import java.util.Map;
import org.eclipse.jetty.server.AbstractConnector;
import org.eclipse.jetty.server.ConnectionFactory;
@ -62,8 +61,8 @@ public class JettyReactiveWebServerFactory extends AbstractReactiveWebServerFact
}
/**
* Create a new {@link JettyServletWebServerFactory} that listens for requests
* using the specified port.
* Create a new {@link JettyServletWebServerFactory} that listens for requests using
* the specified port.
* @param port the port to listen on
*/
public JettyReactiveWebServerFactory(int port) {
@ -77,13 +76,6 @@ public class JettyReactiveWebServerFactory extends AbstractReactiveWebServerFact
return new JettyWebServer(server, getPort() >= 0);
}
@Override
public WebServer getWebServer(Map<String, HttpHandler> handlerMap) {
JettyHttpHandlerAdapter servlet = new JettyHttpHandlerAdapter(handlerMap);
Server server = createJettyServer(servlet);
return new JettyWebServer(server, getPort() >= 0);
}
protected Server createJettyServer(JettyHttpHandlerAdapter servlet) {
int port = (getPort() >= 0 ? getPort() : 0);
InetSocketAddress address = new InetSocketAddress(getAddress(), port);

@ -16,8 +16,6 @@
package org.springframework.boot.web.embedded.netty;
import java.util.Map;
import reactor.ipc.netty.http.server.HttpServer;
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactory;
@ -49,14 +47,6 @@ public class NettyReactiveWebServerFactory extends AbstractReactiveWebServerFact
return new NettyWebServer(server, handlerAdapter);
}
@Override
public WebServer getWebServer(Map<String, HttpHandler> handlerMap) {
HttpServer server = createHttpServer();
ReactorHttpHandlerAdapter handlerAdapter = new ReactorHttpHandlerAdapter(
handlerMap);
return new NettyWebServer(server, handlerAdapter);
}
private HttpServer createHttpServer() {
HttpServer server;
if (getAddress() != null) {

@ -17,7 +17,6 @@
package org.springframework.boot.web.embedded.tomcat;
import java.io.File;
import java.util.Map;
import org.apache.catalina.Host;
import org.apache.catalina.connector.Connector;
@ -73,14 +72,6 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac
return new TomcatWebServer(tomcatServer, getPort() >= 0);
}
@Override
public WebServer getWebServer(Map<String, HttpHandler> handlerMap) {
Tomcat tomcatServer = createTomcatServer();
TomcatHttpHandlerAdapter servlet = new TomcatHttpHandlerAdapter(handlerMap);
prepareContext(tomcatServer.getHost(), servlet);
return new TomcatWebServer(tomcatServer, getPort() >= 0);
}
private Tomcat createTomcatServer() {
Tomcat tomcat = new Tomcat();
File baseDir = createTempDir("tomcat");

@ -16,8 +16,6 @@
package org.springframework.boot.web.embedded.undertow;
import java.util.Map;
import io.undertow.Undertow;
import org.springframework.boot.web.reactive.server.AbstractReactiveWebServerFactory;
@ -65,14 +63,6 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF
return new UndertowWebServer(builder, getPort() >= 0);
}
@Override
public WebServer getWebServer(Map<String, HttpHandler> handlerMap) {
Undertow.Builder builder = createBuilder(getPort());
UndertowHttpHandlerAdapter handler = new UndertowHttpHandlerAdapter(handlerMap);
builder.setHandler(handler);
return new UndertowWebServer(builder, getPort() >= 0);
}
private Undertow.Builder createBuilder(int port) {
Undertow.Builder builder = Undertow.builder();
if (this.bufferSize != null) {

@ -16,8 +16,6 @@
package org.springframework.boot.web.reactive.server;
import java.util.Map;
import org.springframework.boot.web.server.WebServer;
import org.springframework.http.server.reactive.HttpHandler;
@ -28,6 +26,7 @@ import org.springframework.http.server.reactive.HttpHandler;
* @since 2.0.0
* @see WebServer
*/
@FunctionalInterface
public interface ReactiveWebServerFactory {
/**
@ -41,12 +40,4 @@ public interface ReactiveWebServerFactory {
*/
WebServer getWebServer(HttpHandler httpHandler);
/**
* Register a map of {@link HttpHandler}s, each to a specific context path.
* @param handlerMap a map of context paths and the associated {@code HttpHandler}
* @return a fully configured and started {@link WebServer}
* @see WebServer#stop()
*/
WebServer getWebServer(Map<String, HttpHandler> handlerMap);
}

Loading…
Cancel
Save