org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator Java Examples

The following examples show how to use org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebSocketConnectionManagerTests.java    From java-technology-stack with MIT License 7 votes vote down vote up
@Test
public void openConnection() throws Exception {
	List<String> subprotocols = Arrays.asList("abc");

	TestLifecycleWebSocketClient client = new TestLifecycleWebSocketClient(false);
	WebSocketHandler handler = new TextWebSocketHandler();

	WebSocketConnectionManager manager = new WebSocketConnectionManager(client, handler , "/path/{id}", "123");
	manager.setSubProtocols(subprotocols);
	manager.openConnection();

	WebSocketHttpHeaders expectedHeaders = new WebSocketHttpHeaders();
	expectedHeaders.setSecWebSocketProtocol(subprotocols);

	assertEquals(expectedHeaders, client.headers);
	assertEquals(new URI("/path/123"), client.uri);

	WebSocketHandlerDecorator loggingHandler = (WebSocketHandlerDecorator) client.webSocketHandler;
	assertEquals(LoggingWebSocketHandlerDecorator.class, loggingHandler.getClass());

	assertSame(handler, loggingHandler.getDelegate());
}
 
Example #2
Source File: WebSocketConnectionManagerTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void openConnection() throws Exception {
	List<String> subprotocols = Arrays.asList("abc");

	TestLifecycleWebSocketClient client = new TestLifecycleWebSocketClient(false);
	WebSocketHandler handler = new TextWebSocketHandler();

	WebSocketConnectionManager manager = new WebSocketConnectionManager(client, handler , "/path/{id}", "123");
	manager.setSubProtocols(subprotocols);
	manager.openConnection();

	WebSocketHttpHeaders expectedHeaders = new WebSocketHttpHeaders();
	expectedHeaders.setSecWebSocketProtocol(subprotocols);

	assertEquals(expectedHeaders, client.headers);
	assertEquals(new URI("/path/123"), client.uri);

	WebSocketHandlerDecorator loggingHandler = (WebSocketHandlerDecorator) client.webSocketHandler;
	assertEquals(LoggingWebSocketHandlerDecorator.class, loggingHandler.getClass());

	assertSame(handler, loggingHandler.getDelegate());
}
 
Example #3
Source File: WebSocketConnectionManagerTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void openConnection() throws Exception {
	List<String> subprotocols = Arrays.asList("abc");

	TestLifecycleWebSocketClient client = new TestLifecycleWebSocketClient(false);
	WebSocketHandler handler = new TextWebSocketHandler();

	WebSocketConnectionManager manager = new WebSocketConnectionManager(client, handler , "/path/{id}", "123");
	manager.setSubProtocols(subprotocols);
	manager.openConnection();

	WebSocketHttpHeaders expectedHeaders = new WebSocketHttpHeaders();
	expectedHeaders.setSecWebSocketProtocol(subprotocols);

	assertEquals(expectedHeaders, client.headers);
	assertEquals(new URI("/path/123"), client.uri);

	WebSocketHandlerDecorator loggingHandler = (WebSocketHandlerDecorator) client.webSocketHandler;
	assertEquals(LoggingWebSocketHandlerDecorator.class, loggingHandler.getClass());

	assertSame(handler, loggingHandler.getDelegate());
}
 
Example #4
Source File: SockJsHttpRequestHandler.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * 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));
}
 
Example #5
Source File: SockJsHttpRequestHandler.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * 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));
}
 
Example #6
Source File: SockJsHttpRequestHandler.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * 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));
}
 
Example #7
Source File: WebSocketHttpRequestHandler.java    From spring-analysis-note with MIT License 4 votes vote down vote up
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;
}
 
Example #8
Source File: WebSocketHttpRequestHandler.java    From java-technology-stack with MIT License 4 votes vote down vote up
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;
}
 
Example #9
Source File: WebSocketHttpRequestHandler.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example #10
Source File: WebSocketConnectionManager.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Decorate the WebSocketHandler provided to the class constructor.
 * <p>By default {@link LoggingWebSocketHandlerDecorator} is added.
 */
protected WebSocketHandler decorateWebSocketHandler(WebSocketHandler handler) {
	return new LoggingWebSocketHandlerDecorator(handler);
}
 
Example #11
Source File: WebSocketConnectionManager.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Decorate the WebSocketHandler provided to the class constructor.
 * <p>By default {@link LoggingWebSocketHandlerDecorator} is added.
 */
protected WebSocketHandler decorateWebSocketHandler(WebSocketHandler handler) {
	return new LoggingWebSocketHandlerDecorator(handler);
}
 
Example #12
Source File: WebSocketConnectionManager.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Decorate the WebSocketHandler provided to the class constructor.
 * <p>By default {@link LoggingWebSocketHandlerDecorator} is added.
 */
protected WebSocketHandler decorateWebSocketHandler(WebSocketHandler handler) {
	return new LoggingWebSocketHandlerDecorator(handler);
}