Fixing build

This commit is contained in:
Joakim Erdfelt 2012-07-10 13:44:09 -07:00
parent 6f52b23735
commit 23ecb2e29c
2 changed files with 14 additions and 1 deletions

View File

@ -6,6 +6,8 @@ import java.util.Collections;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Executor; 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.ByteBufferPool;
import org.eclipse.jetty.io.SelectorManager; import org.eclipse.jetty.io.SelectorManager;
@ -24,6 +26,10 @@ import org.eclipse.jetty.websocket.driver.WebSocketEventDriver;
public class WebSocketClientFactory extends AggregateLifeCycle public class WebSocketClientFactory extends AggregateLifeCycle
{ {
private static final Logger LOG = Log.getLogger(WebSocketClientFactory.class); 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<WebSocketConnection> connections = new ConcurrentLinkedQueue<>(); private final Queue<WebSocketConnection> connections = new ConcurrentLinkedQueue<>();
private final ByteBufferPool bufferPool = new StandardByteBufferPool(); private final ByteBufferPool bufferPool = new StandardByteBufferPool();
private final Executor executor; private final Executor executor;
@ -112,6 +118,11 @@ public class WebSocketClientFactory extends AggregateLifeCycle
return policy; return policy;
} }
public ScheduledExecutorService getScheduler()
{
return scheduler;
}
public SelectorManager getSelector() public SelectorManager getSelector()
{ {
return selector; return selector;

View File

@ -4,6 +4,7 @@ import java.io.IOException;
import java.nio.channels.SelectionKey; import java.nio.channels.SelectionKey;
import java.nio.channels.SocketChannel; import java.nio.channels.SocketChannel;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import javax.net.ssl.SSLEngine; import javax.net.ssl.SSLEngine;
@ -79,8 +80,9 @@ public class WebSocketClientSelectorManager extends SelectorManager
Executor executor = factory.getExecutor(); Executor executor = factory.getExecutor();
WebSocketPolicy policy = factory.getPolicy(); WebSocketPolicy policy = factory.getPolicy();
ByteBufferPool bufferPool = factory.getBufferPool(); 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); endPoint.setAsyncConnection(connection);
connection.getParser().addListener(websocket); connection.getParser().addListener(websocket);