Top Description Fields Constructors Methods
org.eclipse.jetty.ee10.websocket.jakarta.server.config

public final Class ContainerDefaultConfigurator

extends Configurator
Class Inheritance
Imports
java.util.ArrayList, .List, .ServiceLoader, jakarta.websocket.Extension, .HandshakeResponse, jakarta.websocket.server.HandshakeRequest, .ServerEndpointConfig, .ServerEndpointConfig.Configurator, org.slf4j.Logger, .LoggerFactory

The "Container Default Configurator" per the JSR-356 spec.
See Also
ServiceLoader behavior of jakarta.websocket.server.ServerEndpointConfig.Configurator

Field Summary

Modifier and TypeField and Description
private static final Logger
private static final String

Constructor Summary

AccessConstructor and Description
public
ContainerDefaultConfigurator()

Default Constructor required, as jakarta.websocket.server.ServerEndpointConfig$Configurator.fetchContainerDefaultConfigurator() will be the one that instantiates this class in most cases.

Method Summary

Modifier and TypeMethod and Description
public boolean
checkOrigin(String
the value of the origin header passed by the client.
originHeaderValue
)

Overrides jakarta.websocket.server.ServerEndpointConfig.Configurator.checkOrigin.

Check the value of the Origin header (See Origin Header) the client passed during the opening handshake.

public <T> T
getEndpointInstance(Class<T>
the class of the endpoint
endpointClass
)

Overrides jakarta.websocket.server.ServerEndpointConfig.Configurator.getEndpointInstance.

This method is called by the container each time a new client connects to the logical endpoint this configurator configures.

public List<Extension>
getNegotiatedExtensions(List<Extension>
the installed extensions on the implementation.
installed
,
List<Extension>
the requested extensions, in the order they were requested by the client
requested
)

Overrides jakarta.websocket.server.ServerEndpointConfig.Configurator.getNegotiatedExtensions.

Return the ordered list of extensions that t server endpoint will support given the requested extension list passed in, the empty list if none.

public String
getNegotiatedSubprotocol(List<String>
the subprotocols supported by the server endpoint
supported
,
List<String>
the requested subprotocols from the client endpoint
requested
)

Overrides jakarta.websocket.server.ServerEndpointConfig.Configurator.getNegotiatedSubprotocol.

Return the subprotocol the server endpoint has chosen from the requested list supplied by a client who wishes to connect, or none if there wasn't one this server endpoint liked.

public void
modifyHandshake(ServerEndpointConfig
the configuration object involved in the handshake
sec
,
HandshakeRequest
the opening handshake request.
request
,
HandshakeResponse
the proposed opening handshake response
response
)

Overrides jakarta.websocket.server.ServerEndpointConfig.Configurator.modifyHandshake.

Called by the container after it has formulated a handshake response resulting from a well-formed handshake request.

Inherited from jakarta.websocket.server.ServerEndpointConfig.Configurator:
getContainerDefaultConfigurator

Field Detail

LOGback to summary
private static final Logger LOG
NO_SUBPROTOCOLback to summary
private static final String NO_SUBPROTOCOL

Constructor Detail

ContainerDefaultConfiguratorback to summary
public ContainerDefaultConfigurator()

Default Constructor required, as jakarta.websocket.server.ServerEndpointConfig$Configurator.fetchContainerDefaultConfigurator() will be the one that instantiates this class in most cases.

Method Detail

checkOriginback to summary
public boolean checkOrigin(String originHeaderValue)

Overrides jakarta.websocket.server.ServerEndpointConfig.Configurator.checkOrigin.

Doc from jakarta.websocket.server.ServerEndpointConfig.Configurator.checkOrigin.

Check the value of the Origin header (See Origin Header) the client passed during the opening handshake.

The platform default implementation of this method makes a check of the validity of the Origin header sent along with the opening handshake following the recommendation at: Sending the Server's Opening Handshake.

Parameters
originHeaderValue:String

the value of the origin header passed by the client.

Returns:boolean

whether the check passed or not

Annotations
@Override
getEndpointInstanceback to summary
public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException

Overrides jakarta.websocket.server.ServerEndpointConfig.Configurator.getEndpointInstance.

Doc from jakarta.websocket.server.ServerEndpointConfig.Configurator.getEndpointInstance.

This method is called by the container each time a new client connects to the logical endpoint this configurator configures. Developers may override this method to control instantiation of endpoint instances in order to customize the initialization of the endpoint instance, or manage them in some other way. If the developer overrides this method, services like dependency injection that are otherwise supported, for example, when the implementation is part of the Java EE platform may not be available. The platform default implementation of this method returns a new endpoint instance per call, thereby ensuring that there is one endpoint instance per client, the default deployment cardinality.

Parameters
<T>
the type of the endpoint
endpointClass:Class<T>

the class of the endpoint

Returns:T

an instance of the endpoint that will handle all interactions from a new client.

Annotations
@Override
Exceptions
InstantiationException:
if there was an error producing the endpoint instance.
getNegotiatedExtensionsback to summary
public List<Extension> getNegotiatedExtensions(List<Extension> installed, List<Extension> requested)

Overrides jakarta.websocket.server.ServerEndpointConfig.Configurator.getNegotiatedExtensions.

Doc from jakarta.websocket.server.ServerEndpointConfig.Configurator.getNegotiatedExtensions.

Return the ordered list of extensions that t server endpoint will support given the requested extension list passed in, the empty list if none. See Negotiating Extensions

The default platform implementation of this method returns a list containing all of the requested extensions passed to this method that it supports, using the order in the requested extensions, the empty list if none.

Parameters
installed:List<Extension>

the installed extensions on the implementation.

requested:List<Extension>

the requested extensions, in the order they were requested by the client

Returns:List<Extension>

the list of extensions negotiated, the empty list if none.

Annotations
@Override
getNegotiatedSubprotocolback to summary
public String getNegotiatedSubprotocol(List<String> supported, List<String> requested)

Overrides jakarta.websocket.server.ServerEndpointConfig.Configurator.getNegotiatedSubprotocol.

Doc from jakarta.websocket.server.ServerEndpointConfig.Configurator.getNegotiatedSubprotocol.

Return the subprotocol the server endpoint has chosen from the requested list supplied by a client who wishes to connect, or none if there wasn't one this server endpoint liked. See Sending the Server's Opening Handshake. Subclasses may provide custom algorithms based on other factors.

The default platform implementation of this method returns the first subprotocol in the list sent by the client that the server supports, or the empty string if there isn't one.

Parameters
supported:List<String>

the subprotocols supported by the server endpoint

requested:List<String>

the requested subprotocols from the client endpoint

Returns:String

the negotiated subprotocol or the empty string if there isn't one.

Annotations
@Override
modifyHandshakeback to summary
public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response)

Overrides jakarta.websocket.server.ServerEndpointConfig.Configurator.modifyHandshake.

Doc from jakarta.websocket.server.ServerEndpointConfig.Configurator.modifyHandshake.

Called by the container after it has formulated a handshake response resulting from a well-formed handshake request. The container has already checked that this configuration has a matching URI, determined the validity of the origin using the checkOrigin method, and filled out the negotiated subprotocols and extensions based on this configuration. Custom configurations may override this method in order to inspect the request parameters and modify the handshake response that the server has formulated. and the URI checking also.

If the developer does not override this method, no further modification of the request and response are made by the implementation.

The user properties made available via ServerEndpointConfig#getUserProperties() must be a per WebSocket connection (i.e. per jakarta.websocket.Session) copy of the user properties. This copy, including any modifications made to the user properties during the execution of this method must be used to populate the initial contents of jakarta.websocket.Session#getUserProperties().

Parameters
sec:ServerEndpointConfig

the configuration object involved in the handshake

request:HandshakeRequest

the opening handshake request.

response:HandshakeResponse

the proposed opening handshake response

Annotations
@Override