Class DefaultServerEndpointConfigurator
- java.lang.Object
-
- jakarta.websocket.server.ServerEndpointConfig.Configurator
-
- org.apache.tomcat.websocket.server.DefaultServerEndpointConfigurator
-
public class DefaultServerEndpointConfigurator extends ServerEndpointConfig.Configurator
Default implementation ofServerEndpointConfig.Configuratorfor WebSocket server endpoints.
-
-
Constructor Summary
Constructors Constructor Description DefaultServerEndpointConfigurator()Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckOrigin(java.lang.String originHeaderValue)Checks whether the given Origin header value is acceptable.<T> TgetEndpointInstance(java.lang.Class<T> clazz)Creates a new instance of the endpoint class.java.util.List<Extension>getNegotiatedExtensions(java.util.List<Extension> installed, java.util.List<Extension> requested)Determines the extensions to use for the WebSocket connection by comparing the installed and requested extensions.java.lang.StringgetNegotiatedSubprotocol(java.util.List<java.lang.String> supported, java.util.List<java.lang.String> requested)Determines the sub-protocol to use for the WebSocket connection by comparing the supported and requested sub-protocols.voidmodifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response)Provides the opportunity to modify the handshake before it is completed.-
Methods inherited from class jakarta.websocket.server.ServerEndpointConfig.Configurator
getContainerDefaultConfigurator
-
-
-
-
Method Detail
-
getEndpointInstance
public <T> T getEndpointInstance(java.lang.Class<T> clazz) throws java.lang.InstantiationExceptionDescription copied from class:jakarta.websocket.server.ServerEndpointConfig.ConfiguratorCreates a new instance of the endpoint class.- Overrides:
getEndpointInstancein classServerEndpointConfig.Configurator- Type Parameters:
T- The type of the endpoint class- Parameters:
clazz- The endpoint class- Returns:
- A new instance of the endpoint
- Throws:
java.lang.InstantiationException- If the endpoint cannot be instantiated
-
getNegotiatedSubprotocol
public java.lang.String getNegotiatedSubprotocol(java.util.List<java.lang.String> supported, java.util.List<java.lang.String> requested)Description copied from class:jakarta.websocket.server.ServerEndpointConfig.ConfiguratorDetermines the sub-protocol to use for the WebSocket connection by comparing the supported and requested sub-protocols.- Overrides:
getNegotiatedSubprotocolin classServerEndpointConfig.Configurator- Parameters:
supported- The list of sub-protocols supported by the endpointrequested- The list of sub-protocols requested by the client- Returns:
- The negotiated sub-protocol, or
nullif none matches
-
getNegotiatedExtensions
public java.util.List<Extension> getNegotiatedExtensions(java.util.List<Extension> installed, java.util.List<Extension> requested)
Description copied from class:jakarta.websocket.server.ServerEndpointConfig.ConfiguratorDetermines the extensions to use for the WebSocket connection by comparing the installed and requested extensions.- Overrides:
getNegotiatedExtensionsin classServerEndpointConfig.Configurator- Parameters:
installed- The list of extensions installed on the serverrequested- The list of extensions requested by the client- Returns:
- The list of negotiated extensions
-
checkOrigin
public boolean checkOrigin(java.lang.String originHeaderValue)
Description copied from class:jakarta.websocket.server.ServerEndpointConfig.ConfiguratorChecks whether the given Origin header value is acceptable. The default implementation always returnstrue.- Overrides:
checkOriginin classServerEndpointConfig.Configurator- Parameters:
originHeaderValue- The Origin header value to check- Returns:
trueif the origin is acceptable
-
modifyHandshake
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response)
Description copied from class:jakarta.websocket.server.ServerEndpointConfig.ConfiguratorProvides the opportunity to modify the handshake before it is completed. This method is called after the sub-protocol and extensions have been negotiated.- Overrides:
modifyHandshakein classServerEndpointConfig.Configurator- Parameters:
sec- The server endpoint configurationrequest- The handshake requestresponse- The handshake response
-
-