Class ServerEndpointConfig.Configurator
java.lang.Object
jakarta.websocket.server.ServerEndpointConfig.Configurator
- Enclosing interface:
ServerEndpointConfig
Provides a mechanism to customize the WebSocket handshake for server endpoints.
Applications may subclass this to inspect or modify the handshake.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancheckOrigin(String originHeaderValue) Checks whether the given Origin header value is acceptable.Return the platform default configurator.<T> TgetEndpointInstance(Class<T> clazz) Creates a new instance of the endpoint class.getNegotiatedExtensions(List<Extension> installed, List<Extension> requested) Determines the extensions to use for the WebSocket connection by comparing the installed and requested extensions.getNegotiatedSubprotocol(List<String> supported, List<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.
-
Constructor Details
-
Configurator
public Configurator()Creates a new instance of the Configurator.
-
-
Method Details
-
getContainerDefaultConfigurator
Return the platform default configurator.- Returns:
- the platform default configurator
- Since:
- WebSocket 2.1
-
getNegotiatedSubprotocol
Determines the sub-protocol to use for the WebSocket connection by comparing the supported and requested sub-protocols.- 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 List<Extension> getNegotiatedExtensions(List<Extension> installed, List<Extension> requested) Determines the extensions to use for the WebSocket connection by comparing the installed and requested extensions.- 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
Checks whether the given Origin header value is acceptable. The default implementation always returnstrue.- Parameters:
originHeaderValue- The Origin header value to check- Returns:
trueif the origin is acceptable
-
modifyHandshake
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) Provides the opportunity to modify the handshake before it is completed. This method is called after the sub-protocol and extensions have been negotiated.- Parameters:
sec- The server endpoint configurationrequest- The handshake requestresponse- The handshake response
-
getEndpointInstance
Creates a new instance of the endpoint class.- Type Parameters:
T- The type of the endpoint class- Parameters:
clazz- The endpoint class- Returns:
- A new instance of the endpoint
- Throws:
InstantiationException- If the endpoint cannot be instantiated
-