org.frameworkset.web.socket.config.ServletWebSocketHandlerRegistration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bboss-websocket Show documentation
Show all versions of bboss-websocket Show documentation
bboss is a j2ee framework include aop/ioc,mvc,persistent,taglib,rpc,event ,bean-xml serializable and so on.http://www.bbossgroups.com
package org.frameworkset.web.socket.config;
import java.util.Arrays;
import org.frameworkset.schedule.TaskScheduler;
import org.frameworkset.util.LinkedMultiValueMap;
import org.frameworkset.util.MultiValueMap;
import org.frameworkset.util.ObjectUtils;
import org.frameworkset.web.servlet.handler.HandlerMeta;
import org.frameworkset.web.socket.handler.HandshakeHandler;
import org.frameworkset.web.socket.handler.HandshakeInterceptor;
import org.frameworkset.web.socket.handler.SockJsHttpRequestHandler;
import org.frameworkset.web.socket.handler.WebSocketHttpRequestHandler;
import org.frameworkset.web.socket.inf.WebSocketHandler;
import org.frameworkset.web.socket.sockjs.SockJsService;
public class ServletWebSocketHandlerRegistration extends AbstractWebSocketHandlerRegistration> {
public ServletWebSocketHandlerRegistration(TaskScheduler sockJsTaskScheduler) {
super(sockJsTaskScheduler);
}
@Override
protected MultiValueMap createMappings() {
return new LinkedMultiValueMap();
}
@Override
protected void addSockJsServiceMapping(MultiValueMap mappings,
SockJsService sockJsService, WebSocketHandler handler, String pathPattern) {
SockJsHttpRequestHandler httpHandler = new SockJsHttpRequestHandler(sockJsService, handler);
HandlerMeta handlerMeta = new HandlerMeta();
handlerMeta.setHandler(httpHandler);
handlerMeta.setWebsocket(true);
mappings.add(handlerMeta, pathPattern);
}
@Override
protected void addWebSocketHandlerMapping(MultiValueMap mappings,
WebSocketHandler wsHandler, HandshakeHandler handshakeHandler,
HandshakeInterceptor[] interceptors, String path) {
HandlerMeta handlerMeta = new HandlerMeta();
WebSocketHttpRequestHandler httpHandler = new WebSocketHttpRequestHandler(wsHandler, handshakeHandler);
if (!ObjectUtils.isEmpty(interceptors)) {
httpHandler.setHandshakeInterceptors(Arrays.asList(interceptors));
}
handlerMeta.setHandler(httpHandler);
handlerMeta.setWebsocket(true);
mappings.add(handlerMeta, path);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy