1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.websocket.jsr356.client;
20
21 import javax.websocket.ClientEndpoint;
22 import javax.websocket.ClientEndpointConfig;
23
24 import org.eclipse.jetty.websocket.api.InvalidWebSocketException;
25 import org.eclipse.jetty.websocket.jsr356.ClientContainer;
26 import org.eclipse.jetty.websocket.jsr356.annotations.AnnotatedEndpointMetadata;
27
28 public class AnnotatedClientEndpointMetadata extends AnnotatedEndpointMetadata<ClientEndpoint, ClientEndpointConfig>
29 {
30 private final ClientEndpoint endpoint;
31 private final AnnotatedClientEndpointConfig config;
32
33 public AnnotatedClientEndpointMetadata(ClientContainer container, Class<?> websocket)
34 {
35 super(websocket);
36
37 ClientEndpoint anno = websocket.getAnnotation(ClientEndpoint.class);
38 if (anno == null)
39 {
40 throw new InvalidWebSocketException(String.format("Unsupported WebSocket object [%s], missing @%s annotation",websocket.getName(),
41 ClientEndpoint.class.getName()));
42 }
43
44 this.endpoint = anno;
45 this.config = new AnnotatedClientEndpointConfig(anno);
46
47 getDecoders().addAll(anno.decoders());
48 getEncoders().addAll(anno.encoders());
49 }
50
51 @Override
52 public ClientEndpoint getAnnotation()
53 {
54 return endpoint;
55 }
56
57 @Override
58 public ClientEndpointConfig getConfig()
59 {
60 return config;
61 }
62 }