From c0b6d320f17add580427e72ac7b5ac85b6197692 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Tue, 13 Oct 2015 12:31:35 +0200 Subject: [PATCH] Updated compatibility statements in RequestUpgradeStrategy javadocs --- .../jetty/JettyRequestUpgradeStrategy.java | 18 +++++++++--------- .../AbstractTyrusRequestUpgradeStrategy.java | 7 ++++--- .../GlassFishRequestUpgradeStrategy.java | 4 ++-- .../standard/TomcatRequestUpgradeStrategy.java | 14 ++++++++------ .../UndertowRequestUpgradeStrategy.java | 4 ++-- .../WebLogicRequestUpgradeStrategy.java | 4 ++-- .../support/DefaultHandshakeHandler.java | 16 +++++++++++----- 7 files changed, 38 insertions(+), 29 deletions(-) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java index 9bb42fd03d..27f4e3f561 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,8 +50,8 @@ import org.springframework.web.socket.server.HandshakeFailureException; import org.springframework.web.socket.server.RequestUpgradeStrategy; /** - * {@link RequestUpgradeStrategy} for use with Jetty 9. Based on Jetty's internal - * {@code org.eclipse.jetty.websocket.server.WebSocketHandler} class. + * A {@link RequestUpgradeStrategy} for use with Jetty 9.x. Based on Jetty's + * internal {@code org.eclipse.jetty.websocket.server.WebSocketHandler} class. * * @author Phillip Webb * @author Rossen Stoyanchev @@ -69,17 +69,17 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy { /** - * Default constructor that creates {@link WebSocketServerFactory} through its default - * constructor thus using a default {@link WebSocketPolicy}. + * Default constructor that creates {@link WebSocketServerFactory} through + * its default constructor thus using a default {@link WebSocketPolicy}. */ public JettyRequestUpgradeStrategy() { this(new WebSocketServerFactory()); } /** - * A constructor accepting a {@link WebSocketServerFactory}. This may be useful for - * modifying the factory's {@link WebSocketPolicy} via - * {@link WebSocketServerFactory#getPolicy()}. + * A constructor accepting a {@link WebSocketServerFactory}. + * This may be useful for modifying the factory's {@link WebSocketPolicy} + * via {@link WebSocketServerFactory#getPolicy()}. */ public JettyRequestUpgradeStrategy(WebSocketServerFactory factory) { Assert.notNull(factory, "WebSocketServerFactory must not be null"); @@ -154,7 +154,7 @@ public class JettyRequestUpgradeStrategy implements RequestUpgradeStrategy { } catch (IOException ex) { throw new HandshakeFailureException( - "Response update failed during upgrade to WebSocket, uri=" + request.getURI(), ex); + "Response update failed during upgrade to WebSocket: " + request.getURI(), ex); } finally { wsContainerHolder.remove(); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractTyrusRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractTyrusRequestUpgradeStrategy.java index 9a871e3dde..8d0077e2a5 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractTyrusRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/AbstractTyrusRequestUpgradeStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,9 +54,10 @@ import org.springframework.web.socket.WebSocketExtension; import org.springframework.web.socket.server.HandshakeFailureException; /** - * An base class for WebSocket servers using Tyrus. + * A base class for {@code RequestUpgradeStrategy} implementations on top of + * JSR-356 based servers which include Tyrus as their WebSocket engine. * - *

Works with Tyrus 1.3.5 (WebLogic 12.1.3) and Tyrus 1.7 (GlassFish 4.0.1). + *

Works with Tyrus 1.3.5 (WebLogic 12.1.3) and Tyrus 1.7+ (GlassFish 4.1.x). * * @author Rossen Stoyanchev * @since 4.1 diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/GlassFishRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/GlassFishRequestUpgradeStrategy.java index a37abe304f..65e140a568 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/GlassFishRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/GlassFishRequestUpgradeStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import org.springframework.util.ReflectionUtils; import org.springframework.web.socket.server.HandshakeFailureException; /** - * A WebSocket {@code RequestUpgradeStrategy} for GlassFish 4.0.1 and beyond. + * A WebSocket {@code RequestUpgradeStrategy} for Oracle's GlassFish 4.1 and higher. * * @author Rossen Stoyanchev * @author Juergen Hoeller diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/TomcatRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/TomcatRequestUpgradeStrategy.java index a99995ac69..9ae54f9924 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/TomcatRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/TomcatRequestUpgradeStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,8 +34,10 @@ import org.springframework.http.server.ServerHttpResponse; import org.springframework.web.socket.server.HandshakeFailureException; /** - * Tomcat support for upgrading an {@link HttpServletRequest} during a WebSocket handshake. - * To modify properties of the underlying {@link javax.websocket.server.ServerContainer} + * A WebSocket {@code RequestUpgradeStrategy} for Apache Tomcat. Compatible with + * all versions of Tomcat that support JSR-356, i.e. Tomcat 7.0.47+ and higher. + * + *

To modify properties of the underlying {@link javax.websocket.server.ServerContainer} * you can use {@link ServletServerContainerFactoryBean} in XML configuration or, * when using Java configuration, access the container instance through the * "javax.websocket.server.ServerContainer" ServletContext attribute. @@ -59,7 +61,7 @@ public class TomcatRequestUpgradeStrategy extends AbstractStandardUpgradeStrateg HttpServletResponse servletResponse = getHttpServletResponse(response); StringBuffer requestUrl = servletRequest.getRequestURL(); - String path = servletRequest.getRequestURI(); // shouldn't matter + String path = servletRequest.getRequestURI(); // shouldn't matter Map pathParams = Collections. emptyMap(); ServerEndpointRegistration endpointConfig = new ServerEndpointRegistration(path, endpoint); @@ -71,11 +73,11 @@ public class TomcatRequestUpgradeStrategy extends AbstractStandardUpgradeStrateg } catch (ServletException ex) { throw new HandshakeFailureException( - "Servlet request failed to upgrade to WebSocket, uri=" + requestUrl, ex); + "Servlet request failed to upgrade to WebSocket: " + requestUrl, ex); } catch (IOException ex) { throw new HandshakeFailureException( - "Response update failed during upgrade to WebSocket, uri=" + requestUrl, ex); + "Response update failed during upgrade to WebSocket: " + requestUrl, ex); } } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java index 679313dcfb..d97b99bfb9 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/UndertowRequestUpgradeStrategy.java @@ -56,8 +56,8 @@ import org.springframework.util.ClassUtils; import org.springframework.web.socket.server.HandshakeFailureException; /** - * A {@link org.springframework.web.socket.server.RequestUpgradeStrategy} for use - * with WildFly and its underlying Undertow web server. + * A WebSocket {@code RequestUpgradeStrategy} for use with WildFly and its + * underlying Undertow web server. Also compatible with embedded Undertow usage. * *

Compatible with Undertow 1.0, 1.1, 1.2 - as included in WildFly 8.x and 9.0. * diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/WebLogicRequestUpgradeStrategy.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/WebLogicRequestUpgradeStrategy.java index b52e5c66e0..13843b9bb6 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/WebLogicRequestUpgradeStrategy.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/standard/WebLogicRequestUpgradeStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,7 +42,7 @@ import org.springframework.util.ReflectionUtils; import org.springframework.web.socket.server.HandshakeFailureException; /** - * A WebSocket {@code RequestUpgradeStrategy} for WebLogic 12.1.3. + * A WebSocket {@code RequestUpgradeStrategy} for Oracle's WebLogic 12.1.3 and higher. * * @author Rossen Stoyanchev * @since 4.1 diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/DefaultHandshakeHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/DefaultHandshakeHandler.java index 46e8c2402c..78bf744bc1 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/DefaultHandshakeHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/DefaultHandshakeHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 the original author or authors. + * Copyright 2002-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -54,10 +54,16 @@ import org.springframework.web.socket.server.RequestUpgradeStrategy; *

If the negotiation succeeds, the actual upgrade is delegated to a server-specific * {@link org.springframework.web.socket.server.RequestUpgradeStrategy}, which will update * the response as necessary and initialize the WebSocket. Currently supported servers are - * Tomcat 7 and 8, Jetty 9, and GlassFish 4. + * Jetty 9.x, Tomcat 7.0.47+ and 8.x, Undertow 1.0-1.2, GlassFish 4.1+, WebLogic 12.1.3+. * * @author Rossen Stoyanchev + * @author Juergen Hoeller * @since 4.0 + * @see org.springframework.web.socket.server.jetty.JettyRequestUpgradeStrategy + * @see org.springframework.web.socket.server.standard.TomcatRequestUpgradeStrategy + * @see org.springframework.web.socket.server.standard.UndertowRequestUpgradeStrategy + * @see org.springframework.web.socket.server.standard.GlassFishRequestUpgradeStrategy + * @see org.springframework.web.socket.server.standard.WebLogicRequestUpgradeStrategy */ public class DefaultHandshakeHandler implements HandshakeHandler { @@ -126,6 +132,7 @@ public class DefaultHandshakeHandler implements HandshakeHandler { else { throw new IllegalStateException("No suitable default RequestUpgradeStrategy found"); } + try { Class clazz = ClassUtils.forName(className, DefaultHandshakeHandler.class.getClassLoader()); return (RequestUpgradeStrategy) clazz.newInstance(); @@ -206,7 +213,7 @@ public class DefaultHandshakeHandler implements HandshakeHandler { } catch (IOException ex) { throw new HandshakeFailureException( - "Response update failed during upgrade to WebSocket, uri=" + request.getURI(), ex); + "Response update failed during upgrade to WebSocket: " + request.getURI(), ex); } String subProtocol = selectProtocol(headers.getSecWebSocketProtocol(), wsHandler); @@ -340,8 +347,7 @@ public class DefaultHandshakeHandler implements HandshakeHandler { * in the process of being established. The default implementation calls * {@link org.springframework.http.server.ServerHttpRequest#getPrincipal()} *

Subclasses can provide custom logic for associating a user with a session, - * for example for assigning a name to anonymous users (i.e. not fully - * authenticated). + * for example for assigning a name to anonymous users (i.e. not fully authenticated). * @param request the handshake request * @param wsHandler the WebSocket handler that will handle messages * @param attributes handshake attributes to pass to the WebSocket session