Top Description Inners Methods
javax.websocket.server

public Interface ServerEndpointConfig

extends EndpointConfig
Known Direct Implementers
javax.websocket.server.DefaultServerEndpointConfig
Imports
java.util.ArrayList, .Collections, .List, .ServiceLoader, javax.websocket.Decoder, .Encoder, .EndpointConfig, .Extension, .HandshakeResponse

The ServerEndpointConfig is a special kind of endpoint configuration object that contains web socket configuration information specific only to server endpoints. For developers deploying programmatic endpoints, ServerEndpointConfig objects can be created using a ServerEndpointConfig.Builder. Certain configuration operations can be customized by providing a ServerEndpointConfig.Configurator
Author
dannycoward

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ServerEndpointConfig.Builder

The ServerEndpointConfig.Builder is a class used for creating ServerEndpointConfig.Builder objects for the purposes of deploying a server endpoint.

public static class
ServerEndpointConfig.Configurator

The ServerEndpointConfig.Configurator class may be extended by developers who want to provide custom configuration algorithms, such as intercepting the opening handshake, or providing arbitrary methods and algorithms that can be accessed from each endpoint instance configured with this configurator.

Method Summary

Modifier and TypeMethod and Description
public ServerEndpointConfig.Configurator

Returns:

the configurator in use.
getConfigurator
()

Return the ServerEndpointConfig.Configurator this configuration is using.

public Class<?>

Returns:

the class of the endpoint, annotated or programmatic.
getEndpointClass
()

Returns the Class of the endpoint this configuration is configuring.

public List<Extension>

Returns:

the list of extensions, the empty list if none.
getExtensions
()

Return the websocket extensions configured.

public String

Returns:

the relative path for this configuration.
getPath
()

Return the path for this endpoint configuration.

public List<String>

Returns:

the list of subprotocols, the empty list if none
getSubprotocols
()

Return the websocket subprotocols configured.

Inherited from javax.websocket.EndpointConfig:
getDecodersgetEncodersgetUserProperties

Method Detail

getConfiguratorback to summary
public ServerEndpointConfig.Configurator getConfigurator()

Return the ServerEndpointConfig.Configurator this configuration is using. If none was set by calling ServerEndpointConfig.Builder#configurator(javax.websocket.server.ServerEndpointConfig.Configurator) this methods returns the platform default configurator.

Returns:ServerEndpointConfig.Configurator

the configurator in use.

getEndpointClassback to summary
public Class<?> getEndpointClass()

Returns the Class of the endpoint this configuration is configuring. If the endpoint is an annotated endpoint, the value is the class of the Java class annotated with @ServerEndpoint. if the endpoint is a programmatic, the value is the class of the subclass of Endpoint.

Returns:Class<?>

the class of the endpoint, annotated or programmatic.

getExtensionsback to summary
public List<Extension> getExtensions()

Return the websocket extensions configured.

Returns:List<Extension>

the list of extensions, the empty list if none.

getPathback to summary
public String getPath()

Return the path for this endpoint configuration. The path is the URI or URI-template (level 1) relative to the websocket root of the server to which the endpoint using this configuration will be mapped. The path is always non-null and always begins with a leading "/".

Returns:String

the relative path for this configuration.

getSubprotocolsback to summary
public List<String> getSubprotocols()

Return the websocket subprotocols configured.

Returns:List<String>

the list of subprotocols, the empty list if none

javax.websocket.server back to summary

public final Class ServerEndpointConfig.Builder

extends Object
Class Inheritance

The ServerEndpointConfig.Builder is a class used for creating ServerEndpointConfig.Builder objects for the purposes of deploying a server endpoint.

Here are some examples:

Building a plain configuration for an endpoint with just a path.


ServerEndpointConfig config = ServerEndpointConfig.Builder.create(ProgrammaticEndpoint.class, "/foo").build();

Building a configuration with no subprotocols and a custom configurator.


ServerEndpointConfig config = ServerEndpointConfig.Builder.create(ProgrammaticEndpoint.class, "/bar")
        .subprotocols(subprotocols)
        .configurator(new MyServerConfigurator())
        .build();
Author
dannycoward

Field Summary

Modifier and TypeField and Description
private List<Class<? extends Decoder>>
private List<Class<? extends Encoder>>
private Class<?>
private List<Extension>
private String
private ServerEndpointConfig.Configurator
private List<String>

Constructor Summary

AccessConstructor and Description
private
private
Builder(Class<T> endpointClass, String path)

Method Summary

Modifier and TypeMethod and Description
public ServerEndpointConfig

Returns:

a new ServerEndpointConfig object.
build
()

Builds the configuration object using the current attributes that have been set on this builder object.

public ServerEndpointConfig.Builder

Returns:

this builder instance
configurator
(ServerEndpointConfig.Configurator
the configurator
serverEndpointConfigurator
)

Sets the custom configurator to use on the configuration object built by this builder.

public static ServerEndpointConfig.Builder

Returns:

a new instance of ServerEndpointConfig.Builder
create
(Class<?>
the class of the endpoint to configure
endpointClass
,
String
The URI or URI template where the endpoint will be deployed. A trailing "/" will be ignored and the path must begin with /.
path
)

Creates the builder with the mandatory information of the endpoint class (programmatic or annotated), the relative URI or URI-template to use, and with no subprotocols, extensions, encoders, decoders or custom configurator.

public ServerEndpointConfig.Builder

Returns:

this builder instance.
decoders
(List<Class<? extends Decoder>>
the decoders
decoders
)

Sets the decoder implementation classes to use in the configuration.

public ServerEndpointConfig.Builder

Returns:

this builder instance
encoders
(List<Class<? extends Encoder>>
the encoders
encoders
)

Sets the list of encoder implementation classes for this builder.

public ServerEndpointConfig.Builder

Returns:

this builder instance.
extensions
(List<Extension>
the extensions to use.
extensions
)

Sets the extensions to use in the configuration.

public ServerEndpointConfig.Builder

Returns:

this builder instance
subprotocols
(List<String>
the subprotocols.
subprotocols
)

Sets the subprotocols to use in the configuration.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

decodersback to summary
private List<Class<? extends Decoder>> decoders
encodersback to summary
private List<Class<? extends Encoder>> encoders
endpointClassback to summary
private Class<?> endpointClass
extensionsback to summary
private List<Extension> extensions
pathback to summary
private String path
serverEndpointConfiguratorback to summary
private ServerEndpointConfig.Configurator serverEndpointConfigurator
subprotocolsback to summary
private List<String> subprotocols

Constructor Detail

Builderback to summary
private Builder()
Builderback to summary
private Builder(Class<T> endpointClass, String path)

Method Detail

buildback to summary
public ServerEndpointConfig build()

Builds the configuration object using the current attributes that have been set on this builder object.

Returns:ServerEndpointConfig

a new ServerEndpointConfig object.

configuratorback to summary
public ServerEndpointConfig.Builder configurator(ServerEndpointConfig.Configurator serverEndpointConfigurator)

Sets the custom configurator to use on the configuration object built by this builder.

Parameters
serverEndpointConfigurator:ServerEndpointConfig.Configurator

the configurator

Returns:ServerEndpointConfig.Builder

this builder instance

createback to summary
public static ServerEndpointConfig.Builder create(Class<?> endpointClass, String path)

Creates the builder with the mandatory information of the endpoint class (programmatic or annotated), the relative URI or URI-template to use, and with no subprotocols, extensions, encoders, decoders or custom configurator.

Parameters
endpointClass:Class<?>

the class of the endpoint to configure

path:String

The URI or URI template where the endpoint will be deployed. A trailing "/" will be ignored and the path must begin with /.

Returns:ServerEndpointConfig.Builder

a new instance of ServerEndpointConfig.Builder

decodersback to summary
public ServerEndpointConfig.Builder decoders(List<Class<? extends Decoder>> decoders)

Sets the decoder implementation classes to use in the configuration.

Parameters
decoders:List<Class<? extends Decoder>>

the decoders

Returns:ServerEndpointConfig.Builder

this builder instance.

encodersback to summary
public ServerEndpointConfig.Builder encoders(List<Class<? extends Encoder>> encoders)

Sets the list of encoder implementation classes for this builder.

Parameters
encoders:List<Class<? extends Encoder>>

the encoders

Returns:ServerEndpointConfig.Builder

this builder instance

extensionsback to summary
public ServerEndpointConfig.Builder extensions(List<Extension> extensions)

Sets the extensions to use in the configuration.

Parameters
extensions:List<Extension>

the extensions to use.

Returns:ServerEndpointConfig.Builder

this builder instance.

subprotocolsback to summary
public ServerEndpointConfig.Builder subprotocols(List<String> subprotocols)

Sets the subprotocols to use in the configuration.

Parameters
subprotocols:List<String>

the subprotocols.

Returns:ServerEndpointConfig.Builder

this builder instance

javax.websocket.server back to summary

public Class ServerEndpointConfig.Configurator

extends Object
Class Inheritance

The ServerEndpointConfig.Configurator class may be extended by developers who want to provide custom configuration algorithms, such as intercepting the opening handshake, or providing arbitrary methods and algorithms that can be accessed from each endpoint instance configured with this configurator. The implementation must provide a platform default configurator loading using the service loader.

Field Summary

Modifier and TypeField and Description
private ServerEndpointConfig.Configurator

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

whether the check passed or not
checkOrigin
(String
the value of the origin header passed by the client.
originHeaderValue
)

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

pack-priv static ServerEndpointConfig.Configurator
pack-priv ServerEndpointConfig.Configurator
public <
the type of the endpoint
T
>
T

Returns:

an instance of the endpoint that will handle all interactions from a new client.
getEndpointInstance
(Class<T>
the class of the endpoint
endpointClass
)

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

public List<Extension>

Returns:

the list of extensions negotiated, the empty list if none.
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
)

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

Returns:

the negotiated subprotocol or the empty string if there isn't one.
getNegotiatedSubprotocol
(List<String>
the subprotocols supported by the server endpoint
supported
,
List<String>
the requested subprotocols from the client endpoint
requested
)

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
)

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

containerDefaultConfiguratorback to summary
private ServerEndpointConfig.Configurator containerDefaultConfigurator

Constructor Detail

Configuratorback to summary
public Configurator()

Method Detail

checkOriginback to summary
public boolean checkOrigin(String originHeaderValue)

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

fetchContainerDefaultConfiguratorback to summary
pack-priv static ServerEndpointConfig.Configurator fetchContainerDefaultConfigurator()
getContainerDefaultConfiguratorback to summary
pack-priv ServerEndpointConfig.Configurator getContainerDefaultConfigurator()
getEndpointInstanceback to summary
public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException

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.

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

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.

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

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.

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

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.

Parameters
sec:ServerEndpointConfig

the configuration object involved in the handshake

request:HandshakeRequest

the opening handshake request.

response:HandshakeResponse

the proposed opening handshake response