diff --git a/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxWebSocketClientContainer.java b/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxWebSocketClientContainer.java index 3fa4f70e064..c30ed03c5fe 100644 --- a/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxWebSocketClientContainer.java +++ b/jetty-websocket/javax-websocket-client/src/main/java/org/eclipse/jetty/websocket/javax/client/JavaxWebSocketClientContainer.java @@ -40,6 +40,7 @@ import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.util.DecoratedObjectFactory; import org.eclipse.jetty.util.annotation.ManagedObject; +import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; import org.eclipse.jetty.websocket.javax.common.ConfiguredEndpoint; @@ -64,34 +65,23 @@ public class JavaxWebSocketClientContainer extends JavaxWebSocketContainer imple public JavaxWebSocketClientContainer() { - this(() -> { - WebSocketCoreClient coreClient = new WebSocketCoreClient(); - coreClient.getHttpClient().setName("Javax-WebSocketClient@" + Integer.toHexString(coreClient.getHttpClient().hashCode())); - return coreClient; - }); + this(new WebSocketComponents(), null, null); } - public JavaxWebSocketClientContainer(Supplier coreClientFactory) + public JavaxWebSocketClientContainer(WebSocketComponents components, HttpClient httpClient, Executor executor) { - this((WebSocketCoreClient)null); - this.coreClientFactory = coreClientFactory; - this.addBean(coreClientFactory); - } - - public JavaxWebSocketClientContainer(WebSocketCoreClient coreClient) - { - super(); - - if (coreClient != null) - { - coreClient.setCustomizer(defaultCustomizer); - this.coreClient = coreClient; - this.addBean(coreClient); - } - - this.objectFactory = new DecoratedObjectFactory(); - this.extensionRegistry = new WebSocketExtensionRegistry(); + this.objectFactory = components.getObjectFactory(); + this.extensionRegistry = components.getExtensionRegistry(); this.frameHandlerFactory = new JavaxWebSocketClientFrameHandlerFactory(this); + + coreClientFactory = () -> + { + WebSocketCoreClient coreClient = new WebSocketCoreClient(httpClient, defaultCustomizer); + coreClient.getHttpClient().setName("Javax-WebSocketClient@" + Integer.toHexString(coreClient.getHttpClient().hashCode())); + if (executor != null && httpClient == null) + coreClient.getHttpClient().setExecutor(executor); + return coreClient; + }; } @Override @@ -116,12 +106,7 @@ public class JavaxWebSocketClientContainer extends JavaxWebSocketContainer imple if (coreClient == null) { coreClient = coreClientFactory.get(); - if (coreClient.isRunning()) - addBean(coreClient,false); - else - addManaged(coreClient); - - coreClient.setCustomizer(defaultCustomizer); + addManaged(coreClient); } return coreClient; diff --git a/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/JavaxWebSocketServerContainer.java b/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/JavaxWebSocketServerContainer.java index f8a874d8185..a43c6e16028 100644 --- a/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/JavaxWebSocketServerContainer.java +++ b/jetty-websocket/javax-websocket-server/src/main/java/org/eclipse/jetty/websocket/javax/server/JavaxWebSocketServerContainer.java @@ -44,7 +44,6 @@ import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.core.WebSocketComponents; import org.eclipse.jetty.websocket.core.WebSocketException; import org.eclipse.jetty.websocket.core.WebSocketExtensionRegistry; -import org.eclipse.jetty.websocket.core.client.WebSocketCoreClient; import org.eclipse.jetty.websocket.javax.client.JavaxWebSocketClientContainer; import org.eclipse.jetty.websocket.javax.server.internal.AnnotatedServerEndpointConfig; import org.eclipse.jetty.websocket.javax.server.internal.JavaxWebSocketCreator; @@ -138,13 +137,7 @@ public class JavaxWebSocketServerContainer */ public JavaxWebSocketServerContainer(WebSocketMapping webSocketMapping, WebSocketComponents webSocketComponents, HttpClient httpClient, Executor executor) { - super(() -> - { - WebSocketCoreClient client = new WebSocketCoreClient(httpClient); - if (executor != null && httpClient == null) - client.getHttpClient().setExecutor(executor); - return client; - }); + super(webSocketComponents, httpClient, executor); this.webSocketMapping = webSocketMapping; this.webSocketComponents = webSocketComponents; this.executor = executor; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java index 625a939410f..25bc7df3c79 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/WebSocketCoreClient.java @@ -71,16 +71,6 @@ public class WebSocketCoreClient extends ContainerLifeCycle implements FrameHand addBean(httpClient); } - public FrameHandler.ConfigurationCustomizer getCustomizer() - { - return customizer; - } - - public void setCustomizer(FrameHandler.ConfigurationCustomizer customizer) - { - this.customizer = customizer; - } - @Override public void customize(FrameHandler.CoreSession session) {