Skip to content

Package: DefaultServerEndpointConfig

DefaultServerEndpointConfig

nameinstructionbranchcomplexitylinemethod
DefaultServerEndpointConfig(Class, String)
M: 14 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
DefaultServerEndpointConfig(Class, String, List, List, List, List, ServerEndpointConfig.Configurator)
M: 39 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 12 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%
getEndpointClass()
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%
getPath()
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%
getSubprotocols()
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, 2020 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.server;
19:
20: import java.util.Collections;
21: import java.util.HashMap;
22: import java.util.List;
23: import java.util.Map;
24: import jakarta.websocket.Decoder;
25: import jakarta.websocket.Encoder;
26: import jakarta.websocket.Endpoint;
27: import jakarta.websocket.Extension;
28:
29: /**
30: * The DefaultServerEndpointConfig is a concrete class that embodies all the configuration parameters for an endpoint
31: * that is to be published as a server endpoint. Developers may subclass this class in order to override the
32: * configuration behavior.
33: *
34: * @author dannycoward
35: */
36: final class DefaultServerEndpointConfig implements ServerEndpointConfig {
37: private String path;
38: private Class<?> endpointClass;
39: private List<String> subprotocols;
40: private List<Extension> extensions;
41: private List<Class<? extends Encoder>> encoders;
42: private List<Class<? extends Decoder>> decoders;
43: private Map<String, Object> userProperties = new HashMap<>();
44: private ServerEndpointConfig.Configurator serverEndpointConfigurator;
45:
46: // The builder ensures nothing except configurator can be {@code null}.
47: DefaultServerEndpointConfig(Class<?> endpointClass, String path, List<String> subprotocols,
48: List<Extension> extensions, List<Class<? extends Encoder>> encoders,
49: List<Class<? extends Decoder>> decoders, ServerEndpointConfig.Configurator serverEndpointConfigurator) {
50: this.path = path;
51: this.endpointClass = endpointClass;
52: this.subprotocols = Collections.unmodifiableList(subprotocols);
53: this.extensions = Collections.unmodifiableList(extensions);
54: this.encoders = Collections.unmodifiableList(encoders);
55: this.decoders = Collections.unmodifiableList(decoders);
56:• if (serverEndpointConfigurator == null) {
57: this.serverEndpointConfigurator = ServerEndpointConfig.Configurator.fetchContainerDefaultConfigurator();
58: } else {
59: this.serverEndpointConfigurator = serverEndpointConfigurator;
60: }
61: }
62:
63: /**
64: * Returns the class of the Endpoint that this configuration configures.
65: *
66: * @return the class of the Endpoint.
67: */
68: @Override
69: public Class<?> getEndpointClass() {
70: return this.endpointClass;
71: }
72:
73: /**
74: * Creates a server configuration with the given path
75: *
76: * @param path the URI or URI template.
77: */
78: DefaultServerEndpointConfig(Class<? extends Endpoint> endpointClass, String path) {
79: this.path = path;
80: this.endpointClass = endpointClass;
81: }
82:
83: /**
84: * Return the Encoder implementation classes configured. These will be used by the container to encode outgoing
85: * messages.
86: *
87: * @return the encoder implementation classes, in an unmodifiable list, empty if there are none.
88: */
89: @Override
90: public List<Class<? extends Encoder>> getEncoders() {
91: return this.encoders;
92: }
93:
94: /**
95: * Return the Decoder implementation classes configured. These will be used by the container to decode incoming
96: * messages into the expected custom objects on MessageHandler callbacks.
97: *
98: * @return the decoder implementation classes, in an unmodifiable list.
99: */
100: @Override
101: public List<Class<? extends Decoder>> getDecoders() {
102: return this.decoders;
103: }
104:
105: /**
106: * Return the path of this server configuration. The path is a relative URI or URI-template.
107: *
108: * @return the path
109: */
110: @Override
111: public String getPath() {
112: return path;
113: }
114:
115: /**
116: * Return the ServerEndpointConfigurator
117: *
118: * @return the ServerEndpointConfigurator
119: */
120: @Override
121: public ServerEndpointConfig.Configurator getConfigurator() {
122: return this.serverEndpointConfigurator;
123: }
124:
125: /**
126: * Editable map of user properties.
127: */
128: @Override
129: public final Map<String, Object> getUserProperties() {
130: return this.userProperties;
131: }
132:
133: @Override
134: public final List<String> getSubprotocols() {
135: return this.subprotocols;
136: }
137:
138: @Override
139: public final List<Extension> getExtensions() {
140: return this.extensions;
141: }
142:
143: }