WebSocketClientFactory (Jetty :: Aggregate :: All core Jetty 7.6.8.v20121106 API)
Date: 2012-11-06

org.eclipse.jetty.websocket

## Class WebSocketClientFactory

- java.lang.Object
- - org.eclipse.jetty.util.component.AbstractLifeCycle
  - - org.eclipse.jetty.util.component.AggregateLifeCycle
    - - org.eclipse.jetty.websocket.WebSocketClientFactory

- All Implemented Interfaces:
    Destroyable, Dumpable, LifeCycle

      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.

  See Also:
    `WebSocketClient`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `AbstractLifeCycle.AbstractLifeCycleListener`

    - ### Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

      `LifeCycle.Listener`

  - ### Field Summary

    - ### Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `_listeners, FAILED, RUNNING, STARTED, STARTING, STOPPED, STOPPING`

  - ### Constructor Summary

    Constructors
    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.

  - ### Method Summary

    Methods
    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)`

    - ### Methods inherited from class org.eclipse.jetty.util.component.AggregateLifeCycle

      `addBean, addBean, contains, destroy, doStart, dump, dump, dump, dump, dump, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, unmanage`

    - ### Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

      `addLifeCycleListener, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### WebSocketClientFactory

          public WebSocketClientFactory()

      Creates a WebSocketClientFactory with the default configuration.

    - #### WebSocketClientFactory

          public WebSocketClientFactory(ThreadPool threadPool)

      Creates a WebSocketClientFactory with the given ThreadPool and the default configuration.

      Parameters:
        `threadPool` - the ThreadPool instance to use

    - #### WebSocketClientFactory

          public WebSocketClientFactory(ThreadPool threadPool,
                                MaskGen maskGen)

      Creates a WebSocketClientFactory with the given ThreadPool and the given MaskGen.

      Parameters:
        `threadPool` - the ThreadPool instance to use
        `maskGen` - the MaskGen instance to use

    - #### WebSocketClientFactory

          public WebSocketClientFactory(ThreadPool threadPool,
                                MaskGen maskGen,
                                int bufferSize)

      Creates a WebSocketClientFactory with the specified configuration.

      Parameters:
        `threadPool` - the ThreadPool instance to use
        `maskGen` - the mask generator to use
        `bufferSize` - the read buffer size

  - ### Method Detail

    - #### getSslContextFactory

          public SslContextFactory getSslContextFactory()

      Returns:
        the SslContextFactory used to configure SSL parameters

    - #### getSelectorManager

          public SelectorManager getSelectorManager()

      Get the selectorManager. Used to configure the manager.
      Returns:
        The `SelectorManager` instance.

    - #### getThreadPool

          public ThreadPool getThreadPool()

      Get the ThreadPool. Used to set/query the thread pool configuration.
      Returns:
        The `ThreadPool`

    - #### getMaskGen

          public MaskGen getMaskGen()

      Returns:
        the shared mask generator, or null if no shared mask generator is used
      See Also:
        `WebSocketClient.getMaskGen()`

    - #### setMaskGen

          public void setMaskGen(MaskGen maskGen)

      Parameters:
        `maskGen` - the shared mask generator, or null if no shared mask generator is used
      See Also:
        `WebSocketClient.setMaskGen(MaskGen)`

    - #### setBufferSize

          public void setBufferSize(int bufferSize)

      Parameters:
        `bufferSize` - the read buffer size
      See Also:
        `getBufferSize()`

    - #### getBufferSize

          public int getBufferSize()

      Returns:
        the read buffer size

    - #### doStop

          protected void doStop()
                         throws Exception

      Description copied from class: `AggregateLifeCycle`
      Stop the joined lifecycle beans in the reverse order they were added.
      Overrides:
        `doStop` in class `AggregateLifeCycle`
      Throws:
        `Exception`
      See Also:
        `AbstractLifeCycle.doStart()`

    - #### newWebSocketClient

          public WebSocketClient newWebSocketClient()

      Creates and returns a new instance of a `WebSocketClient`, configured with this WebSocketClientFactory instance.

      Returns:
        a new `WebSocketClient` instance

    - #### newSslEngine

          protected SSLEngine newSslEngine(SocketChannel channel)
                                    throws IOException

      Throws:
        `IOException`

    - #### addConnection

          protected boolean addConnection(WebSocketConnection connection)

    - #### removeConnection

          protected boolean removeConnection(WebSocketConnection connection)

    - #### closeConnections

          protected void closeConnections()

Copyright © 1995-2012 Mort Bay Consulting. All Rights Reserved.