Class WebSocketContainerHolder

java.lang.Object
io.micronaut.servlet.websocket.WebSocketContainerHolder

@Internal @Singleton public final class WebSocketContainerHolder extends Object
The servlet container's Jakarta WebSocket container, for opening client connections.

Every servlet container's ServerContainer is also a client container, so the one the server side upgrades through is what the client side connects through. The container initializers register it as they create it. In a WAR deployment, where the container ran its own initializer, it is read from the servlet context; with no server at all it is whatever ContainerProvider finds, which is the container's own client implementation.

Since:
6.2.0
Author:
graemerocher
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The servlet context attribute under which a container publishes its ServerContainer.
  • Constructor Summary

    Constructors
    Constructor
    Description
    WebSocketContainerHolder(@Nullable jakarta.servlet.ServletContext servletContext)
    Default constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    jakarta.websocket.WebSocketContainer
    get()
    The container client connections are opened through.
    void
    register(jakarta.websocket.WebSocketContainer webSocketContainer)
    Registers the container the server created.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SERVER_CONTAINER_ATTRIBUTE

      public static final String SERVER_CONTAINER_ATTRIBUTE
      The servlet context attribute under which a container publishes its ServerContainer.
      See Also:
  • Constructor Details

    • WebSocketContainerHolder

      public WebSocketContainerHolder(@Nullable jakarta.servlet.ServletContext servletContext)
      Default constructor.
      Parameters:
      servletContext - The servlet context, a bean only when deployed as a web archive
  • Method Details

    • register

      public void register(jakarta.websocket.WebSocketContainer webSocketContainer)
      Registers the container the server created.
      Parameters:
      webSocketContainer - The container
    • get

      public jakarta.websocket.WebSocketContainer get()
      The container client connections are opened through.
      Returns:
      The container
      Throws:
      io.micronaut.websocket.exceptions.WebSocketException - if no Jakarta WebSocket implementation is available