public class HttpSessionResolver extends Object
HttpSession from an application running on Servlet 3 and Java
WebSocket API 1 environments.
In case of Java WebSocket API, HttpSession must be put into a map returned by
EndpointConfig.getUserProperties() with the
javax.servlet.http.HttpSession key when building ServerEndpointConfig.
ServerEndpointConfig config = ServerEndpointConfig.Builder.create(AsityServerEndpoint.class,
"/cettia")
.configurator(new Configurator() {
@Override
protected <T> T getEndpointInstance(Class<T> endpointClass) throws
InstantiationException {
return endpointClass.cast(new AsityServerEndpoint().onwebsocket(wsTransportServer));
}
@Override
protected void modifyHandshake(ServerEndpointConfig config, HandshakeRequest request,
HandshakeResponse response) {
HttpSession httpSession = (HttpSession) request.getHttpSession();
config.getUserProperties().put(HttpSession.class.getName(), httpSession);
}
})
.build();
| Constructor and Description |
|---|
HttpSessionResolver() |
| Modifier and Type | Method and Description |
|---|---|
javax.servlet.http.HttpSession |
resolve(ServerSocket socket)
Resolves the current session.
|
public javax.servlet.http.HttpSession resolve(ServerSocket socket)
Note that it doesn't create a session and returns null if there's no
current session.
Copyright 2015, The Cettia Project