Class WsServerContainer
- java.lang.Object
- 
- org.apache.tomcat.websocket.WsWebSocketContainer
- 
- org.apache.tomcat.websocket.server.WsServerContainer
 
 
- 
- All Implemented Interfaces:
- ServerContainer,- WebSocketContainer,- BackgroundProcess
 
 public class WsServerContainer extends WsWebSocketContainer implements ServerContainer 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.
- 
- 
Method SummaryAll Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddEndpoint(java.lang.Class<?> pojo)Provides the equivalent ofaddEndpoint(ServerEndpointConfig)for publishing plain old java objects (POJOs) that have been annotated as WebSocket endpoints.voidaddEndpoint(ServerEndpointConfig sec)Published the provided endpoint implementation at the specified path with the specified configuration.voidcloseAuthenticatedSession(java.lang.String httpSessionId)voiddoUpgrade(HttpServletRequest request, HttpServletResponse response, ServerEndpointConfig sec, java.util.Map<java.lang.String,java.lang.String> pathParams)Deprecated.This method will be removed in Apache Tomcat 10.1 onwards.org.apache.tomcat.websocket.server.WsMappingResultfindMapping(java.lang.String path)protected InstanceManagergetInstanceManager(java.lang.ClassLoader classLoader)Overridden to make it visible to other classes in this package.protected WsWriteTimeoutgetTimeout()booleanisEnforceNoAddAfterHandshake()Deprecated.protected voidregisterSession(java.lang.Object key, WsSession wsSession)Overridden to make it visible to other classes in this package.voidsetEnforceNoAddAfterHandshake(boolean enforceNoAddAfterHandshake)Deprecated.protected voidunregisterSession(java.lang.Object key, WsSession wsSession)Overridden to make it visible to other classes in this package.voidupgradeHttpToWebSocket(java.lang.Object httpServletRequest, java.lang.Object httpServletResponse, ServerEndpointConfig sec, java.util.Map<java.lang.String,java.lang.String> pathParameters)Upgrade the HTTP connection represented by theHttpServletRequestandHttpServletResponseto the WebSocket protocol and establish a WebSocket connection as per the providedServerEndpointConfig.- 
Methods inherited from class org.apache.tomcat.websocket.WsWebSocketContainerbackgroundProcess, connectToServer, connectToServer, connectToServer, connectToServer, destroy, getDefaultAsyncSendTimeout, getDefaultMaxBinaryMessageBufferSize, getDefaultMaxSessionIdleTimeout, getDefaultMaxTextMessageBufferSize, getInstalledExtensions, getProcessPeriod, setAsyncSendTimeout, setDefaultMaxBinaryMessageBufferSize, setDefaultMaxSessionIdleTimeout, setDefaultMaxTextMessageBufferSize, setInstanceManager, setProcessPeriod
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface javax.websocket.WebSocketContainerconnectToServer, connectToServer, connectToServer, connectToServer, getDefaultAsyncSendTimeout, getDefaultMaxBinaryMessageBufferSize, getDefaultMaxSessionIdleTimeout, getDefaultMaxTextMessageBufferSize, getInstalledExtensions, setAsyncSendTimeout, setDefaultMaxBinaryMessageBufferSize, setDefaultMaxSessionIdleTimeout, setDefaultMaxTextMessageBufferSize
 
- 
 
- 
- 
- 
Method Detail- 
addEndpointpublic void addEndpoint(ServerEndpointConfig sec) throws DeploymentException Published the provided endpoint implementation at the specified path with the specified configuration.WsServerContainer(ServletContext)must be called before calling this method.- Specified by:
- addEndpointin interface- ServerContainer
- Parameters:
- sec- The configuration to use when creating endpoint instances
- Throws:
- DeploymentException- if the endpoint cannot be published as requested
 
 - 
addEndpointpublic void addEndpoint(java.lang.Class<?> pojo) throws DeploymentExceptionProvides the equivalent ofaddEndpoint(ServerEndpointConfig)for publishing plain old java objects (POJOs) that have been annotated as WebSocket endpoints.- Specified by:
- addEndpointin interface- ServerContainer
- Parameters:
- pojo- The annotated POJO
- Throws:
- DeploymentException
 
 - 
doUpgrade@Deprecated public void doUpgrade(HttpServletRequest request, HttpServletResponse response, ServerEndpointConfig sec, java.util.Map<java.lang.String,java.lang.String> pathParams) throws ServletException, java.io.IOException Deprecated.This method will be removed in Apache Tomcat 10.1 onwards. It has been replaced byupgradeHttpToWebSocket(Object, Object, ServerEndpointConfig, Map)Until the WebSocket specification provides such a mechanism, this Tomcat proprietary method is provided to enable applications to programmatically determine whether or not to upgrade an individual request to WebSocket.Note: This method is not used by Tomcat but is used directly by third-party code and must not be removed. - Parameters:
- request- The request object to be upgraded
- response- The response object to be populated with the result of the upgrade
- sec- The server endpoint to use to process the upgrade request
- pathParams- The path parameters associated with the upgrade request
- Throws:
- ServletException- If a configuration error prevents the upgrade from taking place
- java.io.IOException- If an I/O error occurs during the upgrade process
 
 - 
upgradeHttpToWebSocketpublic void upgradeHttpToWebSocket(java.lang.Object httpServletRequest, java.lang.Object httpServletResponse, ServerEndpointConfig sec, java.util.Map<java.lang.String,java.lang.String> pathParameters) throws java.io.IOException, DeploymentExceptionUpgrade the HTTP connection represented by theHttpServletRequestandHttpServletResponseto the WebSocket protocol and establish a WebSocket connection as per the providedServerEndpointConfig.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.This method will be part of the Jakarta WebSocket API from version 2.1 - Parameters:
- httpServletRequest- The- HttpServletRequestto be processed as a WebSocket handshake as per section 4.0 of RFC 6455.
- httpServletResponse- The- HttpServletResponseto be used when processing the- httpServletRequestas a WebSocket handshake as per section 4.0 of RFC 6455.
- sec- The server endpoint configuration to use to configure the WebSocket endpoint
- pathParameters- 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.
- Throws:
- java.lang.IllegalStateException- if the provided request does not meet the requirements of the WebSocket handshake
- java.lang.UnsupportedOperationException- if the WebSocket implementation is not deployed as part of a Jakarta Servlet container
- java.io.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
 
 - 
findMappingpublic org.apache.tomcat.websocket.server.WsMappingResult findMapping(java.lang.String path) 
 - 
isEnforceNoAddAfterHandshake@Deprecated public boolean isEnforceNoAddAfterHandshake() Deprecated.
 - 
setEnforceNoAddAfterHandshake@Deprecated public void setEnforceNoAddAfterHandshake(boolean enforceNoAddAfterHandshake) Deprecated.
 - 
getTimeoutprotected WsWriteTimeout getTimeout() 
 - 
getInstanceManagerprotected InstanceManager getInstanceManager(java.lang.ClassLoader classLoader) Overridden to make it visible to other classes in this package.- Overrides:
- getInstanceManagerin class- WsWebSocketContainer
 
 - 
registerSessionprotected void registerSession(java.lang.Object key, WsSession wsSession)Overridden to make it visible to other classes in this package.- Overrides:
- registerSessionin class- WsWebSocketContainer
 
 - 
unregisterSessionprotected void unregisterSession(java.lang.Object key, WsSession wsSession)Overridden to make it visible to other classes in this package.- Overrides:
- unregisterSessionin class- WsWebSocketContainer
 
 - 
closeAuthenticatedSessionpublic void closeAuthenticatedSession(java.lang.String httpSessionId) 
 
- 
 
-