/** * Decorate the WebSocketHandler provided to the class constructor. * <p>By default {@link LoggingWebSocketHandlerDecorator} is added. */ protected WebSocketHandler decorateWebSocketHandler(WebSocketHandler handler) { return new LoggingWebSocketHandlerDecorator(handler); }
@Override public WebSocketHandler getObject() { WebSocketHandler result = this.handler; for (WebSocketHandlerDecoratorFactory factory : this.factories) { result = factory.decorate(result); } return result; }
@Override public void setBeanFactory(BeanFactory beanFactory) { if (this.endpointProvider != null) { this.endpointProvider.setBeanFactory(beanFactory); } }
public WebSocketHttpRequestHandler(WebSocketHandler wsHandler, HandshakeHandler handshakeHandler) { Assert.notNull(wsHandler, "wsHandler must not be null"); Assert.notNull(handshakeHandler, "handshakeHandler must not be null"); this.wsHandler = new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(wsHandler)); this.handshakeHandler = handshakeHandler; }
public AnnotatedEndpointConnectionManager(Class<?> endpointClass, String uriTemplate, Object... uriVariables) { super(uriTemplate, uriVariables); this.endpoint = null; this.endpointProvider = new BeanCreatingHandlerProvider<>(endpointClass); }
@Before public void setup() { this.delegate = mock(WebSocketHandler.class); this.decorator = new ExceptionWebSocketHandlerDecorator(this.delegate); this.session = new TestWebSocketSession(); this.session.setOpen(true); }
public static WebSocketHandler unwrap(WebSocketHandler handler) { if (handler instanceof WebSocketHandlerDecorator) { return ((WebSocketHandlerDecorator) handler).getLastHandler(); } else { return handler; } }
public WebSocketHandler getLastHandler() { WebSocketHandler result = this.delegate; while (result instanceof WebSocketHandlerDecorator) { result = ((WebSocketHandlerDecorator) result).getDelegate(); } return result; }
public WebSocketSession getLastSession() { WebSocketSession result = this.delegate; while (result instanceof WebSocketSessionDecorator) { result = ((WebSocketSessionDecorator) result).getDelegate(); } return result; }
public static WebSocketSession unwrap(WebSocketSession session) { if (session instanceof WebSocketSessionDecorator) { return ((WebSocketSessionDecorator) session).getLastSession(); } else { return session; } }
@Override public String toString() { return "PerConnectionWebSocketHandlerProxy[handlerType=" + this.provider.getHandlerType() + "]"; }
private void limitExceeded(String reason) { this.limitExceeded = true; throw new SessionLimitExceededException(reason, CloseStatus.SESSION_NOT_RELIABLE); }
@Override public void sendMessage(WebSocketMessage<?> message) throws IOException { super.sendMessage(message); if (this.nextMessageLatch != null) { this.nextMessageLatch.get().countDown(); } block(); }
/** * Create a new SockJsHttpRequestHandler. * @param sockJsService the SockJS service * @param webSocketHandler the websocket handler */ public SockJsHttpRequestHandler(SockJsService sockJsService, WebSocketHandler webSocketHandler) { Assert.notNull(sockJsService, "SockJsService must not be null"); Assert.notNull(webSocketHandler, "WebSocketHandler must not be null"); this.sockJsService = sockJsService; this.webSocketHandler = new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(webSocketHandler)); }
@Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { if (this.endpointProvider != null) { this.endpointProvider.setBeanFactory(beanFactory); } }
public PerConnectionWebSocketHandler(Class<? extends WebSocketHandler> handlerType, boolean supportsPartialMessages) { this.provider = new BeanCreatingHandlerProvider<>(handlerType); this.supportsPartialMessages = supportsPartialMessages; }
private WebSocketHandler unwrapWebSocketHandler(WebSocketHandler handler) { return (handler instanceof WebSocketHandlerDecorator) ? ((WebSocketHandlerDecorator) handler).getLastHandler() : handler; }
@Override public void setBeanFactory(BeanFactory beanFactory) { if (this.endpointProvider != null) { this.endpointProvider.setBeanFactory(beanFactory); } }
public EndpointConnectionManager(Class<? extends Endpoint> endpointClass, String uriTemplate, Object... uriVars) { super(uriTemplate, uriVars); Assert.notNull(endpointClass, "endpointClass must not be null"); this.endpoint = null; this.endpointProvider = new BeanCreatingHandlerProvider<>(endpointClass); }
@Override public void setBeanFactory(BeanFactory beanFactory) { this.provider.setBeanFactory(beanFactory); }