ServerEndpointConfig.Configurator (WebSocket 2.2 API Documentation - Apache Tomcat 11.0.23)
Description: declaration: package: jakarta.websocket.server, interface: ServerEndpointConfig, class: Configurator

# Class ServerEndpointConfig.Configurator

java.lang.Object
jakarta.websocket.server.ServerEndpointConfig.Configurator

Enclosing interface:
  `ServerEndpointConfig`

public static class ServerEndpointConfig.Configurator extends Object
Provides a mechanism to customize the WebSocket handshake for server endpoints. Applications may subclass this to inspect or modify the handshake.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Configurator()`
  Creates a new instance of the Configurator.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `checkOrigin(String originHeaderValue)`
  Checks whether the given Origin header value is acceptable.
  `ServerEndpointConfig.Configurator`
  `getContainerDefaultConfigurator()`
  Return the platform default configurator.
  `<T> T`
  `getEndpointInstance(Class<T> clazz)`
  Creates a new instance of the endpoint class.
  `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.
  `String`
  `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.
  `void`
  `modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response)`
  Provides the opportunity to modify the handshake before it is completed.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Configurator

    public Configurator()
    Creates a new instance of the Configurator.

- ## Method Details

  - ### getContainerDefaultConfigurator

    public ServerEndpointConfig.Configurator getContainerDefaultConfigurator()
    Return the platform default configurator.
    Returns:
      the platform default configurator
    Since:
      WebSocket 2.1

  - ### getNegotiatedSubprotocol

    public String 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.
    Parameters:
      `supported` - The list of sub-protocols supported by the endpoint
      `requested` - The list of sub-protocols requested by the client
    Returns:
      The negotiated sub-protocol, or `null` if 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 server
      `requested` - The list of extensions requested by the client
    Returns:
      The list of negotiated extensions

  - ### checkOrigin

    public boolean checkOrigin(String originHeaderValue)
    Checks whether the given Origin header value is acceptable. The default implementation always returns `true`.
    Parameters:
      `originHeaderValue` - The Origin header value to check
    Returns:
      `true` if 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 configuration
      `request` - The handshake request
      `response` - The handshake response

  - ### getEndpointInstance

    public <T> T getEndpointInstance(Class<T> clazz) throws InstantiationException
    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