|
40 | 40 | package org.glassfish.httpsession; |
41 | 41 |
|
42 | 42 | import java.util.Collections; |
43 | | -import java.util.List; |
| 43 | +import java.util.HashSet; |
| 44 | +import java.util.Set; |
44 | 45 | import javax.servlet.http.HttpSession; |
45 | | -import javax.websocket.Extension; |
| 46 | +import javax.websocket.Endpoint; |
46 | 47 | import javax.websocket.HandshakeResponse; |
47 | | -import javax.websocket.server.DefaultServerConfiguration; |
48 | 48 | import javax.websocket.server.HandshakeRequest; |
49 | | -import javax.websocket.server.ServerEndpointConfiguration; |
| 49 | +import javax.websocket.server.ServerApplicationConfig; |
| 50 | +import javax.websocket.server.ServerEndpointConfig; |
50 | 51 |
|
51 | 52 | /** |
52 | 53 | * @author Arun Gupta |
53 | 54 | */ |
54 | | -// "implements ServerEndpointConfiguration" needs to be here, |
55 | | -// most likely Servlet issue; see http://java.net/jira/browse/GLASSFISH-19551 |
56 | | -// (should be reopened, it is currently discussed internally) |
| 55 | +public class MyEndpointConfiguration implements ServerApplicationConfig { |
57 | 56 |
|
58 | | -// Also providing an implementation of three methods until |
59 | | -// http://java.net/jira/browse/WEBSOCKET_SPEC-128 is fixed. |
60 | | -public class MyServerConfiguration extends DefaultServerConfiguration implements ServerEndpointConfiguration { |
61 | | - |
62 | | - public MyServerConfiguration() { |
63 | | - super(MyEndpoint.class, "websocket"); |
64 | | - } |
65 | | - |
66 | | - @Override |
67 | | - public String getNegotiatedSubprotocol(List<String> requestedSubprotocols) { |
68 | | - return null; |
69 | | - } |
70 | | - |
71 | | - @Override |
72 | | - public List<Extension> getNegotiatedExtensions(List<Extension> requestedExtensions) { |
73 | | - return Collections.emptyList(); |
74 | | - } |
75 | | - |
76 | | - @Override |
77 | | - public boolean checkOrigin(String originHeaderValue) { |
78 | | - return true; |
| 57 | +@Override |
| 58 | + public Set<ServerEndpointConfig> getEndpointConfigs(Set<Class<? extends Endpoint>> set) { |
| 59 | + return new HashSet<ServerEndpointConfig>() {{ |
| 60 | + add(ServerEndpointConfig.Builder.create(MyEndpoint.class, "/websocket").build()); |
| 61 | + }}; |
79 | 62 | } |
80 | 63 |
|
81 | 64 | @Override |
82 | | - public void modifyHandshake(HandshakeRequest request, HandshakeResponse response) { |
83 | | - HttpSession httpSession = (HttpSession)request.getSession(); |
84 | | - System.out.println(httpSession); |
85 | | - System.out.println("Invoked from: " + httpSession.getServletContext().getContextPath()); |
86 | | - super.modifyHandshake(request, response); |
| 65 | + public Set<Class<?>> getAnnotatedEndpointClasses(Set<Class<?>> set) { |
| 66 | + return Collections.emptySet(); |
87 | 67 | } |
| 68 | + |
| 69 | +// @Override |
| 70 | +// public void modifyHandshake(HandshakeRequest request, HandshakeResponse response) { |
| 71 | +// HttpSession httpSession = (HttpSession)request.getSession(); |
| 72 | +// System.out.println(httpSession); |
| 73 | +// System.out.println("Invoked from: " + httpSession.getServletContext().getContextPath()); |
| 74 | +// super.modifyHandshake(request, response); |
| 75 | +// } |
88 | 76 | } |
0 commit comments