Skip to content

Commit 8109a8c

Browse files
committed
Updated ServletHttpHandlerAdapter usage
1 parent dfef4e0 commit 8109a8c

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/JettyHttpServer.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,26 +28,18 @@
2828
/**
2929
* @author Rossen Stoyanchev
3030
*/
31-
public class JettyHttpServer extends HttpServerSupport implements InitializingBean, HttpServer {
31+
public class JettyHttpServer extends HttpServerSupport implements HttpServer, InitializingBean {
3232

3333
private Server jettyServer;
3434

3535
private boolean running;
3636

3737

38-
@Override
39-
public boolean isRunning() {
40-
return this.running;
41-
}
42-
4338
@Override
4439
public void afterPropertiesSet() throws Exception {
45-
4640
this.jettyServer = new Server();
4741

48-
Assert.notNull(getHttpHandler());
49-
ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter();
50-
servlet.setHandler(getHttpHandler());
42+
ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(getHttpHandler());
5143
ServletHolder servletHolder = new ServletHolder(servlet);
5244

5345
ServletContextHandler contextHandler = new ServletContextHandler(this.jettyServer, "", false, false);
@@ -86,4 +78,9 @@ public void stop() {
8678
}
8779
}
8880

81+
@Override
82+
public boolean isRunning() {
83+
return this.running;
84+
}
85+
8986
}

spring-web/src/test/java/org/springframework/http/server/reactive/bootstrap/TomcatHttpServer.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -24,13 +24,11 @@
2424

2525
import org.springframework.beans.factory.InitializingBean;
2626
import org.springframework.http.server.reactive.ServletHttpHandlerAdapter;
27-
import org.springframework.util.Assert;
28-
2927

3028
/**
3129
* @author Rossen Stoyanchev
3230
*/
33-
public class TomcatHttpServer extends HttpServerSupport implements InitializingBean, HttpServer {
31+
public class TomcatHttpServer extends HttpServerSupport implements HttpServer, InitializingBean {
3432

3533
private Tomcat tomcatServer;
3634

@@ -47,24 +45,16 @@ public TomcatHttpServer(String baseDir) {
4745
}
4846

4947

50-
@Override
51-
public boolean isRunning() {
52-
return this.running;
53-
}
54-
5548
@Override
5649
public void afterPropertiesSet() throws Exception {
57-
5850
this.tomcatServer = new Tomcat();
5951
if (this.baseDir != null) {
6052
this.tomcatServer.setBaseDir(baseDir);
6153
}
6254
this.tomcatServer.setHostname(getHost());
6355
this.tomcatServer.setPort(getPort());
6456

65-
Assert.notNull(getHttpHandler());
66-
ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter();
67-
servlet.setHandler(getHttpHandler());
57+
ServletHttpHandlerAdapter servlet = new ServletHttpHandlerAdapter(getHttpHandler());
6858

6959
File base = new File(System.getProperty("java.io.tmpdir"));
7060
Context rootContext = tomcatServer.addContext("", base.getAbsolutePath());
@@ -100,4 +90,9 @@ public void stop() {
10090
}
10191
}
10292

93+
@Override
94+
public boolean isRunning() {
95+
return this.running;
96+
}
97+
10398
}

0 commit comments

Comments
 (0)