本文整理了Java中org.apache.tomcat.websocket.server.WsServerContainer
类的一些代码示例,展示了WsServerContainer
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WsServerContainer
类的具体详情如下:
包路径:org.apache.tomcat.websocket.server.WsServerContainer
类名称:WsServerContainer
[英]Provides a per class loader (i.e. per web application) instance of a ServerContainer. Web application wide defaults may be configured by setting the following servlet context initialisation parameters to the desired values.
代码示例来源:origin: spring-projects/spring-framework
@Override
public void upgradeInternal(ServerHttpRequest request, ServerHttpResponse response,
@Nullable String selectedProtocol, List<Extension> selectedExtensions, Endpoint endpoint)
throws HandshakeFailureException {
HttpServletRequest servletRequest = getHttpServletRequest(request);
HttpServletResponse servletResponse = getHttpServletResponse(response);
StringBuffer requestUrl = servletRequest.getRequestURL();
String path = servletRequest.getRequestURI(); // shouldn't matter
Map<String, String> pathParams = Collections.<String, String> emptyMap();
ServerEndpointRegistration endpointConfig = new ServerEndpointRegistration(path, endpoint);
endpointConfig.setSubprotocols(Collections.singletonList(selectedProtocol));
endpointConfig.setExtensions(selectedExtensions);
try {
getContainer(servletRequest).doUpgrade(servletRequest, servletResponse, endpointConfig, pathParams);
}
catch (ServletException ex) {
throw new HandshakeFailureException(
"Servlet request failed to upgrade to WebSocket: " + requestUrl, ex);
}
catch (IOException ex) {
throw new HandshakeFailureException(
"Response update failed during upgrade to WebSocket: " + requestUrl, ex);
}
}
代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket
if (!sc.areEndpointsRegistered() ||
!UpgradeUtil.isWebSocketUpgradeRequest(request, response)) {
chain.doFilter(request, response);
path = req.getServletPath() + pathInfo;
WsMappingResult mappingResult = sc.findMapping(path);
代码示例来源:origin: org.apache.tomcat/tomcat-websocket
validateEncoders(annotation.encoders());
build();
addEndpoint(sec);
代码示例来源:origin: org.jboss.web/jbossweb
public WsRemoteEndpointImplServer(AbstractServletOutputStream sos,
WsServerContainer serverContainer) {
this.sos = sos;
this.wsWriteTimeout = serverContainer.getTimeout();
this.executorService = serverContainer.getExecutorService();
}
代码示例来源:origin: codefollower/Tomcat-Research
@Override
public void contextDestroyed(ServletContextEvent sce) {
ServletContext sc = sce.getServletContext();
Object obj = sc.getAttribute(Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
if (obj instanceof WsServerContainer) {
((WsServerContainer) obj).shutdownExecutor();
((WsServerContainer) obj).destroy();
}
}
}
代码示例来源:origin: codefollower/Tomcat-Research
@Override
public void sessionDestroyed(HttpSessionEvent se) {
wsServerContainer.closeAuthenticatedSession(se.getSession().getId());
}
}
代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket
static WsServerContainer init(ServletContext servletContext,
boolean initBySciMechanism) {
WsServerContainer sc = new WsServerContainer(servletContext);
servletContext.setAttribute(
Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE, sc);
servletContext.addListener(new WsSessionListener(sc));
// Can't register the ContextListener again if the ContextListener is
// calling this method
if (initBySciMechanism) {
servletContext.addListener(new WsContextListener());
}
return sc;
}
}
代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket
/**
* {@inheritDoc}
*
* Overridden to make it visible to other classes in this package.
*/
@Override
protected void registerSession(Endpoint endpoint, WsSession wsSession) {
super.registerSession(endpoint, wsSession);
if (wsSession.isOpen() &&
wsSession.getUserPrincipal() != null &&
wsSession.getHttpSessionId() != null) {
registerAuthenticatedSession(wsSession,
wsSession.getHttpSessionId());
}
}
代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket
webSocketContainer.registerSession(ep, wsSession);
} catch (DeploymentException e) {
throw new IllegalArgumentException(e);
代码示例来源:origin: codefollower/Tomcat-Research
sc.addEndpoint(config);
sc.addEndpoint(clazz);
代码示例来源:origin: org.jboss.web/jbossweb
@Override
public void contextDestroyed(ServletContextEvent sce) {
ServletContext sc = sce.getServletContext();
Object obj = sc.getAttribute(Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE);
if (obj instanceof WsServerContainer) {
((WsServerContainer) obj).destroy();
}
}
}
代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket
public WsRemoteEndpointImplServer(SocketWrapperBase<?> socketWrapper,
WsServerContainer serverContainer) {
this.socketWrapper = socketWrapper;
this.wsWriteTimeout = serverContainer.getTimeout();
}
代码示例来源:origin: codefollower/Tomcat-Research
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// This filter only needs to handle WebSocket upgrade requests
if (!sc.areEndpointsRegistered() ||
!UpgradeUtil.isWebSocketUpgradeRequest(request, response)) {
chain.doFilter(request, response);
return;
}
// HTTP request with an upgrade header for WebSocket present
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
// Check to see if this WebSocket implementation has a matching mapping
String path;
String pathInfo = req.getPathInfo();
if (pathInfo == null) {
path = req.getServletPath();
} else {
path = req.getServletPath() + pathInfo;
}
WsMappingResult mappingResult = sc.findMapping(path);
if (mappingResult == null) {
// No endpoint registered for the requested path. Let the
// application handle it (it might redirect or forward for example)
chain.doFilter(request, response);
return;
}
UpgradeUtil.doUpgrade(sc, req, resp, mappingResult.getConfig(),
mappingResult.getPathParams());
}
代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket
validateEncoders(annotation.encoders());
build();
addEndpoint(sec);
代码示例来源:origin: codefollower/Tomcat-Research
public WsRemoteEndpointImplServer(ServletOutputStream sos,
WsServerContainer serverContainer) {
this.sos = sos;
this.wsWriteTimeout = serverContainer.getTimeout();
this.executorService = serverContainer.getExecutorService();
}
代码示例来源:origin: org.apache.tomcat.embed/tomcat-embed-websocket
@Override
public void sessionDestroyed(HttpSessionEvent se) {
wsServerContainer.closeAuthenticatedSession(se.getSession().getId());
}
}
代码示例来源:origin: org.apache.tomcat/tomcat7-websocket
static WsServerContainer init(ServletContext servletContext,
boolean initBySciMechanism) {
WsServerContainer sc = new WsServerContainer(servletContext);
servletContext.setAttribute(
Constants.SERVER_CONTAINER_SERVLET_CONTEXT_ATTRIBUTE, sc);
servletContext.addListener(new WsSessionListener(sc));
// Can't register the ContextListener again if the ContextListener is
// calling this method
if (initBySciMechanism) {
servletContext.addListener(new WsContextListener());
}
return sc;
}
代码示例来源:origin: org.apache.tomcat/tomcat7-websocket
/**
* {@inheritDoc}
*
* Overridden to make it visible to other classes in this package.
*/
@Override
protected void registerSession(Endpoint endpoint, WsSession wsSession) {
super.registerSession(endpoint, wsSession);
if (wsSession.isOpen() &&
wsSession.getUserPrincipal() != null &&
wsSession.getHttpSessionId() != null) {
registerAuthenticatedSession(wsSession,
wsSession.getHttpSessionId());
}
}
代码示例来源:origin: org.apache.tomcat/tomcat-websocket
webSocketContainer.registerSession(ep, wsSession);
} catch (DeploymentException e) {
throw new IllegalArgumentException(e);
代码示例来源:origin: org.apache.tomcat/tomcat-websocket
sc.addEndpoint(config);
sc.addEndpoint(clazz);
内容来源于网络,如有侵权,请联系作者删除!