Deprecated as of 5.0 a TaskScheduler is not provided upfront, not until it is obvious that it is needed, see AbstractWebSocketHandlerRegistration.getSockJsServiceRegistration().
@Override public WebSocketHandlerRegistration addHandler(WebSocketHandler handler, String... paths) { ServletWebSocketHandlerRegistration registration = new ServletWebSocketHandlerRegistration(); registration.addHandler(handler, paths); this.registrations.add(registration); return registration; }
public AbstractHandlerMapping getHandlerMapping() { Map<String, Object> urlMap = new LinkedHashMap<>(); for (ServletWebSocketHandlerRegistration registration : this.registrations) { MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); mappings.forEach((httpHandler, patterns) -> { for (String pattern : patterns) { 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; }
/** * Whether there are any endpoint SockJS registrations without a TaskScheduler. * This method should be invoked just before {@link #getHandlerMapping()} to * allow for registrations to be made first. */ protected boolean requiresTaskScheduler() { return this.registrations.stream() .anyMatch(r -> r.getSockJsServiceRegistration() != null && r.getSockJsServiceRegistration().getTaskScheduler() == null); }
@Override public WebSocketHandlerRegistration addHandler(WebSocketHandler handler, String... paths) { ServletWebSocketHandlerRegistration registration = new ServletWebSocketHandlerRegistration(); registration.addHandler(handler, paths); this.registrations.add(registration); return registration; }
/** * Whether there are any endpoint SockJS registrations without a TaskScheduler. * This method should be invoked just before {@link #getHandlerMapping()} to * allow for registrations to be made first. */ protected boolean requiresTaskScheduler() { return this.registrations.stream() .anyMatch(r -> r.getSockJsServiceRegistration() != null && r.getSockJsServiceRegistration().getTaskScheduler() == null); }
public AbstractHandlerMapping getHandlerMapping() { Map<String, Object> urlMap = new LinkedHashMap<>(); for (ServletWebSocketHandlerRegistration registration : this.registrations) { MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); mappings.forEach((httpHandler, patterns) -> { for (String pattern : patterns) { 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; }
@Override public WebSocketHandlerRegistration addHandler(WebSocketHandler handler, String... paths) { ServletWebSocketHandlerRegistration registration = new ServletWebSocketHandlerRegistration(); registration.addHandler(handler, paths); this.registrations.add(registration); return registration; }
/** * Whether there are any endpoint SockJS registrations without a TaskScheduler. * This method should be invoked just before {@link #getHandlerMapping()} to * allow for registrations to be made first. */ protected boolean requiresTaskScheduler() { return this.registrations.stream() .anyMatch(r -> r.getSockJsServiceRegistration() != null && r.getSockJsServiceRegistration().getTaskScheduler() == null); }
public AbstractHandlerMapping getHandlerMapping() { Map<String, Object> urlMap = new LinkedHashMap<>(); for (ServletWebSocketHandlerRegistration registration : this.registrations) { updateTaskScheduler(registration); MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings(); mappings.forEach((httpHandler, patterns) -> { for (String pattern : patterns) { 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; }
private void updateTaskScheduler(ServletWebSocketHandlerRegistration registration) { SockJsServiceRegistration sockJsRegistration = registration.getSockJsServiceRegistration(); if (sockJsRegistration != null && this.scheduler != null && sockJsRegistration.getTaskScheduler() == null) { sockJsRegistration.setTaskScheduler(this.scheduler); } }