Merged web.socket.messaging.config into web.socket.config and introduced web.socket.config.annotation

This commit is contained in:
Juergen Hoeller
2013-12-02 23:54:38 +01:00
parent ab2949f2b7
commit e62cd84ca2
27 changed files with 115 additions and 66 deletions

View File

@@ -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<M> implements WebSock
return this.sockJsServiceRegistration;
}
final M getMappings() {
public final M getMappings() {
M mappings = createMappings();
if (this.sockJsServiceRegistration != null) {

View File

@@ -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<WebSocketConfigurer> configurers) {
if (CollectionUtils.isEmpty(configurers)) {
return;
if (!CollectionUtils.isEmpty(configurers)) {
this.configurers.addAll(configurers);
}
this.configurers.addAll(configurers);
}

View File

@@ -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<WebSocketMessageBrokerConfigurer> configurers) {
if (CollectionUtils.isEmpty(configurers)) {
return;
if (!CollectionUtils.isEmpty(configurers)) {
this.configurers.addAll(configurers);
}
this.configurers.addAll(configurers);
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<MultiValueMap<HttpRequestHandler, String>> {
public ServletWebSocketHandlerRegistration(TaskScheduler sockJsTaskScheduler) {
super(sockJsTaskScheduler);
}

View File

@@ -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<String, Object> urlMap = new LinkedHashMap<String, Object>();
for (ServletWebSocketHandlerRegistration registration : this.registrations) {
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();

View File

@@ -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

View File

@@ -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.

View File

@@ -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.

View File

@@ -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<String, Object> urlMap = new LinkedHashMap<String, Object>();
for (WebMvcStompWebSocketEndpointRegistration registration : this.registrations) {
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();

View File

@@ -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<HttpRequestHandler, String> getMappings() {
public final MultiValueMap<HttpRequestHandler, String> getMappings() {
MultiValueMap<HttpRequestHandler, String> mappings = new LinkedMultiValueMap<HttpRequestHandler, String>();
if (this.registration != null) {
SockJsService sockJsService = this.registration.getSockJsService();

View File

@@ -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;

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -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

View File

@@ -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;

View File

@@ -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;