Skip to content

Package: DefaultClientEndpointConfig

DefaultClientEndpointConfig

nameinstructionbranchcomplexitylinemethod
DefaultClientEndpointConfig(List, List, List, List, SSLContext, ClientEndpointConfig.Configurator)
M: 30 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
getConfigurator()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getDecoders()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getEncoders()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getExtensions()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getPreferredSubprotocols()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getSSLContext()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getUserProperties()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 2018, 2021 Oracle and/or its affiliates and others.
3: * All rights reserved.
4: *
5: * This program and the accompanying materials are made available under the
6: * terms of the Eclipse Public License v. 2.0, which is available at
7: * http://www.eclipse.org/legal/epl-2.0.
8: *
9: * This Source Code may also be made available under the following Secondary
10: * Licenses when the conditions for such availability set forth in the
11: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
12: * version 2 with the GNU Classpath Exception, which is available at
13: * https://www.gnu.org/software/classpath/license.html.
14: *
15: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16: */
17:
18: package jakarta.websocket;
19:
20: import java.util.Collections;
21: import java.util.HashMap;
22: import java.util.List;
23: import java.util.Map;
24:
25: import javax.net.ssl.SSLContext;
26:
27: /**
28: * The DefaultClientEndpointConfig is a concrete implementation of a client configuration.
29: *
30: * @author dannycoward
31: */
32: final class DefaultClientEndpointConfig implements ClientEndpointConfig {
33: private List<String> preferredSubprotocols;
34: private List<Extension> extensions;
35: private List<Class<? extends Encoder>> encoders;
36: private List<Class<? extends Decoder>> decoders;
37: private SSLContext sslContext;
38: private Map<String, Object> userProperties = new HashMap<>();
39: private ClientEndpointConfig.Configurator clientEndpointConfigurator;
40:
41: DefaultClientEndpointConfig(List<String> preferredSubprotocols, List<Extension> extensions,
42: List<Class<? extends Encoder>> encoders, List<Class<? extends Decoder>> decoders,
43: SSLContext sslContext, ClientEndpointConfig.Configurator clientEndpointConfigurator) {
44: this.preferredSubprotocols = Collections.unmodifiableList(preferredSubprotocols);
45: this.extensions = Collections.unmodifiableList(extensions);
46: this.encoders = Collections.unmodifiableList(encoders);
47: this.decoders = Collections.unmodifiableList(decoders);
48: this.sslContext = sslContext;
49: this.clientEndpointConfigurator = clientEndpointConfigurator;
50: }
51:
52: /**
53: * Return the protocols, in order of preference, favorite first, that this client would like to use for its
54: * sessions.
55: *
56: * @return the preferred subprotocols.
57: */
58: @Override
59: public List<String> getPreferredSubprotocols() {
60: return this.preferredSubprotocols;
61: }
62:
63: /**
64: * Return the extensions, in order of preference, favorite first, that this client would like to use for its
65: * sessions.
66: *
67: * @return the (unmodifiable) extension list.
68: */
69: @Override
70: public List<Extension> getExtensions() {
71: return this.extensions;
72: }
73:
74: /**
75: * Return the (unmodifiable) list of encoders this client will use.
76: *
77: * @return the encoder list.
78: */
79: @Override
80: public List<Class<? extends Encoder>> getEncoders() {
81: return this.encoders;
82: }
83:
84: /**
85: * Return the (unmodifiable) list of decoders this client will use.
86: *
87: * @return the decoders to use.
88: */
89: @Override
90: public List<Class<? extends Decoder>> getDecoders() {
91: return this.decoders;
92: }
93:
94: /**
95: * SSLContext to use to secure WebSocket (wss) connections or {@code null} for insecure Websocket (ws) connections.
96: * If there is an existing connection to the server that uses the same SSLContext and that connection supports
97: * multiplexing WebSocket connections then the container may choose to re-use that connection rather than creating a
98: * new one. Containers may provide container specific configuration to control this behaviour.
99: */
100: @Override
101: public SSLContext getSSLContext() {
102: return this.sslContext;
103: }
104:
105: /**
106: * Editable map of user properties.
107: */
108: @Override
109: public final Map<String, Object> getUserProperties() {
110: return this.userProperties;
111: }
112:
113: @Override
114: public ClientEndpointConfig.Configurator getConfigurator() {
115: return this.clientEndpointConfigurator;
116: }
117:
118: }