Top Description Inners Fields Constructors Methods
org.apache.tomcat.websocket.server

public Class WsServerContainer

extends WsWebSocketContainer
implements ServerContainer
Class Inheritance
All Implemented Interfaces
jakarta.websocket.server.ServerContainer, jakarta.websocket.WebSocketContainer
Imports
java.io.IOException, java.util.Arrays, .Collections, .EnumSet, .Map, .Set, java.util.concurrent.ConcurrentHashMap, .ConcurrentSkipListMap, javax.naming.NamingException, jakarta.servlet.DispatcherType, .FilterRegistration, .ServletContext, .ServletException, jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, jakarta.websocket.CloseReason, .CloseReason.CloseCodes, .DeploymentException, .Encoder, jakarta.websocket.server.ServerContainer, .ServerEndpoint, .ServerEndpointConfig, .ServerEndpointConfig.Configurator, org.apache.tomcat.InstanceManager, org.apache.tomcat.util.res.StringManager, org.apache.tomcat.websocket.WsSession, .WsWebSocketContainer, org.apache.tomcat.websocket.pojo.PojoMethodMapping

Provides a per class loader (i.e. per web application) instance of a ServerContainer. Web application wide defaults may be configured by setting the following servlet context initialisation parameters to the desired values.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final CloseReason
private final Map<String, Set<WsSession>>
private final Map<String, WsServerContainer.ExactPathMatch>
private final Map<Integer, ConcurrentSkipListMap<String, WsServerContainer.TemplatePathMatch>>
private volatile boolean
private volatile boolean
private final ServletContext
private static final StringManager
private final WsWriteTimeout

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
addEndpoint(ServerEndpointConfig
The configuration to use when creating endpoint instances
sec
)

Implements jakarta.websocket.server.ServerContainer.addEndpoint.

Published the provided endpoint implementation at the specified path with the specified configuration.

pack-priv void
addEndpoint(ServerEndpointConfig sec, boolean fromAnnotatedPojo)

public void
addEndpoint(Class<?>
The annotated POJO
pojo
)

Implements jakarta.websocket.server.ServerContainer.addEndpoint.

Provides the equivalent of addEndpoint(ServerEndpointConfig) for publishing plain old java objects (POJOs) that have been annotated as WebSocket endpoints.

pack-priv void
addEndpoint(Class<?> pojo, boolean fromAnnotatedPojo)

pack-priv boolean
public void
pack-priv void
public WsMappingResult
protected InstanceManager
getInstanceManager(ClassLoader classLoader)

Overrides org.apache.tomcat.websocket.WsWebSocketContainer.getInstanceManager.

Overridden to make it visible to other classes in this package.

protected WsWriteTimeout
private void
registerAuthenticatedSession(WsSession wsSession, String httpSessionId)

protected void
registerSession(Object key, WsSession wsSession)

Overrides org.apache.tomcat.websocket.WsWebSocketContainer.registerSession.

Overridden to make it visible to other classes in this package.

private void
protected void
unregisterSession(Object key, WsSession wsSession)

Overrides org.apache.tomcat.websocket.WsWebSocketContainer.unregisterSession.

Overridden to make it visible to other classes in this package.

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
)

Implements jakarta.websocket.server.ServerContainer.upgradeHttpToWebSocket.

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

private static void
validateEncoders(Class<? extends Encoder>[] encoders, InstanceManager instanceManager)

Inherited from org.apache.tomcat.websocket.WsWebSocketContainer:
backgroundProcessconnectToServerconnectToServerconnectToServerconnectToServerdestroygetDefaultAsyncSendTimeoutgetDefaultMaxBinaryMessageBufferSizegetDefaultMaxSessionIdleTimeoutgetDefaultMaxTextMessageBufferSizegetInstalledExtensionsgetProcessPeriodsetAsyncSendTimeoutsetDefaultMaxBinaryMessageBufferSizesetDefaultMaxSessionIdleTimeoutsetDefaultMaxTextMessageBufferSizesetInstanceManagersetProcessPeriod

Field Detail

AUTHENTICATED_HTTP_SESSION_CLOSEDback to summary
private static final CloseReason AUTHENTICATED_HTTP_SESSION_CLOSED
authenticatedSessionsback to summary
private final Map<String, Set<WsSession>> authenticatedSessions
configExactMatchMapback to summary
private final Map<String, WsServerContainer.ExactPathMatch> configExactMatchMap
configTemplateMatchMapback to summary
private final Map<Integer, ConcurrentSkipListMap<String, WsServerContainer.TemplatePathMatch>> configTemplateMatchMap
deploymentFailedback to summary
private volatile boolean deploymentFailed
endpointsRegisteredback to summary
private volatile boolean endpointsRegistered
servletContextback to summary
private final ServletContext servletContext
smback to summary
private static final StringManager sm

Hides org.apache.tomcat.websocket.WsWebSocketContainer.sm.

wsWriteTimeoutback to summary
private final WsWriteTimeout wsWriteTimeout

Constructor Detail

WsServerContainerback to summary
pack-priv WsServerContainer(ServletContext servletContext)

Method Detail

addEndpointback to summary
public void addEndpoint(ServerEndpointConfig sec) throws DeploymentException

Implements jakarta.websocket.server.ServerContainer.addEndpoint.

Published the provided endpoint implementation at the specified path with the specified configuration. WsServerContainer(ServletContext) must be called before calling this method.

Parameters
sec:ServerEndpointConfig

The configuration to use when creating endpoint instances

Annotations
@Override
Exceptions
DeploymentException:
if the endpoint cannot be published as requested
addEndpointback to summary
pack-priv void addEndpoint(ServerEndpointConfig sec, boolean fromAnnotatedPojo) throws DeploymentException
addEndpointback to summary
public void addEndpoint(Class<?> pojo) throws DeploymentException

Implements jakarta.websocket.server.ServerContainer.addEndpoint.

Provides the equivalent of addEndpoint(ServerEndpointConfig) for publishing plain old java objects (POJOs) that have been annotated as WebSocket endpoints.

Parameters
pojo:Class<?>

The annotated POJO

Annotations
@Override
addEndpointback to summary
pack-priv void addEndpoint(Class<?> pojo, boolean fromAnnotatedPojo) throws DeploymentException
areEndpointsRegisteredback to summary
pack-priv boolean areEndpointsRegistered()
closeAuthenticatedSessionback to summary
public void closeAuthenticatedSession(String httpSessionId)
failDeploymentback to summary
pack-priv void failDeployment()
findMappingback to summary
public WsMappingResult findMapping(String path)
getInstanceManagerback to summary
protected InstanceManager getInstanceManager(ClassLoader classLoader)

Overrides org.apache.tomcat.websocket.WsWebSocketContainer.getInstanceManager.

Overridden to make it visible to other classes in this package.

Annotations
@Override
getTimeoutback to summary
protected WsWriteTimeout getTimeout()
registerAuthenticatedSessionback to summary
private void registerAuthenticatedSession(WsSession wsSession, String httpSessionId)
registerSessionback to summary
protected void registerSession(Object key, WsSession wsSession)

Overrides org.apache.tomcat.websocket.WsWebSocketContainer.registerSession.

Overridden to make it visible to other classes in this package.

Annotations
@Override
unregisterAuthenticatedSessionback to summary
private void unregisterAuthenticatedSession(WsSession wsSession, String httpSessionId)
unregisterSessionback to summary
protected void unregisterSession(Object key, WsSession wsSession)

Overrides org.apache.tomcat.websocket.WsWebSocketContainer.unregisterSession.

Overridden to make it visible to other classes in this package.

Annotations
@Override
upgradeHttpToWebSocketback to summary
public void upgradeHttpToWebSocket(Object httpServletRequest, Object httpServletResponse, ServerEndpointConfig sec, Map<String, String> pathParameters) throws IOException, DeploymentException

Implements jakarta.websocket.server.ServerContainer.upgradeHttpToWebSocket.

Doc from jakarta.websocket.server.ServerContainer.upgradeHttpToWebSocket.

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.

Annotations
@Override
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
validateEncodersback to summary
private static void validateEncoders(Class<? extends Encoder>[] encoders, InstanceManager instanceManager) throws DeploymentException
org.apache.tomcat.websocket.server back to summary

private Class WsServerContainer.ExactPathMatch

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.tomcat.websocket.server.WsServerContainer.ExactPathMatch

Field Summary

Modifier and TypeField and Description
private final ServerEndpointConfig
private final boolean

Constructor Summary

AccessConstructor and Description
pack-priv
ExactPathMatch(ServerEndpointConfig config, boolean fromAnnotatedPojo)

Method Summary

Modifier and TypeMethod and Description
public ServerEndpointConfig
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

configback to summary
private final ServerEndpointConfig config
fromAnnotatedPojoback to summary
private final boolean fromAnnotatedPojo

Constructor Detail

ExactPathMatchback to summary
pack-priv ExactPathMatch(ServerEndpointConfig config, boolean fromAnnotatedPojo)

Method Detail

getConfigback to summary
public ServerEndpointConfig getConfig()
isFromAnnotatedPojoback to summary
public boolean isFromAnnotatedPojo()
org.apache.tomcat.websocket.server back to summary

private Class WsServerContainer.TemplatePathMatch

extends Object
Class Inheritance
  • java.lang.Object
  • org.apache.tomcat.websocket.server.WsServerContainer.TemplatePathMatch

Field Summary

Modifier and TypeField and Description
private final ServerEndpointConfig
private final boolean
private final UriTemplate

Constructor Summary

AccessConstructor and Description
pack-priv
TemplatePathMatch(ServerEndpointConfig config, UriTemplate uriTemplate, boolean fromAnnotatedPojo)

Method Summary

Modifier and TypeMethod and Description
public ServerEndpointConfig
public UriTemplate
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

configback to summary
private final ServerEndpointConfig config
fromAnnotatedPojoback to summary
private final boolean fromAnnotatedPojo
uriTemplateback to summary
private final UriTemplate uriTemplate

Constructor Detail

TemplatePathMatchback to summary
pack-priv TemplatePathMatch(ServerEndpointConfig config, UriTemplate uriTemplate, boolean fromAnnotatedPojo)

Method Detail

getConfigback to summary
public ServerEndpointConfig getConfig()
getUriTemplateback to summary
public UriTemplate getUriTemplate()
isFromAnnotatedPojoback to summary
public boolean isFromAnnotatedPojo()