public class WebSocketClientFactory extends AggregateLifeCycle
WebSocketClientFactory contains the common components needed by multiple WebSocketClient
instances
(for example, a ThreadPool
, a NIO selector
, etc).
WebSocketClients with different configurations should share the same factory to avoid to waste resources.
If a ThreadPool or MaskGen is passed in the constructor, then it is not added with AggregateLifeCycle.addBean(Object)
,
so it's lifecycle must be controlled externally.
WebSocketClient
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING
Constructor and Description |
---|
WebSocketClientFactory()
Creates a WebSocketClientFactory with the default configuration.
|
WebSocketClientFactory(ThreadPool threadPool)
Creates a WebSocketClientFactory with the given ThreadPool and the default configuration.
|
WebSocketClientFactory(ThreadPool threadPool,
MaskGen maskGen)
Creates a WebSocketClientFactory with the given ThreadPool and the given MaskGen.
|
WebSocketClientFactory(ThreadPool threadPool,
MaskGen maskGen,
int bufferSize)
Creates a WebSocketClientFactory with the specified configuration.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
addConnection(WebSocketConnection connection) |
protected void |
closeConnections() |
protected void |
doStop()
Stop the joined lifecycle beans in the reverse order they were added.
|
int |
getBufferSize() |
MaskGen |
getMaskGen() |
SelectorManager |
getSelectorManager()
Get the selectorManager.
|
SslContextFactory |
getSslContextFactory() |
ThreadPool |
getThreadPool()
Get the ThreadPool.
|
protected SSLEngine |
newSslEngine(SocketChannel channel) |
WebSocketClient |
newWebSocketClient()
Creates and returns a new instance of a
WebSocketClient , configured with this
WebSocketClientFactory instance. |
protected boolean |
removeConnection(WebSocketConnection connection) |
void |
setBufferSize(int bufferSize) |
void |
setMaskGen(MaskGen maskGen) |
addBean, addBean, contains, destroy, doStart, dump, dump, dump, dump, dump, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, unmanage
addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
public WebSocketClientFactory()
Creates a WebSocketClientFactory with the default configuration.
public WebSocketClientFactory(ThreadPool threadPool)
Creates a WebSocketClientFactory with the given ThreadPool and the default configuration.
threadPool
- the ThreadPool instance to usepublic WebSocketClientFactory(ThreadPool threadPool, MaskGen maskGen)
Creates a WebSocketClientFactory with the given ThreadPool and the given MaskGen.
threadPool
- the ThreadPool instance to usemaskGen
- the MaskGen instance to usepublic WebSocketClientFactory(ThreadPool threadPool, MaskGen maskGen, int bufferSize)
Creates a WebSocketClientFactory with the specified configuration.
threadPool
- the ThreadPool instance to usemaskGen
- the mask generator to usebufferSize
- the read buffer sizepublic SslContextFactory getSslContextFactory()
public SelectorManager getSelectorManager()
SelectorManager
instance.public ThreadPool getThreadPool()
ThreadPool
public MaskGen getMaskGen()
WebSocketClient.getMaskGen()
public void setMaskGen(MaskGen maskGen)
maskGen
- the shared mask generator, or null if no shared mask generator is usedWebSocketClient.setMaskGen(MaskGen)
public void setBufferSize(int bufferSize)
bufferSize
- the read buffer sizegetBufferSize()
public int getBufferSize()
protected void doStop() throws Exception
AggregateLifeCycle
doStop
in class AggregateLifeCycle
Exception
AbstractLifeCycle.doStart()
public WebSocketClient newWebSocketClient()
Creates and returns a new instance of a WebSocketClient
, configured with this
WebSocketClientFactory instance.
WebSocketClient
instanceprotected SSLEngine newSslEngine(SocketChannel channel) throws IOException
IOException
protected boolean addConnection(WebSocketConnection connection)
protected boolean removeConnection(WebSocketConnection connection)
protected void closeConnections()
Copyright © 1995-2013 Mort Bay Consulting. All Rights Reserved.