From e62cd84ca23a176912562e175197167d62a08705 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Mon, 2 Dec 2013 23:54:38 +0100 Subject: [PATCH] Merged web.socket.messaging.config into web.socket.config and introduced web.socket.config.annotation --- .../AbstractWebSocketHandlerRegistration.java | 5 ++--- .../DelegatingWebSocketConfiguration.java | 7 +++---- ...ngWebSocketMessageBrokerConfiguration.java | 7 +++---- .../{ => annotation}/EnableWebSocket.java | 3 ++- .../EnableWebSocketMessageBroker.java | 3 ++- .../ServletWebSocketHandlerRegistration.java | 3 +-- .../ServletWebSocketHandlerRegistry.java | 15 ++++++------- .../SockJsServiceRegistration.java | 4 ++-- .../annotation}/StompEndpointRegistry.java | 2 +- .../StompWebSocketEndpointRegistration.java | 3 +-- .../WebMvcStompEndpointRegistry.java | 13 +++++++----- ...MvcStompWebSocketEndpointRegistration.java | 5 ++--- .../WebSocketConfigurationSupport.java | 2 +- .../{ => annotation}/WebSocketConfigurer.java | 4 ++-- .../WebSocketHandlerRegistration.java | 2 +- .../WebSocketHandlerRegistry.java | 2 +- ...cketMessageBrokerConfigurationSupport.java | 6 +----- .../WebSocketMessageBrokerConfigurer.java | 4 ++-- .../config/annotation/package-info.java | 21 +++++++++++++++++++ .../web/socket/messaging/package-info.java | 21 +++++++++++++++++++ .../web/socket/WebSocketIntegrationTests.java | 6 +++--- ...ractWebSocketHandlerRegistrationTests.java | 3 ++- .../WebMvcStompEndpointRegistrationTests.java | 6 ++++-- .../WebMvcStompEndpointRegistryTests.java | 7 ++++--- .../config/WebSocketConfigurationTests.java | 3 +++ ...essageBrokerConfigurationSupportTests.java | 18 +++++++++------- .../SimpAnnotationMethodIntegrationTests.java | 6 +++--- 27 files changed, 115 insertions(+), 66 deletions(-) rename spring-websocket/src/main/java/org/springframework/web/socket/config/{ => annotation}/AbstractWebSocketHandlerRegistration.java (98%) rename spring-websocket/src/main/java/org/springframework/web/socket/config/{ => annotation}/DelegatingWebSocketConfiguration.java (91%) rename spring-websocket/src/main/java/org/springframework/web/socket/{messaging/config => config/annotation}/DelegatingWebSocketMessageBrokerConfiguration.java (94%) rename spring-websocket/src/main/java/org/springframework/web/socket/config/{ => annotation}/EnableWebSocket.java (96%) rename spring-websocket/src/main/java/org/springframework/web/socket/{messaging/config => config/annotation}/EnableWebSocketMessageBroker.java (97%) rename spring-websocket/src/main/java/org/springframework/web/socket/config/{ => annotation}/ServletWebSocketHandlerRegistration.java (97%) rename spring-websocket/src/main/java/org/springframework/web/socket/config/{ => annotation}/ServletWebSocketHandlerRegistry.java (84%) rename spring-websocket/src/main/java/org/springframework/web/socket/config/{ => annotation}/SockJsServiceRegistration.java (97%) rename spring-websocket/src/main/java/org/springframework/web/socket/{messaging/config => config/annotation}/StompEndpointRegistry.java (94%) rename spring-websocket/src/main/java/org/springframework/web/socket/{messaging/config => config/annotation}/StompWebSocketEndpointRegistration.java (89%) rename spring-websocket/src/main/java/org/springframework/web/socket/{messaging/config => config/annotation}/WebMvcStompEndpointRegistry.java (92%) rename spring-websocket/src/main/java/org/springframework/web/socket/{messaging/config => config/annotation}/WebMvcStompWebSocketEndpointRegistration.java (95%) rename spring-websocket/src/main/java/org/springframework/web/socket/config/{ => annotation}/WebSocketConfigurationSupport.java (97%) rename spring-websocket/src/main/java/org/springframework/web/socket/config/{ => annotation}/WebSocketConfigurer.java (86%) rename spring-websocket/src/main/java/org/springframework/web/socket/config/{ => annotation}/WebSocketHandlerRegistration.java (96%) rename spring-websocket/src/main/java/org/springframework/web/socket/config/{ => annotation}/WebSocketHandlerRegistry.java (94%) rename spring-websocket/src/main/java/org/springframework/web/socket/{messaging/config => config/annotation}/WebSocketMessageBrokerConfigurationSupport.java (95%) rename spring-websocket/src/main/java/org/springframework/web/socket/{messaging/config => config/annotation}/WebSocketMessageBrokerConfigurer.java (91%) create mode 100644 spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/package-info.java create mode 100644 spring-websocket/src/main/java/org/springframework/web/socket/messaging/package-info.java rename spring-websocket/src/test/java/org/springframework/web/socket/{messaging => }/config/WebMvcStompEndpointRegistrationTests.java (94%) rename spring-websocket/src/test/java/org/springframework/web/socket/{messaging => }/config/WebMvcStompEndpointRegistryTests.java (93%) rename spring-websocket/src/test/java/org/springframework/web/socket/{messaging => }/config/WebSocketMessageBrokerConfigurationSupportTests.java (92%) diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/AbstractWebSocketHandlerRegistration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/AbstractWebSocketHandlerRegistration.java similarity index 98% rename from spring-websocket/src/main/java/org/springframework/web/socket/config/AbstractWebSocketHandlerRegistration.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/AbstractWebSocketHandlerRegistration.java index 229b1769e9..9d3b01353c 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/AbstractWebSocketHandlerRegistration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/AbstractWebSocketHandlerRegistration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.socket.config; +package org.springframework.web.socket.config.annotation; import java.util.Arrays; @@ -103,8 +103,7 @@ public abstract class AbstractWebSocketHandlerRegistration implements WebSock return this.sockJsServiceRegistration; } - final M getMappings() { - + public final M getMappings() { M mappings = createMappings(); if (this.sockJsServiceRegistration != null) { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/DelegatingWebSocketConfiguration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketConfiguration.java similarity index 91% rename from spring-websocket/src/main/java/org/springframework/web/socket/config/DelegatingWebSocketConfiguration.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketConfiguration.java index d625e77a51..3ab769d0b3 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/DelegatingWebSocketConfiguration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.socket.config; +package org.springframework.web.socket.config.annotation; import java.util.ArrayList; import java.util.List; @@ -39,10 +39,9 @@ public class DelegatingWebSocketConfiguration extends WebSocketConfigurationSupp @Autowired(required = false) public void setConfigurers(List configurers) { - if (CollectionUtils.isEmpty(configurers)) { - return; + if (!CollectionUtils.isEmpty(configurers)) { + this.configurers.addAll(configurers); } - this.configurers.addAll(configurers); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/DelegatingWebSocketMessageBrokerConfiguration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.java similarity index 94% rename from spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/DelegatingWebSocketMessageBrokerConfiguration.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.java index 433b19ba1b..6f2be10e72 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/DelegatingWebSocketMessageBrokerConfiguration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/DelegatingWebSocketMessageBrokerConfiguration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.socket.messaging.config; +package org.springframework.web.socket.config.annotation; import java.util.ArrayList; import java.util.List; @@ -44,10 +44,9 @@ public class DelegatingWebSocketMessageBrokerConfiguration extends WebSocketMess @Autowired(required=false) public void setConfigurers(List configurers) { - if (CollectionUtils.isEmpty(configurers)) { - return; + if (!CollectionUtils.isEmpty(configurers)) { + this.configurers.addAll(configurers); } - this.configurers.addAll(configurers); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/EnableWebSocket.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/EnableWebSocket.java similarity index 96% rename from spring-websocket/src/main/java/org/springframework/web/socket/config/EnableWebSocket.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/EnableWebSocket.java index aefba3eb78..15722bdf2e 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/EnableWebSocket.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/EnableWebSocket.java @@ -10,7 +10,8 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package org.springframework.web.socket.config; + +package org.springframework.web.socket.config.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/EnableWebSocketMessageBroker.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/EnableWebSocketMessageBroker.java similarity index 97% rename from spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/EnableWebSocketMessageBroker.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/EnableWebSocketMessageBroker.java index 3b9c8192e0..6d6a869728 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/EnableWebSocketMessageBroker.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/EnableWebSocketMessageBroker.java @@ -10,7 +10,8 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package org.springframework.web.socket.messaging.config; + +package org.springframework.web.socket.config.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/ServletWebSocketHandlerRegistration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/ServletWebSocketHandlerRegistration.java similarity index 97% rename from spring-websocket/src/main/java/org/springframework/web/socket/config/ServletWebSocketHandlerRegistration.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/ServletWebSocketHandlerRegistration.java index cadc7d46c9..b3709ea722 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/ServletWebSocketHandlerRegistration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/ServletWebSocketHandlerRegistration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.socket.config; +package org.springframework.web.socket.config.annotation; import java.util.Arrays; @@ -40,7 +40,6 @@ import org.springframework.web.socket.sockjs.SockJsService; public class ServletWebSocketHandlerRegistration extends AbstractWebSocketHandlerRegistration> { - public ServletWebSocketHandlerRegistration(TaskScheduler sockJsTaskScheduler) { super(sockJsTaskScheduler); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/ServletWebSocketHandlerRegistry.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/ServletWebSocketHandlerRegistry.java similarity index 84% rename from spring-websocket/src/main/java/org/springframework/web/socket/config/ServletWebSocketHandlerRegistry.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/ServletWebSocketHandlerRegistry.java index 205fbf3ca8..a50a3cf218 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/ServletWebSocketHandlerRegistry.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/ServletWebSocketHandlerRegistry.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.socket.config; +package org.springframework.web.socket.config.annotation; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -51,16 +51,17 @@ public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry @Override public WebSocketHandlerRegistration addHandler(WebSocketHandler webSocketHandler, String... paths) { - ServletWebSocketHandlerRegistration r = new ServletWebSocketHandlerRegistration(this.sockJsTaskScheduler); - r.addHandler(webSocketHandler, paths); - this.registrations.add(r); - return r; + ServletWebSocketHandlerRegistration registration = + new ServletWebSocketHandlerRegistration(this.sockJsTaskScheduler); + registration.addHandler(webSocketHandler, paths); + this.registrations.add(registration); + return registration; } /** - * Returns a {@link HandlerMapping} with mapped {@link HttpRequestHandler}s. + * Return a {@link HandlerMapping} with mapped {@link HttpRequestHandler}s. */ - AbstractHandlerMapping getHandlerMapping() { + public AbstractHandlerMapping getHandlerMapping() { Map urlMap = new LinkedHashMap(); for (ServletWebSocketHandlerRegistration registration : this.registrations) { MultiValueMap mappings = registration.getMappings(); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/SockJsServiceRegistration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/SockJsServiceRegistration.java similarity index 97% rename from spring-websocket/src/main/java/org/springframework/web/socket/config/SockJsServiceRegistration.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/SockJsServiceRegistration.java index 5cdc7d595d..80f876c9aa 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/SockJsServiceRegistration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/SockJsServiceRegistration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.socket.config; +package org.springframework.web.socket.config.annotation; import java.util.ArrayList; import java.util.Arrays; @@ -29,7 +29,7 @@ import org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsServ /** * A helper class for configuring SockJS fallback options, typically used indirectly, in - * conjunction with {@link EnableWebSocket @EnableWebSocket} and + * conjunction with {@link org.springframework.web.socket.config.annotation.EnableWebSocket @EnableWebSocket} and * {@link WebSocketConfigurer}. * * @author Rossen Stoyanchev diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/StompEndpointRegistry.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/StompEndpointRegistry.java similarity index 94% rename from spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/StompEndpointRegistry.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/StompEndpointRegistry.java index 8889e5ee72..89ff6719da 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/StompEndpointRegistry.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/StompEndpointRegistry.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.socket.messaging.config; +package org.springframework.web.socket.config.annotation; /** * A contract for registering STOMP over WebSocket endpoints. diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/StompWebSocketEndpointRegistration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/StompWebSocketEndpointRegistration.java similarity index 89% rename from spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/StompWebSocketEndpointRegistration.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/StompWebSocketEndpointRegistration.java index 0107e024a7..14b5402352 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/StompWebSocketEndpointRegistration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/StompWebSocketEndpointRegistration.java @@ -14,10 +14,9 @@ * limitations under the License. */ -package org.springframework.web.socket.messaging.config; +package org.springframework.web.socket.config.annotation; import org.springframework.web.socket.server.HandshakeHandler; -import org.springframework.web.socket.config.SockJsServiceRegistration; /** * A contract for configuring a STOMP over WebSocket endpoint. diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/WebMvcStompEndpointRegistry.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistry.java similarity index 92% rename from spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/WebMvcStompEndpointRegistry.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistry.java index 2a01f88bff..a1f76751b5 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/WebMvcStompEndpointRegistry.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompEndpointRegistry.java @@ -14,12 +14,14 @@ * limitations under the License. */ -package org.springframework.web.socket.messaging.config; +package org.springframework.web.socket.config.annotation; -import java.util.*; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import org.springframework.messaging.simp.handler.UserSessionRegistry; -import org.springframework.web.socket.messaging.StompSubProtocolHandler; import org.springframework.scheduling.TaskScheduler; import org.springframework.util.Assert; import org.springframework.util.MultiValueMap; @@ -27,6 +29,7 @@ import org.springframework.web.HttpRequestHandler; import org.springframework.web.servlet.handler.AbstractHandlerMapping; import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping; import org.springframework.web.socket.WebSocketHandler; +import org.springframework.web.socket.messaging.StompSubProtocolHandler; import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler; import org.springframework.web.socket.support.WebSocketHandlerDecorator; @@ -98,9 +101,9 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry { } /** - * Returns a handler mapping with the mapped ViewControllers; or {@code null} in case of no registrations. + * Return a handler mapping with the mapped ViewControllers; or {@code null} in case of no registrations. */ - protected AbstractHandlerMapping getHandlerMapping() { + public AbstractHandlerMapping getHandlerMapping() { Map urlMap = new LinkedHashMap(); for (WebMvcStompWebSocketEndpointRegistration registration : this.registrations) { MultiValueMap mappings = registration.getMappings(); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/WebMvcStompWebSocketEndpointRegistration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompWebSocketEndpointRegistration.java similarity index 95% rename from spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/WebMvcStompWebSocketEndpointRegistration.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompWebSocketEndpointRegistration.java index 74ff5e9526..0844b4cd5f 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/WebMvcStompWebSocketEndpointRegistration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebMvcStompWebSocketEndpointRegistration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.socket.messaging.config; +package org.springframework.web.socket.config.annotation; import org.springframework.scheduling.TaskScheduler; import org.springframework.util.Assert; @@ -23,7 +23,6 @@ import org.springframework.util.MultiValueMap; import org.springframework.web.HttpRequestHandler; import org.springframework.web.socket.WebSocketHandler; import org.springframework.web.socket.server.HandshakeHandler; -import org.springframework.web.socket.config.SockJsServiceRegistration; import org.springframework.web.socket.server.support.WebSocketHttpRequestHandler; import org.springframework.web.socket.sockjs.SockJsHttpRequestHandler; import org.springframework.web.socket.sockjs.SockJsService; @@ -82,7 +81,7 @@ public class WebMvcStompWebSocketEndpointRegistration implements StompWebSocketE return this.registration; } - protected final MultiValueMap getMappings() { + public final MultiValueMap getMappings() { MultiValueMap mappings = new LinkedMultiValueMap(); if (this.registration != null) { SockJsService sockJsService = this.registration.getSockJsService(); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketConfigurationSupport.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationSupport.java similarity index 97% rename from spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketConfigurationSupport.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationSupport.java index fcf4b62f99..3d1e442724 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketConfigurationSupport.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationSupport.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.socket.config; +package org.springframework.web.socket.config.annotation; import org.springframework.context.annotation.Bean; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketConfigurer.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketConfigurer.java similarity index 86% rename from spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketConfigurer.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketConfigurer.java index d429c1abd0..99a44ab4ca 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketConfigurer.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketConfigurer.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package org.springframework.web.socket.config; +package org.springframework.web.socket.config.annotation; import org.springframework.web.socket.WebSocketHandler; /** * Defines callback methods to configure the WebSocket request handling - * via {@link EnableWebSocket @EnableWebSocket}. + * via {@link org.springframework.web.socket.config.annotation.EnableWebSocket @EnableWebSocket}. * * @author Rossen Stoyanchev * @since 4.0 diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketHandlerRegistration.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketHandlerRegistration.java similarity index 96% rename from spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketHandlerRegistration.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketHandlerRegistration.java index 9fdf654d50..8debdceb99 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketHandlerRegistration.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketHandlerRegistration.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.socket.config; +package org.springframework.web.socket.config.annotation; import org.springframework.web.socket.WebSocketHandler; import org.springframework.web.socket.server.HandshakeHandler; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketHandlerRegistry.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketHandlerRegistry.java similarity index 94% rename from spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketHandlerRegistry.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketHandlerRegistry.java index 53a937873a..0cc06d67be 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketHandlerRegistry.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketHandlerRegistry.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.socket.config; +package org.springframework.web.socket.config.annotation; import org.springframework.web.socket.WebSocketHandler; diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/WebSocketMessageBrokerConfigurationSupport.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupport.java similarity index 95% rename from spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/WebSocketMessageBrokerConfigurationSupport.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupport.java index 11335e72ea..e367fbae09 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/WebSocketMessageBrokerConfigurationSupport.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupport.java @@ -14,14 +14,13 @@ * limitations under the License. */ -package org.springframework.web.socket.messaging.config; +package org.springframework.web.socket.config.annotation; import org.springframework.context.annotation.Bean; import org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.socket.WebSocketHandler; -import org.springframework.web.socket.config.SockJsServiceRegistration; import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler; /** @@ -37,16 +36,13 @@ import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler; */ public abstract class WebSocketMessageBrokerConfigurationSupport extends AbstractMessageBrokerConfiguration { - protected WebSocketMessageBrokerConfigurationSupport() { } @Bean public HandlerMapping stompWebSocketHandlerMapping() { - WebMvcStompEndpointRegistry registry = new WebMvcStompEndpointRegistry( subProtocolWebSocketHandler(), userSessionRegistry(), messageBrokerSockJsTaskScheduler()); - registerStompEndpoints(registry); return registry.getHandlerMapping(); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/WebSocketMessageBrokerConfigurer.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurer.java similarity index 91% rename from spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/WebSocketMessageBrokerConfigurer.java rename to spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurer.java index f7bba9c58f..e8de3fb717 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/config/WebSocketMessageBrokerConfigurer.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.socket.messaging.config; +package org.springframework.web.socket.config.annotation; import org.springframework.messaging.simp.config.ChannelRegistration; @@ -24,7 +24,7 @@ import org.springframework.messaging.simp.config.MessageBrokerRegistry; * Defines methods for configuring message handling with simple messaging * protocols (e.g. STOMP) from WebSocket clients. Typically used to customize * the configuration provided via - * {@link EnableWebSocketMessageBroker @EnableWebSocketMessageBroker}. + * {@link org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker @EnableWebSocketMessageBroker}. * * @author Rossen Stoyanchev * @since 4.0 diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/package-info.java b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/package-info.java new file mode 100644 index 0000000000..9e291a5f9e --- /dev/null +++ b/spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2002-2013 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Support for annotation-based WebSocket setup in configuration classes. + */ +package org.springframework.web.socket.config.annotation; + diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/messaging/package-info.java b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/package-info.java new file mode 100644 index 0000000000..e4e2e56959 --- /dev/null +++ b/spring-websocket/src/main/java/org/springframework/web/socket/messaging/package-info.java @@ -0,0 +1,21 @@ +/* + * Copyright 2002-2013 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * WebSocket integration for Spring's messaging module. + */ +package org.springframework.web.socket.messaging; + diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java index b1d5bdc3e7..14c88ad4d6 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/WebSocketIntegrationTests.java @@ -31,9 +31,9 @@ import org.springframework.web.socket.adapter.WebSocketHandlerAdapter; import org.springframework.web.socket.client.endpoint.StandardWebSocketClient; import org.springframework.web.socket.client.jetty.JettyWebSocketClient; import org.springframework.web.socket.server.support.DefaultHandshakeHandler; -import org.springframework.web.socket.config.EnableWebSocket; -import org.springframework.web.socket.config.WebSocketConfigurer; -import org.springframework.web.socket.config.WebSocketHandlerRegistry; +import org.springframework.web.socket.config.annotation.EnableWebSocket; +import org.springframework.web.socket.config.annotation.WebSocketConfigurer; +import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; import org.springframework.web.socket.support.WebSocketHttpHeaders; import static org.junit.Assert.*; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/AbstractWebSocketHandlerRegistrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/AbstractWebSocketHandlerRegistrationTests.java index 9031919138..4a95ab5f0d 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/AbstractWebSocketHandlerRegistrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/AbstractWebSocketHandlerRegistrationTests.java @@ -26,6 +26,7 @@ import org.mockito.Mockito; import org.springframework.scheduling.TaskScheduler; import org.springframework.web.socket.WebSocketHandler; import org.springframework.web.socket.adapter.TextWebSocketHandlerAdapter; +import org.springframework.web.socket.config.annotation.AbstractWebSocketHandlerRegistration; import org.springframework.web.socket.server.support.DefaultHandshakeHandler; import org.springframework.web.socket.server.HandshakeHandler; import org.springframework.web.socket.server.HandshakeInterceptor; @@ -38,7 +39,7 @@ import org.springframework.web.socket.sockjs.transport.handler.WebSocketTranspor import static org.junit.Assert.*; /** - * Test fixture for {@link AbstractWebSocketHandlerRegistration}. + * Test fixture for {@link org.springframework.web.socket.config.annotation.AbstractWebSocketHandlerRegistration}. * * @author Rossen Stoyanchev */ diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/config/WebMvcStompEndpointRegistrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/WebMvcStompEndpointRegistrationTests.java similarity index 94% rename from spring-websocket/src/test/java/org/springframework/web/socket/messaging/config/WebMvcStompEndpointRegistrationTests.java rename to spring-websocket/src/test/java/org/springframework/web/socket/config/WebMvcStompEndpointRegistrationTests.java index 5f1e8a466d..e97cdc12b4 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/config/WebMvcStompEndpointRegistrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/WebMvcStompEndpointRegistrationTests.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.springframework.web.socket.messaging.config; +package org.springframework.web.socket.config; import java.util.Arrays; import java.util.List; @@ -23,10 +23,12 @@ import java.util.Map; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; + import org.springframework.messaging.support.channel.ExecutorSubscribableChannel; import org.springframework.scheduling.TaskScheduler; import org.springframework.util.MultiValueMap; import org.springframework.web.HttpRequestHandler; +import org.springframework.web.socket.config.annotation.WebMvcStompWebSocketEndpointRegistration; import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler; import org.springframework.web.socket.server.support.DefaultHandshakeHandler; import org.springframework.web.socket.server.support.WebSocketHttpRequestHandler; @@ -38,7 +40,7 @@ import org.springframework.web.socket.sockjs.transport.handler.WebSocketTranspor import static org.junit.Assert.*; /** - * Test fixture for {@link WebMvcStompWebSocketEndpointRegistration}. + * Test fixture for {@link org.springframework.web.socket.config.annotation.WebMvcStompWebSocketEndpointRegistration}. * * @author Rossen Stoyanchev */ diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/config/WebMvcStompEndpointRegistryTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/WebMvcStompEndpointRegistryTests.java similarity index 93% rename from spring-websocket/src/test/java/org/springframework/web/socket/messaging/config/WebMvcStompEndpointRegistryTests.java rename to spring-websocket/src/test/java/org/springframework/web/socket/config/WebMvcStompEndpointRegistryTests.java index 339e06b59f..0a8e602fb8 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/config/WebMvcStompEndpointRegistryTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/WebMvcStompEndpointRegistryTests.java @@ -14,28 +14,29 @@ * limitations under the License. */ -package org.springframework.web.socket.messaging.config; +package org.springframework.web.socket.config; import java.util.Map; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; + import org.springframework.messaging.MessageChannel; import org.springframework.messaging.SubscribableChannel; import org.springframework.messaging.simp.handler.DefaultUserSessionRegistry; import org.springframework.messaging.simp.handler.UserSessionRegistry; import org.springframework.scheduling.TaskScheduler; import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping; +import org.springframework.web.socket.config.annotation.WebMvcStompEndpointRegistry; import org.springframework.web.socket.messaging.StompSubProtocolHandler; import org.springframework.web.socket.messaging.SubProtocolHandler; import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler; import static org.junit.Assert.*; -import static org.junit.Assert.assertEquals; /** - * Test fixture for {@link WebMvcStompEndpointRegistry}. + * Test fixture for {@link org.springframework.web.socket.config.annotation.WebMvcStompEndpointRegistry}. * * @author Rossen Stoyanchev */ diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/config/WebSocketConfigurationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/WebSocketConfigurationTests.java index a2d077b45c..de6687bad4 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/config/WebSocketConfigurationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/WebSocketConfigurationTests.java @@ -34,6 +34,9 @@ import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.adapter.WebSocketHandlerAdapter; import org.springframework.web.socket.client.endpoint.StandardWebSocketClient; import org.springframework.web.socket.client.jetty.JettyWebSocketClient; +import org.springframework.web.socket.config.annotation.EnableWebSocket; +import org.springframework.web.socket.config.annotation.WebSocketConfigurer; +import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; import org.springframework.web.socket.server.HandshakeHandler; import org.springframework.web.socket.sockjs.transport.handler.WebSocketTransportHandler; diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/config/WebSocketMessageBrokerConfigurationSupportTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/config/WebSocketMessageBrokerConfigurationSupportTests.java similarity index 92% rename from spring-websocket/src/test/java/org/springframework/web/socket/messaging/config/WebSocketMessageBrokerConfigurationSupportTests.java rename to spring-websocket/src/test/java/org/springframework/web/socket/config/WebSocketMessageBrokerConfigurationSupportTests.java index c852431edc..041df76125 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/config/WebSocketMessageBrokerConfigurationSupportTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/config/WebSocketMessageBrokerConfigurationSupportTests.java @@ -14,10 +14,15 @@ * limitations under the License. */ -package org.springframework.web.socket.messaging.config; +package org.springframework.web.socket.config; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; import org.junit.Before; import org.junit.Test; + import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -31,24 +36,23 @@ import org.springframework.messaging.simp.config.ChannelRegistration; import org.springframework.messaging.simp.config.MessageBrokerRegistry; import org.springframework.messaging.simp.stomp.StompCommand; import org.springframework.messaging.simp.stomp.StompHeaderAccessor; -import org.springframework.web.socket.messaging.StompTextMessageBuilder; import org.springframework.messaging.support.channel.AbstractSubscribableChannel; import org.springframework.messaging.support.channel.ExecutorSubscribableChannel; import org.springframework.stereotype.Controller; import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.handler.SimpleUrlHandlerMapping; import org.springframework.web.socket.TextMessage; +import org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration; +import org.springframework.web.socket.config.annotation.StompEndpointRegistry; +import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; +import org.springframework.web.socket.messaging.StompTextMessageBuilder; import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler; import org.springframework.web.socket.support.TestWebSocketSession; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - import static org.junit.Assert.*; /** - * Test fixture for {@link WebSocketMessageBrokerConfigurationSupport}. + * Test fixture for {@link org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurationSupport}. * * @author Rossen Stoyanchev */ diff --git a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/SimpAnnotationMethodIntegrationTests.java b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/SimpAnnotationMethodIntegrationTests.java index 6d3c1c9b8a..2e25fee684 100644 --- a/spring-websocket/src/test/java/org/springframework/web/socket/messaging/SimpAnnotationMethodIntegrationTests.java +++ b/spring-websocket/src/test/java/org/springframework/web/socket/messaging/SimpAnnotationMethodIntegrationTests.java @@ -50,9 +50,9 @@ import org.springframework.web.socket.WebSocketSession; import org.springframework.web.socket.adapter.TextWebSocketHandlerAdapter; import org.springframework.web.socket.client.endpoint.StandardWebSocketClient; import org.springframework.web.socket.client.jetty.JettyWebSocketClient; -import org.springframework.web.socket.messaging.config.DelegatingWebSocketMessageBrokerConfiguration; -import org.springframework.web.socket.messaging.config.StompEndpointRegistry; -import org.springframework.web.socket.messaging.config.WebSocketMessageBrokerConfigurer; +import org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration; +import org.springframework.web.socket.config.annotation.StompEndpointRegistry; +import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer; import org.springframework.web.socket.server.HandshakeHandler; import static org.junit.Assert.*;