Class WebSocketContainerHolder
java.lang.Object
io.micronaut.servlet.websocket.WebSocketContainerHolder
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
FieldsModifier and TypeFieldDescriptionstatic final StringThe servlet context attribute under which a container publishes itsServerContainer. -
Constructor Summary
ConstructorsConstructorDescriptionWebSocketContainerHolder(@Nullable jakarta.servlet.ServletContext servletContext) Default constructor. -
Method Summary
-
Field Details
-
SERVER_CONTAINER_ATTRIBUTE
The servlet context attribute under which a container publishes itsServerContainer.- 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
-