Package jakarta.websocket
Class ClientEndpointConfig.Builder
- java.lang.Object
-
- jakarta.websocket.ClientEndpointConfig.Builder
-
- Enclosing interface:
- ClientEndpointConfig
public static final class ClientEndpointConfig.Builder extends java.lang.Object
The ClientEndpointConfig.Builder is a class used for creatingClientEndpointConfig
objects for the purposes of deploying a client endpoint. Here are some examples: Building a plain configuration with no encoders, decoders, subprotocols or extensions.ClientEndpointConfig cec = ClientEndpointConfig.Builder.create().build();
Building a configuration with no subprotocols and a custom configurator.ClientEndpointConfig customCec = ClientEndpointConfig.Builder.create() .preferredSubprotocols(mySubprotocols) .configurator(new MyClientConfigurator()) .build();
- Author:
- dannycoward
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ClientEndpointConfig
build()
Builds a configuration object using the attributes set on this builder.ClientEndpointConfig.Builder
configurator(ClientEndpointConfig.Configurator clientEndpointConfigurator)
Sets the configurator object for the configuration this builder will build.static ClientEndpointConfig.Builder
create()
Creates a new builder object with no subprotocols, extensions, encoders, decoders and anull
configurator.ClientEndpointConfig.Builder
decoders(java.util.List<java.lang.Class<? extends Decoder>> decoders)
Assign the list of decoder implementation classes the client will use.ClientEndpointConfig.Builder
encoders(java.util.List<java.lang.Class<? extends Encoder>> encoders)
Assign the list of encoder implementation classes the client will use.ClientEndpointConfig.Builder
extensions(java.util.List<Extension> extensions)
Set the extensions for the configuration this builder will build.ClientEndpointConfig.Builder
preferredSubprotocols(java.util.List<java.lang.String> preferredSubprotocols)
Set the preferred sub protocols for the configuration this builder will build.ClientEndpointConfig.Builder
sslContext(javax.net.ssl.SSLContext sslContext)
Assign the SSLContext to be used when connection to the WebSocket server.
-
-
-
Method Detail
-
create
public static ClientEndpointConfig.Builder create()
Creates a new builder object with no subprotocols, extensions, encoders, decoders and anull
configurator.- Returns:
- a new builder object.
-
build
public ClientEndpointConfig build()
Builds a configuration object using the attributes set on this builder.- Returns:
- a new configuration object.
-
configurator
public ClientEndpointConfig.Builder configurator(ClientEndpointConfig.Configurator clientEndpointConfigurator)
Sets the configurator object for the configuration this builder will build.- Parameters:
clientEndpointConfigurator
- the configurator- Returns:
- the builder instance
-
preferredSubprotocols
public ClientEndpointConfig.Builder preferredSubprotocols(java.util.List<java.lang.String> preferredSubprotocols)
Set the preferred sub protocols for the configuration this builder will build. The list is treated in order of preference, favorite first, that this client would like to use for its sessions.- Parameters:
preferredSubprotocols
- the preferred subprotocol names.- Returns:
- the builder instance
-
extensions
public ClientEndpointConfig.Builder extensions(java.util.List<Extension> extensions)
Set the extensions for the configuration this builder will build. The list is treated in order of preference, favorite first, that the client would like to use for its sessions.- Parameters:
extensions
- the extensions- Returns:
- the builder instance
-
encoders
public ClientEndpointConfig.Builder encoders(java.util.List<java.lang.Class<? extends Encoder>> encoders)
Assign the list of encoder implementation classes the client will use.- Parameters:
encoders
- the encoder implementation classes- Returns:
- the builder instance
-
decoders
public ClientEndpointConfig.Builder decoders(java.util.List<java.lang.Class<? extends Decoder>> decoders)
Assign the list of decoder implementation classes the client will use.- Parameters:
decoders
- the decoder implementation classes- Returns:
- this builder instance
-
sslContext
public ClientEndpointConfig.Builder sslContext(javax.net.ssl.SSLContext sslContext)
Assign the SSLContext to be used when connection to the WebSocket server. If there is an existing connection to the server that uses the same SSLContext and that connection supports multiplexing WebSocket connections then the container may choose to re-use that connection rather than creating a new one. Containers may provide container specific configuration to control this behaviour.- Parameters:
sslContext
- The SSLContext which must be initialised for secure WebSocket (wss) connections ornull
for insecure WebSocket (ws) connections.- Returns:
- this builder instance
-
-