diff --git a/jetty-websocket/jetty-websocket-client/pom.xml b/jetty-websocket/jetty-websocket-client/pom.xml index 3b922fbb0be..10ff69001a5 100644 --- a/jetty-websocket/jetty-websocket-client/pom.xml +++ b/jetty-websocket/jetty-websocket-client/pom.xml @@ -32,13 +32,6 @@ jetty-client ${project.version} - - org.eclipse.jetty - jetty-xml - ${project.version} - true - - org.eclipse.jetty jetty-server diff --git a/jetty-websocket/websocket-core/pom.xml b/jetty-websocket/websocket-core/pom.xml index 5a0ab6af971..cdbc67958d0 100644 --- a/jetty-websocket/websocket-core/pom.xml +++ b/jetty-websocket/websocket-core/pom.xml @@ -31,6 +31,12 @@ jetty-http ${project.version} + + org.eclipse.jetty + jetty-xml + ${project.version} + true + org.eclipse.jetty jetty-client diff --git a/jetty-websocket/websocket-core/src/main/java/module-info.java b/jetty-websocket/websocket-core/src/main/java/module-info.java index ffcaed7e690..93358f5eb3a 100644 --- a/jetty-websocket/websocket-core/src/main/java/module-info.java +++ b/jetty-websocket/websocket-core/src/main/java/module-info.java @@ -37,6 +37,7 @@ module org.eclipse.jetty.websocket.core requires org.eclipse.jetty.io; requires org.eclipse.jetty.http; requires org.eclipse.jetty.server; + requires static org.eclipse.jetty.xml; requires org.eclipse.jetty.util; uses Extension; diff --git a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DefaultHttpClientProvider.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/DefaultHttpClientProvider.java similarity index 81% rename from jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DefaultHttpClientProvider.java rename to jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/DefaultHttpClientProvider.java index 0a92db92be8..cad3935ef9e 100644 --- a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/DefaultHttpClientProvider.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/DefaultHttpClientProvider.java @@ -16,7 +16,7 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.client.impl; +package org.eclipse.jetty.websocket.core.client; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.util.ssl.SslContextFactory; @@ -26,13 +26,14 @@ class DefaultHttpClientProvider { public static HttpClient newHttpClient() { - SslContextFactory sslContextFactory = new SslContextFactory(); - HttpClient client = new HttpClient(sslContextFactory); + HttpClient client = new HttpClient(new SslContextFactory()); + client.getSslContextFactory().setEndpointIdentificationAlgorithm("HTTPS"); + QueuedThreadPool threadPool = new QueuedThreadPool(); - String name = "WebSocketClient@" + client.hashCode(); - threadPool.setName(name); + threadPool.setName("WebSocketClient@" + client.hashCode()); threadPool.setDaemon(true); client.setExecutor(threadPool); + return client; } } diff --git a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/HttpClientProvider.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/HttpClientProvider.java similarity index 93% rename from jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/HttpClientProvider.java rename to jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/HttpClientProvider.java index 4fc3e70b640..bf7089b1ea8 100644 --- a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/HttpClientProvider.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/HttpClientProvider.java @@ -16,13 +16,13 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.client.impl; +package org.eclipse.jetty.websocket.core.client; + +import java.lang.reflect.Method; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.util.log.Log; -import java.lang.reflect.Method; - public final class HttpClientProvider { public static HttpClient get() @@ -31,7 +31,7 @@ public final class HttpClientProvider { if (Class.forName("org.eclipse.jetty.xml.XmlConfiguration") != null) { - Class xmlClazz = Class.forName("org.eclipse.jetty.websocket.client.XmlBasedHttpClientProvider"); + Class xmlClazz = Class.forName("org.eclipse.jetty.websocket.core.client.XmlBasedHttpClientProvider"); Method getMethod = xmlClazz.getMethod("get"); Object ret = getMethod.invoke(null); if ((ret != null) && (ret instanceof HttpClient)) 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 3d247f3414f..0fbe0aa7199 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 @@ -27,7 +27,6 @@ import org.eclipse.jetty.util.DecoratedObjectFactory; import org.eclipse.jetty.util.component.ContainerLifeCycle; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; -import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.thread.ShutdownThread; import org.eclipse.jetty.websocket.core.ExtensionConfig; import org.eclipse.jetty.websocket.core.FrameHandler; @@ -61,12 +60,9 @@ public class WebSocketCoreClient extends ContainerLifeCycle implements FrameHand public WebSocketCoreClient(HttpClient httpClient, FrameHandler.Customizer customizer) { - if (httpClient==null) - { - httpClient = new HttpClient(new SslContextFactory()); - httpClient.getSslContextFactory().setEndpointIdentificationAlgorithm("HTTPS"); - httpClient.setName(String.format("%s@%x",getClass().getSimpleName(),hashCode())); - } + if (httpClient == null) + httpClient = HttpClientProvider.get(); + this.httpClient = httpClient; this.extensionRegistry = new WebSocketExtensionRegistry(); this.objectFactory = new DecoratedObjectFactory(); diff --git a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/XmlBasedHttpClientProvider.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/XmlBasedHttpClientProvider.java similarity index 97% rename from jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/XmlBasedHttpClientProvider.java rename to jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/XmlBasedHttpClientProvider.java index d168eb6d2d3..2be1cd253f4 100644 --- a/jetty-websocket/jetty-websocket-client/src/main/java/org/eclipse/jetty/websocket/client/impl/XmlBasedHttpClientProvider.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/core/client/XmlBasedHttpClientProvider.java @@ -16,15 +16,15 @@ // ======================================================================== // -package org.eclipse.jetty.websocket.client.impl; +package org.eclipse.jetty.websocket.core.client; + +import java.io.InputStream; +import java.net.URL; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.xml.XmlConfiguration; -import java.io.InputStream; -import java.net.URL; - class XmlBasedHttpClientProvider { public static HttpClient get()