From 23ecb2e29cd7538a5d29aa95ef3fc30839a146c8 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 10 Jul 2012 13:44:09 -0700 Subject: [PATCH] Fixing build --- .../websocket/client/WebSocketClientFactory.java | 11 +++++++++++ .../client/io/WebSocketClientSelectorManager.java | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClientFactory.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClientFactory.java index e6eabffc48e..f01dcf8d812 100644 --- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClientFactory.java +++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/WebSocketClientFactory.java @@ -6,6 +6,8 @@ import java.util.Collections; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.Executor; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.SelectorManager; @@ -24,6 +26,10 @@ import org.eclipse.jetty.websocket.driver.WebSocketEventDriver; public class WebSocketClientFactory extends AggregateLifeCycle { private static final Logger LOG = Log.getLogger(WebSocketClientFactory.class); + /** + * Have the factory maintain 1 and only 1 scheduler. All connections share this scheduler. + */ + private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(); private final Queue connections = new ConcurrentLinkedQueue<>(); private final ByteBufferPool bufferPool = new StandardByteBufferPool(); private final Executor executor; @@ -112,6 +118,11 @@ public class WebSocketClientFactory extends AggregateLifeCycle return policy; } + public ScheduledExecutorService getScheduler() + { + return scheduler; + } + public SelectorManager getSelector() { return selector; diff --git a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java index f55fcabdc4c..abacfcf2aea 100644 --- a/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java +++ b/jetty-websocket/websocket-client/src/main/java/org/eclipse/jetty/websocket/client/io/WebSocketClientSelectorManager.java @@ -4,6 +4,7 @@ import java.io.IOException; import java.nio.channels.SelectionKey; import java.nio.channels.SocketChannel; import java.util.concurrent.Executor; +import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.atomic.AtomicReference; import javax.net.ssl.SSLEngine; @@ -79,8 +80,9 @@ public class WebSocketClientSelectorManager extends SelectorManager Executor executor = factory.getExecutor(); WebSocketPolicy policy = factory.getPolicy(); ByteBufferPool bufferPool = factory.getBufferPool(); + ScheduledExecutorService scheduler = factory.getScheduler(); - WebSocketAsyncConnection connection = new WebSocketAsyncConnection(endPoint,executor,policy,bufferPool); + WebSocketAsyncConnection connection = new WebSocketAsyncConnection(endPoint,executor,scheduler,policy,bufferPool); endPoint.setAsyncConnection(connection); connection.getParser().addListener(websocket);