diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/ClientContainer.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/ClientContainer.java index 1a1c6181e42..46d1f4878a6 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/ClientContainer.java +++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/ClientContainer.java @@ -183,8 +183,12 @@ public class ClientContainer extends ContainerLifeCycle implements WebSocketCont */ public ClientContainer(WebSocketClient client) { + Objects.requireNonNull(client, "WebSocketClient"); this.scopeDelegate = client; this.client = client; + addBean(this.client); + this.client.setEventDriverFactory(new JsrEventDriverFactory(scopeDelegate)); + this.client.setSessionFactory(new JsrSessionFactory(this)); this.internalClient = false; this.endpointClientMetadataCache = new ConcurrentHashMap<>(); diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java index 553baf457f6..28e9cb58f2c 100644 --- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java +++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClient.java @@ -76,10 +76,10 @@ public class WebSocketClient extends ContainerLifeCycle implements WebSocketCont // WebSocket Specifics private final WebSocketPolicy policy; private final WebSocketExtensionFactory extensionRegistry; - private final EventDriverFactory eventDriverFactory; - private final SessionFactory sessionFactory; private final SessionTracker sessionTracker = new SessionTracker(); private final List sessionListeners = new ArrayList<>(); + private EventDriverFactory eventDriverFactory; + private SessionFactory sessionFactory; // defaults to true for backwards compatibility private boolean stopAtShutdown = true; @@ -379,6 +379,16 @@ public class WebSocketClient extends ContainerLifeCycle implements WebSocketCont return wsReq.sendAsync(); } + public void setEventDriverFactory(EventDriverFactory eventDriverFactory) + { + this.eventDriverFactory = eventDriverFactory; + } + + public void setSessionFactory(SessionFactory sessionFactory) + { + this.sessionFactory = sessionFactory; + } + @Override protected void doStart() throws Exception {