Avoid explicit DecoratedObjectFactory setup in JettyRequestUpgradeStrategy
Align Jetty support on spring-websocket module. Issue: SPR-14940
This commit is contained in:
parent
7b183048b8
commit
54901ab865
|
|
@ -23,7 +23,6 @@ import javax.servlet.ServletContext;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.util.DecoratedObjectFactory;
|
||||
import org.eclipse.jetty.websocket.server.WebSocketServerFactory;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
|
|
@ -165,7 +164,6 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy, Life
|
|||
synchronized (this.lifecycleMonitor) {
|
||||
if (this.servletContext == null) {
|
||||
this.servletContext = request.getServletContext();
|
||||
this.servletContext.setAttribute(DecoratedObjectFactory.ATTR, new DecoratedObjectFactory());
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue