private static Set<TransportHandler> getDefaultTransportHandlers(@Nullable Collection<TransportHandler> overrides) { Set<TransportHandler> result = new LinkedHashSet<>(8); result.add(new XhrPollingTransportHandler()); result.add(new XhrReceivingTransportHandler()); result.add(new XhrStreamingTransportHandler()); result.add(new EventSourceTransportHandler()); result.add(new HtmlFileTransportHandler()); try { result.add(new WebSocketTransportHandler(new DefaultHandshakeHandler())); } catch (Exception ex) { Log logger = LogFactory.getLog(DefaultSockJsService.class); if (logger.isWarnEnabled()) { logger.warn("Failed to create a default WebSocketTransportHandler", ex); } } if (overrides != null) { result.addAll(overrides); } return result; }
@Override public SockJsServiceRegistration withSockJS() { this.sockJsServiceRegistration = new SockJsServiceRegistration(); HandshakeInterceptor[] interceptors = getInterceptors(); if (interceptors.length > 0) { this.sockJsServiceRegistration.setInterceptors(interceptors); } if (this.handshakeHandler != null) { WebSocketTransportHandler transportHandler = new WebSocketTransportHandler(this.handshakeHandler); this.sockJsServiceRegistration.setTransportHandlerOverrides(transportHandler); } if (!this.allowedOrigins.isEmpty()) { this.sockJsServiceRegistration.setAllowedOrigins(StringUtils.toStringArray(this.allowedOrigins)); } return this.sockJsServiceRegistration; }
@Override public SockJsServiceRegistration withSockJS() { this.registration = new SockJsServiceRegistration(); this.registration.setTaskScheduler(this.sockJsTaskScheduler); HandshakeInterceptor[] interceptors = getInterceptors(); if (interceptors.length > 0) { this.registration.setInterceptors(interceptors); } if (this.handshakeHandler != null) { WebSocketTransportHandler handler = new WebSocketTransportHandler(this.handshakeHandler); this.registration.setTransportHandlerOverrides(handler); } if (!this.allowedOrigins.isEmpty()) { this.registration.setAllowedOrigins(StringUtils.toStringArray(this.allowedOrigins)); } return this.registration; }
@Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { registry.addHandler(serverHandler(), "/ws") .setHandshakeHandler(this.handshakeHandler); registry.addHandler(serverHandler(), "/sockjs").withSockJS() .setTransportHandlerOverrides(new WebSocketTransportHandler(this.handshakeHandler)); }
private static Set<TransportHandler> getDefaultTransportHandlers(@Nullable Collection<TransportHandler> overrides) { Set<TransportHandler> result = new LinkedHashSet<>(8); result.add(new XhrPollingTransportHandler()); result.add(new XhrReceivingTransportHandler()); result.add(new XhrStreamingTransportHandler()); result.add(new EventSourceTransportHandler()); result.add(new HtmlFileTransportHandler()); try { result.add(new WebSocketTransportHandler(new DefaultHandshakeHandler())); } catch (Exception ex) { Log logger = LogFactory.getLog(DefaultSockJsService.class); if (logger.isWarnEnabled()) { logger.warn("Failed to create a default WebSocketTransportHandler", ex); } } if (overrides != null) { result.addAll(overrides); } return result; }
@SuppressWarnings("deprecation") private static Set<TransportHandler> getDefaultTransportHandlers(@Nullable Collection<TransportHandler> overrides) { Set<TransportHandler> result = new LinkedHashSet<>(8); result.add(new XhrPollingTransportHandler()); result.add(new XhrReceivingTransportHandler()); result.add(new XhrStreamingTransportHandler()); result.add(new JsonpPollingTransportHandler()); result.add(new JsonpReceivingTransportHandler()); result.add(new EventSourceTransportHandler()); result.add(new HtmlFileTransportHandler()); try { result.add(new WebSocketTransportHandler(new DefaultHandshakeHandler())); } catch (Exception ex) { Log logger = LogFactory.getLog(DefaultSockJsService.class); if (logger.isWarnEnabled()) { logger.warn("Failed to create a default WebSocketTransportHandler", ex); } } if (overrides != null) { result.addAll(overrides); } return result; }
@Override public SockJsServiceRegistration withSockJS() { this.registration = new WampSockJsServiceRegistration(this.sockJsTaskScheduler); HandshakeInterceptor[] handshakeInterceptors = getInterceptors(); if (handshakeInterceptors.length > 0) { this.registration.setInterceptors(handshakeInterceptors); } if (this.handshakeHandler != null) { WebSocketTransportHandler transportHandler = new WebSocketTransportHandler( this.handshakeHandler); this.registration.setTransportHandlerOverrides(transportHandler); } if (!this.allowedOrigins.isEmpty()) { this.registration.setAllowedOrigins( this.allowedOrigins.toArray(new String[this.allowedOrigins.size()])); } return this.registration; }
@Override public SockJsServiceRegistration withSockJS() { this.sockJsServiceRegistration = new SockJsServiceRegistration(); HandshakeInterceptor[] interceptors = getInterceptors(); if (interceptors.length > 0) { this.sockJsServiceRegistration.setInterceptors(interceptors); } if (this.handshakeHandler != null) { WebSocketTransportHandler transportHandler = new WebSocketTransportHandler(this.handshakeHandler); this.sockJsServiceRegistration.setTransportHandlerOverrides(transportHandler); } if (!this.allowedOrigins.isEmpty()) { this.sockJsServiceRegistration.setAllowedOrigins(StringUtils.toStringArray(this.allowedOrigins)); } return this.sockJsServiceRegistration; }
@Override public SockJsServiceRegistration withSockJS() { this.registration = new SockJsServiceRegistration(); this.registration.setTaskScheduler(this.sockJsTaskScheduler); HandshakeInterceptor[] interceptors = getInterceptors(); if (interceptors.length > 0) { this.registration.setInterceptors(interceptors); } if (this.handshakeHandler != null) { WebSocketTransportHandler handler = new WebSocketTransportHandler(this.handshakeHandler); this.registration.setTransportHandlerOverrides(handler); } if (!this.allowedOrigins.isEmpty()) { this.registration.setAllowedOrigins(StringUtils.toStringArray(this.allowedOrigins)); } return this.registration; }
@Override public SockJsServiceRegistration withSockJS() { this.registration = new SockJsServiceRegistration(); this.registration.setTaskScheduler(this.sockJsTaskScheduler); HandshakeInterceptor[] interceptors = getInterceptors(); if (interceptors.length > 0) { this.registration.setInterceptors(interceptors); } if (this.handshakeHandler != null) { WebSocketTransportHandler handler = new WebSocketTransportHandler(this.handshakeHandler); this.registration.setTransportHandlerOverrides(handler); } if (!this.allowedOrigins.isEmpty()) { this.registration.setAllowedOrigins(StringUtils.toStringArray(this.allowedOrigins)); } return this.registration; }
@Override public SockJsServiceRegistration withSockJS() { this.sockJsServiceRegistration = new SockJsServiceRegistration(); if (this.scheduler != null) { this.sockJsServiceRegistration.setTaskScheduler(this.scheduler); } HandshakeInterceptor[] interceptors = getInterceptors(); if (interceptors.length > 0) { this.sockJsServiceRegistration.setInterceptors(interceptors); } if (this.handshakeHandler != null) { WebSocketTransportHandler transportHandler = new WebSocketTransportHandler(this.handshakeHandler); this.sockJsServiceRegistration.setTransportHandlerOverrides(transportHandler); } if (!this.allowedOrigins.isEmpty()) { this.sockJsServiceRegistration.setAllowedOrigins(StringUtils.toStringArray(this.allowedOrigins)); } return this.sockJsServiceRegistration; }