From 7930a3dac8ccf8ee669e0625ecd9984df9666e3b Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 16 Nov 2016 18:31:33 -0700 Subject: [PATCH] Fixing merge 9.2.x -> 9.3.x --- .../WebSocketServerContainerInitializer.java | 15 +-------------- .../common/events/AbstractEventDriver.java | 6 +++++- .../server/DefaultMappedWebSocketCreator.java | 4 ++-- .../websocket/server/WebSocketUpgradeFilter.java | 3 ++- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/WebSocketServerContainerInitializer.java b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/WebSocketServerContainerInitializer.java index 8545b931db7..82c35278cf5 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/WebSocketServerContainerInitializer.java +++ b/jetty-websocket/javax-websocket-server-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/server/deploy/WebSocketServerContainerInitializer.java @@ -37,7 +37,6 @@ import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.MappedByteBufferPool; import org.eclipse.jetty.server.handler.ContextHandler; import org.eclipse.jetty.servlet.ServletContextHandler; -import org.eclipse.jetty.util.DecoratedObjectFactory; import org.eclipse.jetty.util.TypeUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; @@ -201,20 +200,8 @@ public class WebSocketServerContainerInitializer implements ServletContainerInit // Create the Jetty ServerContainer implementation ServerContainer jettyContainer = configureContext(jettyContext); - context.addListener(new ContextDestroyListener()); //make sure context is cleaned up when the context stops + context.addListener(new ContextDestroyListener()); // make sure context is cleaned up when the context stops - // Establish the DecoratedObjectFactory thread local - // for various ServiceLoader initiated components to use. - DecoratedObjectFactory instantiator = (DecoratedObjectFactory)context.getAttribute(DecoratedObjectFactory.ATTR); - if (instantiator == null) - { - LOG.info("Using WebSocket local DecoratedObjectFactory - none found in ServletContext"); - instantiator = new DecoratedObjectFactory(); - } - - // Store a reference to the ServerContainer per javax.websocket spec 1.0 final section 6.4 Programmatic Server Deployment - context.setAttribute(javax.websocket.server.ServerContainer.class.getName(),jettyContainer); - if (c.isEmpty()) { if (LOG.isDebugEnabled()) diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java index afb8b4871ff..66ea1c3cdd5 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java @@ -221,9 +221,13 @@ public abstract class AbstractEventDriver extends AbstractLifeCycle implements I public void openSession(WebSocketSession session) { if (LOG.isDebugEnabled()) - LOG.debug("openSession({})",session); + { + LOG.debug("openSession({})", session); + LOG.debug("objectFactory={}", session.getContainerScope().getObjectFactory()); + } this.session = session; this.session.getContainerScope().getObjectFactory().decorate(this.websocket); + try { this.onConnect(); diff --git a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/DefaultMappedWebSocketCreator.java b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/DefaultMappedWebSocketCreator.java index fcbd5419703..62648c59797 100644 --- a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/DefaultMappedWebSocketCreator.java +++ b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/DefaultMappedWebSocketCreator.java @@ -18,8 +18,8 @@ package org.eclipse.jetty.websocket.server; -import org.eclipse.jetty.websocket.server.pathmap.PathMappings; -import org.eclipse.jetty.websocket.server.pathmap.PathSpec; +import org.eclipse.jetty.http.pathmap.PathMappings; +import org.eclipse.jetty.http.pathmap.PathSpec; import org.eclipse.jetty.websocket.servlet.WebSocketCreator; public class DefaultMappedWebSocketCreator implements MappedWebSocketCreator diff --git a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeFilter.java b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeFilter.java index 80a33027be8..7fbc5e4d214 100644 --- a/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeFilter.java +++ b/jetty-websocket/websocket-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeFilter.java @@ -292,6 +292,7 @@ public class WebSocketUpgradeFilter extends ContainerLifeCycle implements Filter { factory = new WebSocketServerFactory(policy, bufferPool); } + factory.init(config.getServletContext()); addBean(factory, true); // TODO: Policy isn't from attributes @@ -327,7 +328,7 @@ public class WebSocketUpgradeFilter extends ContainerLifeCycle implements Filter key = WebSocketUpgradeFilter.class.getName(); } - setToAttribute(ctx, key); + setToAttribute(config.getServletContext(), key); factory.start(); }