Class ClientContainer

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.websocket.jsr356.ClientContainer
All Implemented Interfaces:
javax.websocket.WebSocketContainer, org.eclipse.jetty.util.component.Container, org.eclipse.jetty.util.component.Destroyable, org.eclipse.jetty.util.component.Dumpable, org.eclipse.jetty.util.component.Dumpable.DumpableContainer, org.eclipse.jetty.util.component.LifeCycle, WebSocketContainerScope
Direct Known Subclasses:
ServerContainer

@ManagedObject("JSR356 Client Container") public class ClientContainer extends org.eclipse.jetty.util.component.ContainerLifeCycle implements javax.websocket.WebSocketContainer, WebSocketContainerScope
Container for Client use of the javax.websocket API.

This should be specific to a JVM if run in a standalone mode. or specific to a WebAppContext if running on the Jetty server.

  • Field Details

    • LOG

      private static final org.eclipse.jetty.util.log.Logger LOG
    • scopeDelegate

      private final WebSocketContainerScope scopeDelegate
      The delegated Container Scope
    • decoderFactory

      private final DecoderFactory decoderFactory
      Tracking all primitive decoders for the container
    • encoderFactory

      private final EncoderFactory encoderFactory
      Tracking all primitive encoders for the container
    • client

      private final WebSocketClient client
      The jetty websocket client in use for this container
    • internalClient

      private final boolean internalClient
    • endpointClientMetadataCache

      private final Map<Class<?>,EndpointMetadata> endpointClientMetadataCache
      Tracking for all declared Client endpoints
    • sessionTracker

      private final JsrSessionTracker sessionTracker
  • Constructor Details

    • ClientContainer

      public ClientContainer()
      This is the entry point for ContainerProvider.getWebSocketContainer()
    • ClientContainer

      public ClientContainer(org.eclipse.jetty.client.HttpClient httpClient)
      Create a WebSocketContainer using the supplied HttpClient for environments where you want to configure SSL/TLS or Proxy behaviors.
      Parameters:
      httpClient - the HttpClient instance to use
    • ClientContainer

      public ClientContainer(WebSocketContainerScope scope)
      This is the entry point for ServerContainer, via ServletContext.getAttribute(ServerContainer.class.getName())
      Parameters:
      scope - the scope of the ServerContainer
    • ClientContainer

      protected ClientContainer(WebSocketContainerScope scope, org.eclipse.jetty.client.HttpClient httpClient)
      This is the entry point for ServerContainer, via ServletContext.getAttribute(ServerContainer.class.getName())
      Parameters:
      scope - the scope of the ServerContainer
      httpClient - the HttpClient instance to use
    • ClientContainer

      public ClientContainer(WebSocketClient client)
      Build a ClientContainer with a specific WebSocketClient in mind.
      Parameters:
      client - the WebSocketClient to use.
  • Method Details

    • connect

      private javax.websocket.Session connect(EndpointInstance instance, URI path) throws IOException
      Throws:
      IOException
    • connectToServer

      public javax.websocket.Session connectToServer(Class<? extends javax.websocket.Endpoint> endpointClass, javax.websocket.ClientEndpointConfig config, URI path) throws javax.websocket.DeploymentException, IOException
      Specified by:
      connectToServer in interface javax.websocket.WebSocketContainer
      Throws:
      javax.websocket.DeploymentException
      IOException
    • connectToServer

      public javax.websocket.Session connectToServer(Class<?> annotatedEndpointClass, URI path) throws javax.websocket.DeploymentException, IOException
      Specified by:
      connectToServer in interface javax.websocket.WebSocketContainer
      Throws:
      javax.websocket.DeploymentException
      IOException
    • connectToServer

      public javax.websocket.Session connectToServer(javax.websocket.Endpoint endpoint, javax.websocket.ClientEndpointConfig config, URI path) throws javax.websocket.DeploymentException, IOException
      Specified by:
      connectToServer in interface javax.websocket.WebSocketContainer
      Throws:
      javax.websocket.DeploymentException
      IOException
    • connectToServer

      public javax.websocket.Session connectToServer(Object endpoint, URI path) throws javax.websocket.DeploymentException, IOException
      Specified by:
      connectToServer in interface javax.websocket.WebSocketContainer
      Throws:
      javax.websocket.DeploymentException
      IOException
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class org.eclipse.jetty.util.component.ContainerLifeCycle
      Throws:
      Exception
    • doStop

      protected void doStop() throws Exception
      Overrides:
      doStop in class org.eclipse.jetty.util.component.ContainerLifeCycle
      Throws:
      Exception
    • getBufferPool

      public org.eclipse.jetty.io.ByteBufferPool getBufferPool()
      Description copied from interface: WebSocketContainerScope
      The configured Container Buffer Pool.
      Specified by:
      getBufferPool in interface WebSocketContainerScope
      Returns:
      the buffer pool (never null)
    • getClient

      public WebSocketClient getClient()
    • getClassLoader

      public ClassLoader getClassLoader()
      Description copied from interface: WebSocketContainerScope

      The ClassLoader used to load classes for the WebSocketSession.

      By default this will be the ContextClassLoader at the time this method is called. However this will be overridden by the WebSocketClient to use the ContextClassLoader at the time it was created, this is because the client uses its own ThreadPool so the WebSocketSessions may be created when the ContextClassLoader is not set.

      Specified by:
      getClassLoader in interface WebSocketContainerScope
      Returns:
      the classloader.
    • getClientEndpointMetadata

      public EndpointMetadata getClientEndpointMetadata(Class<?> endpoint, javax.websocket.EndpointConfig config)
    • getDecoderFactory

      public DecoderFactory getDecoderFactory()
    • getDefaultAsyncSendTimeout

      public long getDefaultAsyncSendTimeout()
      Specified by:
      getDefaultAsyncSendTimeout in interface javax.websocket.WebSocketContainer
    • getDefaultMaxBinaryMessageBufferSize

      public int getDefaultMaxBinaryMessageBufferSize()
      Specified by:
      getDefaultMaxBinaryMessageBufferSize in interface javax.websocket.WebSocketContainer
    • getDefaultMaxSessionIdleTimeout

      public long getDefaultMaxSessionIdleTimeout()
      Specified by:
      getDefaultMaxSessionIdleTimeout in interface javax.websocket.WebSocketContainer
    • getDefaultMaxTextMessageBufferSize

      public int getDefaultMaxTextMessageBufferSize()
      Specified by:
      getDefaultMaxTextMessageBufferSize in interface javax.websocket.WebSocketContainer
    • getEncoderFactory

      public EncoderFactory getEncoderFactory()
    • getExecutor

      public Executor getExecutor()
      Description copied from interface: WebSocketContainerScope
      Executor in use by the container.
      Specified by:
      getExecutor in interface WebSocketContainerScope
      Returns:
      the Executor in use by the container.
    • getInstalledExtensions

      public Set<javax.websocket.Extension> getInstalledExtensions()
      Specified by:
      getInstalledExtensions in interface javax.websocket.WebSocketContainer
    • getObjectFactory

      public org.eclipse.jetty.util.DecoratedObjectFactory getObjectFactory()
      Description copied from interface: WebSocketContainerScope
      Object Factory used to create objects.
      Specified by:
      getObjectFactory in interface WebSocketContainerScope
      Returns:
      Object Factory used to create instances of objects.
    • getOpenSessions

      public Set<javax.websocket.Session> getOpenSessions()
      Used in Session.getOpenSessions()
      Returns:
      the set of open sessions
    • getPolicy

      public WebSocketPolicy getPolicy()
      Description copied from interface: WebSocketContainerScope
      The policy the container is running on.
      Specified by:
      getPolicy in interface WebSocketContainerScope
      Returns:
      the websocket policy
    • getSslContextFactory

      public org.eclipse.jetty.util.ssl.SslContextFactory getSslContextFactory()
      Description copied from interface: WebSocketContainerScope
      The SslContextFactory in use by the container.
      Specified by:
      getSslContextFactory in interface WebSocketContainerScope
      Returns:
      the SslContextFactory in use by the container (can be null if no SSL context is defined)
    • addSessionListener

      public void addSessionListener(WebSocketSessionListener listener)
      Specified by:
      addSessionListener in interface WebSocketContainerScope
    • removeSessionListener

      public void removeSessionListener(WebSocketSessionListener listener)
      Specified by:
      removeSessionListener in interface WebSocketContainerScope
    • getSessionListeners

      public Collection<WebSocketSessionListener> getSessionListeners()
      Specified by:
      getSessionListeners in interface WebSocketContainerScope
    • newClientEndpointInstance

      private EndpointInstance newClientEndpointInstance(Class<?> endpointClass, javax.websocket.ClientEndpointConfig config)
    • newClientEndpointInstance

      public EndpointInstance newClientEndpointInstance(Object endpoint, javax.websocket.ClientEndpointConfig config)
    • setAsyncSendTimeout

      public void setAsyncSendTimeout(long ms)
      Specified by:
      setAsyncSendTimeout in interface javax.websocket.WebSocketContainer
    • setDefaultMaxBinaryMessageBufferSize

      public void setDefaultMaxBinaryMessageBufferSize(int max)
      Specified by:
      setDefaultMaxBinaryMessageBufferSize in interface javax.websocket.WebSocketContainer
    • setDefaultMaxSessionIdleTimeout

      public void setDefaultMaxSessionIdleTimeout(long ms)
      Specified by:
      setDefaultMaxSessionIdleTimeout in interface javax.websocket.WebSocketContainer
    • setDefaultMaxTextMessageBufferSize

      public void setDefaultMaxTextMessageBufferSize(int max)
      Specified by:
      setDefaultMaxTextMessageBufferSize in interface javax.websocket.WebSocketContainer