@Override public WebSocketHandlerRegistration addHandler( WebSocketHandler webSocketHandler, String... paths) { ServletWebSocketHandlerRegistration registration = new ServletWebSocketHandlerRegistration(this.sockJsTaskScheduler); registration.addHandler(webSocketHandler, paths); this.registrations.add(registration); return registration; }
/** Return a {@link HandlerMapping} with mapped {@link HttpRequestHandler}s. */ public AbstractHandlerMapping getHandlerMapping() { Map<String, Object> urlMap = new LinkedHashMap<>(); for (ServletWebSocketHandlerRegistration registration : this.registrations) { MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); for (HttpRequestHandler httpHandler : mappings.keySet()) { for (String pattern : mappings.get(httpHandler)) { urlMap.put(pattern, httpHandler); } } } WebSocketHandlerMapping hm = new WebSocketHandlerMapping(); hm.setUrlMap(urlMap); hm.setOrder(this.order); if (this.urlPathHelper != null) { hm.setUrlPathHelper(this.urlPathHelper); } return hm; }