diff --git a/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/module-info.java b/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/module-info.java index 7a92d4c2687..fecc8564468 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/module-info.java +++ b/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/module-info.java @@ -13,11 +13,11 @@ module org.eclipse.jetty.websocket.server { - requires org.eclipse.jetty.server; requires org.eclipse.jetty.websocket.core.server; requires org.eclipse.jetty.websocket.common; requires org.slf4j; + requires transitive org.eclipse.jetty.server; requires transitive org.eclipse.jetty.websocket.api; exports org.eclipse.jetty.websocket.server; diff --git a/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/ServerWebSocketContainer.java b/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/ServerWebSocketContainer.java index 475f7910c9d..af3974cbac3 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/ServerWebSocketContainer.java +++ b/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/ServerWebSocketContainer.java @@ -31,7 +31,6 @@ import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.WebSocketContainer; import org.eclipse.jetty.websocket.api.WebSocketSessionListener; import org.eclipse.jetty.websocket.common.SessionTracker; -import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.exception.WebSocketException; import org.eclipse.jetty.websocket.core.server.FrameHandlerFactory; import org.eclipse.jetty.websocket.core.server.WebSocketMappings; @@ -58,7 +57,7 @@ public class ServerWebSocketContainer extends ContainerLifeCycle implements WebS private final FrameHandlerFactory factory; private InvocationType invocationType = InvocationType.BLOCKING; - public ServerWebSocketContainer(WebSocketMappings mappings) + ServerWebSocketContainer(WebSocketMappings mappings) { this.mappings = mappings; this.factory = new ServerFrameHandlerFactory(this, mappings.getWebSocketComponents()); @@ -66,15 +65,10 @@ public class ServerWebSocketContainer extends ContainerLifeCycle implements WebS addBean(sessionTracker); } - public WebSocketComponents getWebSocketComponents() - { - return mappings.getWebSocketComponents(); - } - @Override public Executor getExecutor() { - return getWebSocketComponents().getExecutor(); + return mappings.getWebSocketComponents().getExecutor(); } @Override diff --git a/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeHandler.java b/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeHandler.java index d1cc6dbd6ed..7a1ad5ced9b 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeHandler.java +++ b/jetty-core/jetty-websocket/jetty-websocket-jetty-server/src/main/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeHandler.java @@ -84,16 +84,20 @@ public class WebSocketUpgradeHandler extends Handler.Wrapper */ public static WebSocketUpgradeHandler from(Server server, ContextHandler context) { - WebSocketUpgradeHandler wsHandler = new WebSocketUpgradeHandler(WebSocketServerComponents.ensureWebSocketComponents(server, context)); - context.getContext().setAttribute(WebSocketContainer.class.getName(), wsHandler.container); + WebSocketComponents components = WebSocketServerComponents.ensureWebSocketComponents(server, context); + WebSocketMappings mappings = new WebSocketMappings(components); + ServerWebSocketContainer container = new ServerWebSocketContainer(mappings); + + WebSocketUpgradeHandler wsHandler = new WebSocketUpgradeHandler(container); + context.getContext().setAttribute(WebSocketContainer.class.getName(), wsHandler._container); return wsHandler; } - private final ServerWebSocketContainer container; + private final ServerWebSocketContainer _container; - private WebSocketUpgradeHandler(WebSocketComponents components) + private WebSocketUpgradeHandler(ServerWebSocketContainer container) { - this.container = new ServerWebSocketContainer(new WebSocketMappings(components)); + _container = container; addBean(container); } @@ -106,14 +110,14 @@ public class WebSocketUpgradeHandler extends Handler.Wrapper */ public WebSocketUpgradeHandler configure(Consumer configurator) { - configurator.accept(container); + configurator.accept(_container); return this; } @Override public boolean handle(Request request, Response response, Callback callback) throws Exception { - if (container.handle(request, response, callback)) + if (_container.handle(request, response, callback)) return true; return super.handle(request, response, callback); } @@ -125,6 +129,6 @@ public class WebSocketUpgradeHandler extends Handler.Wrapper return InvocationType.BLOCKING; Handler handler = getHandler(); InvocationType handlerInvocationType = handler == null ? InvocationType.NON_BLOCKING : handler.getInvocationType(); - return Invocable.combine(handlerInvocationType, container.getInvocationType()); + return Invocable.combine(handlerInvocationType, _container.getInvocationType()); } } diff --git a/jetty-core/jetty-websocket/jetty-websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/MaxOutgoingFramesTest.java b/jetty-core/jetty-websocket/jetty-websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/MaxOutgoingFramesTest.java index 0e55a17a793..f274cb02f67 100644 --- a/jetty-core/jetty-websocket/jetty-websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/MaxOutgoingFramesTest.java +++ b/jetty-core/jetty-websocket/jetty-websocket-jetty-tests/src/test/java/org/eclipse/jetty/websocket/tests/MaxOutgoingFramesTest.java @@ -27,7 +27,9 @@ import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.client.WebSocketClient; import org.eclipse.jetty.websocket.core.AbstractExtension; import org.eclipse.jetty.websocket.core.Frame; +import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; +import org.eclipse.jetty.websocket.core.server.WebSocketServerComponents; import org.eclipse.jetty.websocket.server.WebSocketUpgradeHandler; import org.eclipse.jetty.websocket.tests.util.FutureCallback; import org.junit.jupiter.api.AfterEach; @@ -66,7 +68,8 @@ public class MaxOutgoingFramesTest wsHandler.configure(container -> { container.addMapping("/", (rq, rs, cb) -> serverSocket); - container.getWebSocketComponents().getExtensionRegistry().register(BlockingOutgoingExtension.class.getName(), BlockingOutgoingExtension.class); + WebSocketComponents components = WebSocketServerComponents.getWebSocketComponents(context); + components.getExtensionRegistry().register(BlockingOutgoingExtension.class.getName(), BlockingOutgoingExtension.class); }); server.setHandler(context); diff --git a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/module-info.java b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/module-info.java index 2e3c1a1223b..9a9d5bb731a 100644 --- a/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/module-info.java +++ b/jetty-ee10/jetty-ee10-websocket/jetty-ee10-websocket-jetty-client/src/main/java/module-info.java @@ -16,6 +16,4 @@ module org.eclipse.jetty.ee10.websocket.jetty.client requires org.eclipse.jetty.websocket.client; requires static org.eclipse.jetty.ee10.webapp; - - exports org.eclipse.jetty.ee10.websocket.client.config; }