Class ServerWebSocketContainer

java.lang.Object
io.undertow.websockets.jsr.ServerWebSocketContainer
All Implemented Interfaces:
jakarta.websocket.server.ServerContainer, jakarta.websocket.WebSocketContainer, Closeable, AutoCloseable

public class ServerWebSocketContainer extends Object implements jakarta.websocket.server.ServerContainer, Closeable
ServerContainer implementation which allows to deploy endpoints for a server.
Author:
Norman Maurer
  • Field Details

  • Constructor Details

  • Method Details

    • getDefaultAsyncSendTimeout

      public long getDefaultAsyncSendTimeout()
      Specified by:
      getDefaultAsyncSendTimeout in interface jakarta.websocket.WebSocketContainer
    • setAsyncSendTimeout

      public void setAsyncSendTimeout(long defaultAsyncSendTimeout)
      Specified by:
      setAsyncSendTimeout in interface jakarta.websocket.WebSocketContainer
    • connectToServer

      public jakarta.websocket.Session connectToServer(Object annotatedEndpointInstance, io.undertow.websockets.client.WebSocketClient.ConnectionBuilder connectionBuilder) throws jakarta.websocket.DeploymentException, IOException
      Throws:
      jakarta.websocket.DeploymentException
      IOException
    • connectToServer

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

      public jakarta.websocket.Session connectToServer(Class<?> aClass, io.undertow.websockets.client.WebSocketClient.ConnectionBuilder connectionBuilder) throws jakarta.websocket.DeploymentException, IOException
      Throws:
      jakarta.websocket.DeploymentException
      IOException
    • connectToServer

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

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

      public jakarta.websocket.Session connectToServer(jakarta.websocket.Endpoint endpointInstance, jakarta.websocket.ClientEndpointConfig config, io.undertow.websockets.client.WebSocketClient.ConnectionBuilder connectionBuilder) throws jakarta.websocket.DeploymentException, IOException
      Throws:
      jakarta.websocket.DeploymentException
      IOException
    • connectToServer

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

      public void upgradeHttpToWebSocket(Object req, Object res, jakarta.websocket.server.ServerEndpointConfig sec, Map<String,String> pathParameters) throws IOException, jakarta.websocket.DeploymentException
      Specified by:
      upgradeHttpToWebSocket in interface jakarta.websocket.server.ServerContainer
      Throws:
      IOException
      jakarta.websocket.DeploymentException
    • doUpgrade

      public void doUpgrade(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, jakarta.websocket.server.ServerEndpointConfig sec, Map<String,String> pathParams) throws jakarta.servlet.ServletException, IOException
      Throws:
      jakarta.servlet.ServletException
      IOException
    • getDefaultMaxSessionIdleTimeout

      public long getDefaultMaxSessionIdleTimeout()
      Specified by:
      getDefaultMaxSessionIdleTimeout in interface jakarta.websocket.WebSocketContainer
    • setDefaultMaxSessionIdleTimeout

      public void setDefaultMaxSessionIdleTimeout(long timeout)
      Specified by:
      setDefaultMaxSessionIdleTimeout in interface jakarta.websocket.WebSocketContainer
    • getDefaultMaxBinaryMessageBufferSize

      public int getDefaultMaxBinaryMessageBufferSize()
      Specified by:
      getDefaultMaxBinaryMessageBufferSize in interface jakarta.websocket.WebSocketContainer
    • setDefaultMaxBinaryMessageBufferSize

      public void setDefaultMaxBinaryMessageBufferSize(int defaultMaxBinaryMessageBufferSize)
      Specified by:
      setDefaultMaxBinaryMessageBufferSize in interface jakarta.websocket.WebSocketContainer
    • getDefaultMaxTextMessageBufferSize

      public int getDefaultMaxTextMessageBufferSize()
      Specified by:
      getDefaultMaxTextMessageBufferSize in interface jakarta.websocket.WebSocketContainer
    • setDefaultMaxTextMessageBufferSize

      public void setDefaultMaxTextMessageBufferSize(int defaultMaxTextMessageBufferSize)
      Specified by:
      setDefaultMaxTextMessageBufferSize in interface jakarta.websocket.WebSocketContainer
    • getInstalledExtensions

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

      public void invokeEndpointMethod(Executor executor, Runnable invocation)
      Runs a web socket invocation, setting up the threads and dispatching a thread pool

      Unfortunately we need to dispatch to a thread pool, because there is a good chance that the endpoint will use blocking IO methods. We suspend recieves while this is in progress, to make sure that we do not have multiple methods invoked at once.

      Parameters:
      invocation - The task to run
    • invokeEndpointMethod

      public void invokeEndpointMethod(Runnable invocation)
      Directly invokes an endpoint method, without dispatching to an executor
      Parameters:
      invocation - The invocation
    • addEndpoint

      public void addEndpoint(Class<?> endpoint) throws jakarta.websocket.DeploymentException
      Specified by:
      addEndpoint in interface jakarta.websocket.server.ServerContainer
      Throws:
      jakarta.websocket.DeploymentException
    • addEndpoint

      public void addEndpoint(jakarta.websocket.server.ServerEndpointConfig endpoint) throws jakarta.websocket.DeploymentException
      Specified by:
      addEndpoint in interface jakarta.websocket.server.ServerContainer
      Throws:
      jakarta.websocket.DeploymentException
    • validateDeployment

      public void validateDeployment()
    • deploymentComplete

      public void deploymentComplete()
    • getConfiguredServerEndpoints

      public List<ConfiguredServerEndpoint> getConfiguredServerEndpoints()
    • getContextToAddFilter

      public ServletContextImpl getContextToAddFilter()
    • setContextToAddFilter

      public void setContextToAddFilter(ServletContextImpl contextToAddFilter)
    • close

      public void close(int waitTime)
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • getBufferPool

      public io.undertow.connector.ByteBufferPool getBufferPool()
    • getXnioWorker

      public org.xnio.XnioWorker getXnioWorker()
    • pause

      public void pause(ServerWebSocketContainer.PauseListener listener)
      Pauses the container
      Parameters:
      listener -
    • resume

      public void resume()
      resumes a paused container
    • getWebSocketReconnectHandler

      public WebSocketReconnectHandler getWebSocketReconnectHandler()
    • isClosed

      public boolean isClosed()
    • isDispatchToWorker

      public boolean isDispatchToWorker()