Undertow-related polishing
This commit is contained in:
@@ -16,6 +16,16 @@
|
|||||||
|
|
||||||
package org.springframework.web.socket.server.standard;
|
package org.springframework.web.socket.server.standard;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import javax.websocket.Decoder;
|
||||||
|
import javax.websocket.Encoder;
|
||||||
|
import javax.websocket.Endpoint;
|
||||||
|
import javax.websocket.Extension;
|
||||||
|
|
||||||
import io.undertow.server.HttpServerExchange;
|
import io.undertow.server.HttpServerExchange;
|
||||||
import io.undertow.server.HttpUpgradeListener;
|
import io.undertow.server.HttpUpgradeListener;
|
||||||
import io.undertow.servlet.api.InstanceFactory;
|
import io.undertow.servlet.api.InstanceFactory;
|
||||||
@@ -31,18 +41,11 @@ import io.undertow.websockets.jsr.EncodingFactory;
|
|||||||
import io.undertow.websockets.jsr.EndpointSessionHandler;
|
import io.undertow.websockets.jsr.EndpointSessionHandler;
|
||||||
import io.undertow.websockets.jsr.ServerWebSocketContainer;
|
import io.undertow.websockets.jsr.ServerWebSocketContainer;
|
||||||
import io.undertow.websockets.jsr.handshake.HandshakeUtil;
|
import io.undertow.websockets.jsr.handshake.HandshakeUtil;
|
||||||
|
import org.xnio.StreamConnection;
|
||||||
|
|
||||||
import org.springframework.http.server.ServerHttpRequest;
|
import org.springframework.http.server.ServerHttpRequest;
|
||||||
import org.springframework.http.server.ServerHttpResponse;
|
import org.springframework.http.server.ServerHttpResponse;
|
||||||
import org.springframework.web.socket.server.HandshakeFailureException;
|
import org.springframework.web.socket.server.HandshakeFailureException;
|
||||||
import org.xnio.StreamConnection;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import javax.websocket.Decoder;
|
|
||||||
import javax.websocket.Encoder;
|
|
||||||
import javax.websocket.Endpoint;
|
|
||||||
import javax.websocket.Extension;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -125,8 +128,7 @@ public class UndertowRequestUpgradeStrategy extends AbstractStandardUpgradeStrat
|
|||||||
endpointRegistration.setSubprotocols(Arrays.asList(selectedProtocol));
|
endpointRegistration.setSubprotocols(Arrays.asList(selectedProtocol));
|
||||||
endpointRegistration.setExtensions(selectedExtensions);
|
endpointRegistration.setExtensions(selectedExtensions);
|
||||||
|
|
||||||
return new ConfiguredServerEndpoint(endpointRegistration,
|
return new ConfiguredServerEndpoint(endpointRegistration, new EndpointInstanceFactory(endpoint), null,
|
||||||
new EndpointInstanceFactory(endpoint), null,
|
|
||||||
new EncodingFactory(
|
new EncodingFactory(
|
||||||
Collections.<Class<?>, List<InstanceFactory<? extends Encoder>>>emptyMap(),
|
Collections.<Class<?>, List<InstanceFactory<? extends Encoder>>>emptyMap(),
|
||||||
Collections.<Class<?>, List<InstanceFactory<? extends Decoder>>>emptyMap(),
|
Collections.<Class<?>, List<InstanceFactory<? extends Decoder>>>emptyMap(),
|
||||||
@@ -145,7 +147,6 @@ public class UndertowRequestUpgradeStrategy extends AbstractStandardUpgradeStrat
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InstanceHandle<Endpoint> createInstance() throws InstantiationException {
|
public InstanceHandle<Endpoint> createInstance() throws InstantiationException {
|
||||||
|
|
||||||
return new InstanceHandle<Endpoint>() {
|
return new InstanceHandle<Endpoint>() {
|
||||||
@Override
|
@Override
|
||||||
public Endpoint getInstance() {
|
public Endpoint getInstance() {
|
||||||
|
|||||||
@@ -23,17 +23,18 @@ import java.util.Arrays;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.junit.runners.Parameterized;
|
import org.junit.runners.Parameterized;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.web.socket.handler.TextWebSocketHandler;
|
|
||||||
import org.springframework.web.socket.handler.AbstractWebSocketHandler;
|
|
||||||
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
|
|
||||||
import org.springframework.web.socket.client.jetty.JettyWebSocketClient;
|
import org.springframework.web.socket.client.jetty.JettyWebSocketClient;
|
||||||
import org.springframework.web.socket.server.support.DefaultHandshakeHandler;
|
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
|
||||||
import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
import org.springframework.web.socket.config.annotation.EnableWebSocket;
|
||||||
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
|
import org.springframework.web.socket.config.annotation.WebSocketConfigurer;
|
||||||
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
|
import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry;
|
||||||
|
import org.springframework.web.socket.handler.AbstractWebSocketHandler;
|
||||||
|
import org.springframework.web.socket.handler.TextWebSocketHandler;
|
||||||
|
import org.springframework.web.socket.server.support.DefaultHandshakeHandler;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
@@ -52,7 +53,7 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTest
|
|||||||
{new TomcatWebSocketTestServer(), new StandardWebSocketClient()},
|
{new TomcatWebSocketTestServer(), new StandardWebSocketClient()},
|
||||||
{new UndertowTestServer(), new JettyWebSocketClient()}
|
{new UndertowTestServer(), new JettyWebSocketClient()}
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -62,7 +63,6 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTest
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void subProtocolNegotiation() throws Exception {
|
public void subProtocolNegotiation() throws Exception {
|
||||||
|
|
||||||
WebSocketHttpHeaders headers = new WebSocketHttpHeaders();
|
WebSocketHttpHeaders headers = new WebSocketHttpHeaders();
|
||||||
headers.setSecWebSocketProtocol("foo");
|
headers.setSecWebSocketProtocol("foo");
|
||||||
|
|
||||||
@@ -92,6 +92,7 @@ public class WebSocketIntegrationTests extends AbstractWebSocketIntegrationTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class TestServerWebSocketHandler extends TextWebSocketHandler {
|
private static class TestServerWebSocketHandler extends TextWebSocketHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user