Polishing

This commit is contained in:
Juergen Hoeller
2016-09-26 18:19:04 +02:00
parent f2e1e1b890
commit d04567b99c
4 changed files with 26 additions and 29 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2016 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,13 +50,10 @@ public abstract class Conventions {
* when searching for the 'primary' interface of a proxy.
*/
private static final Set<Class<?>> IGNORED_INTERFACES;
static {
IGNORED_INTERFACES = Collections.unmodifiableSet(
new HashSet<Class<?>>(Arrays.<Class<?>> asList(
Serializable.class,
Externalizable.class,
Cloneable.class,
Comparable.class)));
IGNORED_INTERFACES = Collections.unmodifiableSet(new HashSet<Class<?>>(Arrays.<Class<?>>asList(
Serializable.class, Externalizable.class, Cloneable.class, Comparable.class)));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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,8 +54,8 @@ public class InstanceFilter<T> {
public InstanceFilter(Collection<? extends T> includes,
Collection<? extends T> excludes, boolean matchIfEmpty) {
this.includes = includes != null ? includes : Collections.<T>emptyList();
this.excludes = excludes != null ? excludes : Collections.<T>emptyList();
this.includes = (includes != null ? includes : Collections.<T>emptyList());
this.excludes = (excludes != null ? excludes : Collections.<T>emptyList());
this.matchIfEmpty = matchIfEmpty;
}
@@ -64,7 +64,7 @@ public class InstanceFilter<T> {
* Determine if the specified {code instance} matches this filter.
*/
public boolean match(T instance) {
Assert.notNull(instance, "The instance to match is mandatory");
Assert.notNull(instance, "Instance to match must not be null");
boolean includesSet = !this.includes.isEmpty();
boolean excludesSet = !this.excludes.isEmpty();
@@ -74,11 +74,9 @@ public class InstanceFilter<T> {
boolean matchIncludes = match(instance, this.includes);
boolean matchExcludes = match(instance, this.excludes);
if (!includesSet) {
return !matchExcludes;
}
if (!excludesSet) {
return matchIncludes;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2016 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 @@ public abstract class AbstractBrokerRegistration {
this.clientInboundChannel = clientInboundChannel;
this.clientOutboundChannel = clientOutboundChannel;
this.destinationPrefixes = (destinationPrefixes != null)
? Arrays.<String>asList(destinationPrefixes) : Collections.<String>emptyList();
this.destinationPrefixes = (destinationPrefixes != null ?
Arrays.asList(destinationPrefixes) : Collections.<String>emptyList());
}
@@ -67,6 +67,7 @@ public abstract class AbstractBrokerRegistration {
return this.destinationPrefixes;
}
protected abstract AbstractBrokerMessageHandler getMessageHandler(SubscribableChannel brokerChannel);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -43,8 +43,6 @@ import org.springframework.web.util.UriComponentsBuilder;
*/
public abstract class AbstractWebSocketClient implements WebSocketClient {
protected final Log logger = LogFactory.getLog(getClass());
private static final Set<String> specialHeaders = new HashSet<String>();
static {
@@ -60,11 +58,14 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
}
protected final Log logger = LogFactory.getLog(getClass());
@Override
public ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler,
String uriTemplate, Object... uriVars) {
Assert.notNull(uriTemplate, "uriTemplate must not be null");
Assert.notNull(uriTemplate, "'uriTemplate' must not be null");
URI uri = UriComponentsBuilder.fromUriString(uriTemplate).buildAndExpand(uriVars).encode().toUri();
return doHandshake(webSocketHandler, null, uri);
}
@@ -73,7 +74,7 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
public final ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler,
WebSocketHttpHeaders headers, URI uri) {
Assert.notNull(webSocketHandler, "webSocketHandler must not be null");
Assert.notNull(webSocketHandler, "WebSocketHandler must not be null");
assertUri(uri);
if (logger.isDebugEnabled()) {
@@ -89,25 +90,26 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
}
}
List<String> subProtocols = ((headers != null) && (headers.getSecWebSocketProtocol() != null)) ?
headers.getSecWebSocketProtocol() : Collections.<String>emptyList();
List<String> subProtocols = (headers != null && headers.getSecWebSocketProtocol() != null ?
headers.getSecWebSocketProtocol() : Collections.<String>emptyList());
List<WebSocketExtension> extensions = ((headers != null) && (headers.getSecWebSocketExtensions() != null)) ?
headers.getSecWebSocketExtensions() : Collections.<WebSocketExtension>emptyList();
List<WebSocketExtension> extensions = (headers != null && headers.getSecWebSocketExtensions() != null ?
headers.getSecWebSocketExtensions() : Collections.<WebSocketExtension>emptyList());
return doHandshakeInternal(webSocketHandler, headersToUse, uri, subProtocols, extensions,
Collections.<String, Object>emptyMap());
}
protected void assertUri(URI uri) {
Assert.notNull(uri, "uri must not be null");
Assert.notNull(uri, "URI must not be null");
String scheme = uri.getScheme();
Assert.isTrue(scheme != null && ("ws".equals(scheme) || "wss".equals(scheme)), "Invalid scheme: " + scheme);
if (!"ws".equals(scheme) && !"wss".equals(scheme)) {
throw new IllegalArgumentException("Invalid scheme: " + scheme);
}
}
/**
* Perform the actual handshake to establish a connection to the server.
*
* @param webSocketHandler the client-side handler for WebSocket messages
* @param headers HTTP headers to use for the handshake, with unwanted (forbidden)
* headers filtered out, never {@code null}
@@ -116,7 +118,6 @@ public abstract class AbstractWebSocketClient implements WebSocketClient {
* @param extensions requested WebSocket extensions, or an empty list
* @param attributes attributes to associate with the WebSocketSession, i.e. via
* {@link WebSocketSession#getAttributes()}; currently always an empty map.
*
* @return the established WebSocket session wrapped in a ListenableFuture.
*/
protected abstract ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler webSocketHandler,