1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 package javax.websocket.server;
18 
19 import java.util.List;
20 import java.util.Map;
21 import java.util.concurrent.ConcurrentHashMap;
22 
23 import javax.websocket.Decoder;
24 import javax.websocket.Encoder;
25 import javax.websocket.Extension;
26 
27 /**
28  * Provides the default configuration for WebSocket server endpoints.
29  */
30 final class DefaultServerEndpointConfig implements ServerEndpointConfig {
31 
32     private final Class<?> endpointClass;
33     private final String path;
34     private final List<String> subprotocols;
35     private final List<Extension> extensions;
36     private final List<Class<? extends Encoder>> encoders;
37     private final List<Class<? extends Decoder>> decoders;
38     private final Configurator serverEndpointConfigurator;
39     private final Map<String,Object> userProperties = new ConcurrentHashMap<>();
40 
DefaultServerEndpointConfig( Class<?> endpointClass, String path, List<String> subprotocols, List<Extension> extensions, List<Class<? extends Encoder>> encoders, List<Class<? extends Decoder>> decoders, Configurator serverEndpointConfigurator)41     DefaultServerEndpointConfig(
42             Class<?> endpointClass, String path,
43             List<String> subprotocols, List<Extension> extensions,
44             List<Class<? extends Encoder>> encoders,
45             List<Class<? extends Decoder>> decoders,
46             Configurator serverEndpointConfigurator) {
47         this.endpointClass = endpointClass;
48         this.path = path;
49         this.subprotocols = subprotocols;
50         this.extensions = extensions;
51         this.encoders = encoders;
52         this.decoders = decoders;
53         this.serverEndpointConfigurator = serverEndpointConfigurator;
54     }
55 
56     @Override
getEndpointClass()57     public Class<?> getEndpointClass() {
58         return endpointClass;
59     }
60 
61     @Override
getEncoders()62     public List<Class<? extends Encoder>> getEncoders() {
63         return this.encoders;
64     }
65 
66     @Override
getDecoders()67     public List<Class<? extends Decoder>> getDecoders() {
68         return this.decoders;
69     }
70 
71     @Override
getPath()72     public String getPath() {
73         return path;
74     }
75 
76     @Override
getConfigurator()77     public Configurator getConfigurator() {
78         return serverEndpointConfigurator;
79     }
80 
81     @Override
getUserProperties()82     public final Map<String, Object> getUserProperties() {
83         return userProperties;
84     }
85 
86     @Override
getSubprotocols()87     public final List<String> getSubprotocols() {
88         return subprotocols;
89     }
90 
91     @Override
getExtensions()92     public final List<Extension> getExtensions() {
93         return extensions;
94     }
95 }
96