Avoid explicit DecoratedObjectFactory setup in JettyRequestUpgradeStrategy

Align Jetty support on spring-websocket module.

Issue: SPR-14940
This commit is contained in:
Brian Clozel
2016-12-21 17:25:53 +01:00
parent 7b183048b8
commit 54901ab865
2 changed files with 20 additions and 6 deletions

View File

@@ -32,6 +32,8 @@ public class JettyHttpServer extends HttpServerSupport implements HttpServer, In
private Server jettyServer;
private ServletContextHandler contextHandler;
private boolean running;
@@ -42,8 +44,9 @@ public class JettyHttpServer extends HttpServerSupport implements HttpServer, In
ServletHttpHandlerAdapter servlet = initServletHttpHandlerAdapter();
ServletHolder servletHolder = new ServletHolder(servlet);
ServletContextHandler contextHandler = new ServletContextHandler(this.jettyServer, "", false, false);
contextHandler.addServlet(servletHolder, "/");
this.contextHandler = new ServletContextHandler(this.jettyServer, "", false, false);
this.contextHandler.addServlet(servletHolder, "/");
this.contextHandler.start();
ServerConnector connector = new ServerConnector(this.jettyServer);
connector.setHost(getHost());
@@ -79,12 +82,25 @@ public class JettyHttpServer extends HttpServerSupport implements HttpServer, In
if (this.running) {
try {
this.running = false;
jettyServer.stop();
jettyServer.destroy();
if (this.contextHandler.isRunning()) {
this.contextHandler.stop();
}
}
catch (Exception ex) {
throw new IllegalStateException(ex);
}
finally {
try {
if (this.jettyServer.isRunning()) {
this.jettyServer.setStopTimeout(5000);
this.jettyServer.stop();
this.jettyServer.destroy();
}
}
catch (Exception ex) {
throw new IllegalStateException(ex);
}
}
}
}