Top Description Methods
jakarta.websocket.server

public Interface ServerContainer

extends WebSocketContainer
Known Direct Implementers
org.apache.tomcat.websocket.server.WsServerContainer
Imports
java.io.IOException, java.util.Map, jakarta.websocket.DeploymentException, .WebSocketContainer

Provides the ability to deploy endpoints programmatically.

Method Summary

Modifier and TypeMethod and Description
public void
addEndpoint(Class<?> clazz)

public void
public void
upgradeHttpToWebSocket(Object
The HttpServletRequest to be processed as a WebSocket handshake as per section 4.0 of RFC 6455.
httpServletRequest
,
Object
The HttpServletResponse to be used when processing the httpServletRequest as a WebSocket handshake as per section 4.0 of RFC 6455.
httpServletResponse
,
ServerEndpointConfig
The server endpoint configuration to use to configure the WebSocket endpoint
sec
,
Map<String, String>
Provides a mapping of path parameter names and values, if any, to be used for the WebSocket connection established by the call to this method. If no such mapping is defined, an empty Map must be passed.
pathParameters
)

Upgrade the HTTP connection represented by the HttpServletRequest and HttpServletResponse to the WebSocket protocol and establish a WebSocket connection as per the provided ServerEndpointConfig.

Inherited from jakarta.websocket.WebSocketContainer:
connectToServerconnectToServerconnectToServerconnectToServergetDefaultAsyncSendTimeoutgetDefaultMaxBinaryMessageBufferSizegetDefaultMaxSessionIdleTimeoutgetDefaultMaxTextMessageBufferSizegetInstalledExtensionssetAsyncSendTimeoutsetDefaultMaxBinaryMessageBufferSizesetDefaultMaxSessionIdleTimeoutsetDefaultMaxTextMessageBufferSize

Method Detail

addEndpointback to summary
public void addEndpoint(Class<?> clazz) throws DeploymentException
addEndpointback to summary
public void addEndpoint(ServerEndpointConfig sec) throws DeploymentException
upgradeHttpToWebSocketback to summary
public void upgradeHttpToWebSocket(Object httpServletRequest, Object httpServletResponse, ServerEndpointConfig sec, Map<String, String> pathParameters) throws IOException, DeploymentException

Upgrade the HTTP connection represented by the HttpServletRequest and HttpServletResponse to the WebSocket protocol and establish a WebSocket connection as per the provided ServerEndpointConfig.

This method is primarily intended to be used by frameworks that implement the front-controller pattern. It does not deploy the provided endpoint.

If the WebSocket implementation is not deployed as part of a Jakarta Servlet container, this method will throw an UnsupportedOperationException.

Parameters
httpServletRequest:Object

The HttpServletRequest to be processed as a WebSocket handshake as per section 4.0 of RFC 6455.

httpServletResponse:Object

The HttpServletResponse to be used when processing the httpServletRequest as a WebSocket handshake as per section 4.0 of RFC 6455.

sec:ServerEndpointConfig

The server endpoint configuration to use to configure the WebSocket endpoint

pathParameters:Map<String, String>

Provides a mapping of path parameter names and values, if any, to be used for the WebSocket connection established by the call to this method. If no such mapping is defined, an empty Map must be passed.

Exceptions
IOException:
if an I/O error occurs during the establishment of a WebSocket connection
DeploymentException:
if a configuration error prevents the establishment of a WebSocket connection
IllegalStateException:
if the provided request does not meet the requirements of the WebSocket handshake
UnsupportedOperationException:
if the WebSocket implementation is not deployed as part of a Jakarta Servlet container
Since
WebSocket 2.0