General polish of new 4.0 classes

Apply consistent styling to new classes introduced in Spring 4.0.

- Javadoc line wrapping, whitespace and formatting
- General code whitespace
- Consistent Assert.notNull messages
This commit is contained in:
Phillip Webb
2013-11-26 14:47:39 -08:00
parent 690051f46c
commit 15698860e1
190 changed files with 350 additions and 695 deletions

View File

@@ -35,7 +35,6 @@ public interface MessageChannel {
* non-recoverable errors. Otherwise, if the Message cannot be sent for a non-fatal
* reason this method will return 'false', and if the Message is sent successfully, it
* will return 'true'.
*
* <p>Depending on the implementation, this method may block indefinitely. To provide a
* maximum wait time, use {@link #send(Message, long)}.
* @param message the {@link Message} to send

View File

@@ -32,11 +32,9 @@ public interface MessageHandler {
* message, but fails to do so, a {@code MessageHandlingException} is
* thrown. In the last case it is recommended to treat the message as tainted
* and go into an error scenario.
* <p>
* When the handling results in a failure of another message being sent
* <p>When the handling results in a failure of another message being sent
* (e.g. a "reply" message), that failure will trigger a
* {@code MessageDeliveryException}.
*
* @param message the message to be handled
* reply related to the handling of the message
*/

View File

@@ -100,6 +100,7 @@ public final class MessageHeaders implements Map<String, Object>, Serializable {
this.headers.put(TIMESTAMP, new Long(System.currentTimeMillis()));
}
public UUID getId() {
return this.get(ID, UUID.class);
}
@@ -109,12 +110,12 @@ public final class MessageHeaders implements Map<String, Object>, Serializable {
}
public Object getReplyChannel() {
return this.get(REPLY_CHANNEL);
}
return this.get(REPLY_CHANNEL);
}
public Object getErrorChannel() {
return this.get(ERROR_CHANNEL);
}
public Object getErrorChannel() {
return this.get(ERROR_CHANNEL);
}
@SuppressWarnings("unchecked")
public <T> T get(Object key, Class<T> type) {

View File

@@ -35,9 +35,9 @@ public interface PollableChannel extends MessageChannel {
* Receive a message from this channel, blocking until either a message is available
* or the specified timeout period elapses.
* @param timeout the timeout in milliseconds or
* {@link MessageChannel#INDEFINITE_TIMEOUT}.
* {@link MessageChannel#INDEFINITE_TIMEOUT}.
* @return the next available {@link Message} or {@code null} if the specified timeout
* period elapses or the message reception is interrupted
* period elapses or the message reception is interrupted
*/
Message<?> receive(long timeout);

View File

@@ -16,7 +16,6 @@
package org.springframework.messaging;
/**
* Interface for any MessageChannel implementation that accepts subscribers.
* The subscribers must implement the {@link MessageHandler} interface and
@@ -30,14 +29,14 @@ public interface SubscribableChannel extends MessageChannel {
/**
* Register a {@link MessageHandler} as a subscriber to this channel.
* @return {@code true} if the channel was not already subscribed to the specified
* handler
* handler
*/
boolean subscribe(MessageHandler handler);
/**
* Remove a {@link MessageHandler} from the subscribers of this channel.
* @return {@code true} if the channel was previously subscribed to the specified
* handler
* handler
*/
boolean unsubscribe(MessageHandler handler);

View File

@@ -21,8 +21,10 @@ import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.messaging.MessageChannel;
import org.springframework.util.Assert;
/**
* {@link DestinationResolver} that resolves against named beans contained in a
* {@link BeanFactory}.
*
* @author Mark Fisher
* @since 4.0
*/
@@ -36,7 +38,6 @@ public class BeanFactoryMessageChannelDestinationResolver implements Destination
* <p>The BeanFactory to access must be set via <code>setBeanFactory</code>.
* This will happen automatically if this resolver is defined within an
* ApplicationContext thereby receiving the callback upon initialization.
*
* @see #setBeanFactory
*/
public BeanFactoryMessageChannelDestinationResolver() {
@@ -51,7 +52,6 @@ public class BeanFactoryMessageChannelDestinationResolver implements Destination
* replaced by the {@link BeanFactory} that creates it (c.f. the
* {@link BeanFactoryAware} contract). So only use this constructor if you
* are instantiating this object explicitly rather than defining a bean.
*
* @param beanFactory the bean factory to be used to lookup {@link MessageChannel}s.
*/
public BeanFactoryMessageChannelDestinationResolver(BeanFactory beanFactory) {
@@ -62,7 +62,7 @@ public class BeanFactoryMessageChannelDestinationResolver implements Destination
@Override
public MessageChannel resolveDestination(String name) {
Assert.state(this.beanFactory != null, "BeanFactory is required");
Assert.state(this.beanFactory != null, "BeanFactory must not be null");
try {
return this.beanFactory.getBean(name, MessageChannel.class);
}

View File

@@ -18,7 +18,6 @@ package org.springframework.messaging.core;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
/**
* A {@link MessageReceivingOperations} that can resolve a String-based destinations.
*

View File

@@ -20,7 +20,6 @@ import java.util.Map;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
/**
* A {@link MessageRequestReplyOperations} that can resolve a String-based destinations.
*

View File

@@ -20,7 +20,6 @@ import java.util.Map;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
/**
* A {@link MessageSendingOperations} that can resolve a String-based destinations.
*

View File

@@ -31,7 +31,6 @@ import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.util.Assert;
/**
* A messaging template for sending to and/or receiving messages from a
* {@link MessageChannel}.

View File

@@ -18,7 +18,6 @@ package org.springframework.messaging.core;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
/**
* A set of operations receiving messages from a destination.
*

View File

@@ -20,7 +20,6 @@ import java.util.Map;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
/**
* A set of operations for exchanging messages to and from a destination.
*

View File

@@ -20,7 +20,6 @@ import java.util.Map;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
/**
* A set of operations sending messages to a destination.
*

View File

@@ -22,7 +22,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation which indicates that a method parameter should be bound to a message header.
*

View File

@@ -22,7 +22,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation which indicates that a method parameter should be bound to the headers of a
* message. The annotated parameter must be assignable to {@link java.util.Map} with

View File

@@ -23,12 +23,10 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation for handling exceptions from message-handling methods within specific
* handler methods.
*
*
* @author Rossen Stoyanchev
* @since 4.0
*/

View File

@@ -24,7 +24,6 @@ import java.lang.annotation.Target;
import org.springframework.messaging.Message;
/**
* Annotation for mapping a {@link Message} onto message-handling methods by matching
* to the message destination. This annotation can also be used on the type-level in
@@ -32,8 +31,8 @@ import org.springframework.messaging.Message;
* annotations including method-level
* {@link org.springframework.messaging.simp.annotation.SubscribeMapping @SubscribeMapping}
* annotations.
* <p>
* Handler methods which are annotated with this annotation are allowed to have
*
* <p>Handler methods which are annotated with this annotation are allowed to have
* flexible signatures. They may have arguments of the following types, in arbitrary
* order:
* <ul>
@@ -62,12 +61,12 @@ import org.springframework.messaging.Message;
* WebSocket session on which the message was received. Regular HTTP-based
* authentication (e.g. Spring Security based) can be used to secure the
* HTTP handshake that initiates WebSocket sessions.</li>
* </ul>
* <p>
* By default the return value is wrapped as a message and sent to the destination
* </ul
* >
* <p>By default the return value is wrapped as a message and sent to the destination
* specified with an {@link SendTo} method-level annotation.
* <p>
* STOMP over WebSocket: an {@link SendTo} annotation is not strictly required --
*
* <p>STOMP over WebSocket: an {@link SendTo} annotation is not strictly required --
* by default the message will be sent to the same destination as the incoming
* message but with an additional prefix ("/topic" by default). It is also possible
* to use {@link org.springframework.messaging.simp.annotation.SendToUser} to
@@ -87,8 +86,7 @@ public @interface MessageMapping {
/**
* Destination-based mapping expressed by this annotation.
* <p>
* For STOMP over WebSocket messages: this is the destination of the STOMP message
* <p>For STOMP over WebSocket messages: this is the destination of the STOMP message
* (e.g. "/positions"). Ant-style path patterns (e.g. "/price.stock.*") are supported
* and so are path template variables (e.g. "/price.stock.{ticker}"").
*/

View File

@@ -24,7 +24,6 @@ import java.lang.annotation.Target;
import org.springframework.messaging.support.converter.MessageConverter;
/**
* Annotation that binds a method parameter to the payload of a message. The payload may
* be passed through a {@link MessageConverter} to convert it from serialized form with a
@@ -43,16 +42,14 @@ public @interface Payload {
* This attribute may or may not be supported depending on whether the message being
* handled contains a non-primitive Object as its payload or is in serialized form
* and requires message conversion.
* <p>
* When processing STOMP over WebSocket messages this attribute is not supported.
* <p>When processing STOMP over WebSocket messages this attribute is not supported.
*/
String value() default "";
/**
* Whether payload content is required.
* <p>
* Default is {@code true}, leading to an exception if there is no payload. Switch to
* {@code false} to have {@code null} passed when there is no payload.
* <p>Default is {@code true}, leading to an exception if there is no payload. Switch
* to {@code false} to have {@code null} passed when there is no payload.
*/
boolean required() default true;

View File

@@ -24,7 +24,6 @@ import java.lang.annotation.Target;
import org.springframework.messaging.Message;
/**
* Annotation that indicates a method's return value should be converted to
* a {@link Message} and sent to the specified destination.

View File

@@ -33,7 +33,6 @@ import org.springframework.messaging.handler.method.HandlerMethodArgumentResolve
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
* Abstract base class for resolving method arguments from a named value. Message headers,
* and path variables are examples of named values. Each may have a name, a required flag,

View File

@@ -29,7 +29,6 @@ import org.springframework.messaging.handler.method.AbstractExceptionHandlerMeth
import org.springframework.messaging.handler.method.HandlerMethodSelector;
import org.springframework.util.ReflectionUtils.MethodFilter;
/**
* A sub-class of {@link AbstractExceptionHandlerMethodResolver} that looks for
* {@link MessageExceptionHandler}-annotated methods in a given class. The actual

View File

@@ -22,7 +22,6 @@ import org.springframework.core.convert.ConversionService;
import org.springframework.messaging.Message;
import org.springframework.messaging.handler.annotation.Header;
/**
* Resolves method parameters annotated with {@link Header @Header}.
*

View File

@@ -29,7 +29,6 @@ import org.springframework.messaging.support.MessageHeaderAccessor;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;
/**
* Resolves the following method parameters:
* <ul>

View File

@@ -19,7 +19,6 @@ package org.springframework.messaging.handler.annotation.support;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
/**
* Thrown when the handling of a message results in an unrecoverable exception.
*

View File

@@ -20,7 +20,6 @@ import org.springframework.core.MethodParameter;
import org.springframework.messaging.Message;
import org.springframework.messaging.handler.method.HandlerMethodArgumentResolver;
/**
* A {@link HandlerMethodArgumentResolver} for {@link Message} parameters.
*

View File

@@ -25,13 +25,11 @@ import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
/**
* A resolver to extract and convert the payload of a message using a
* {@link MessageConverter}.
*
* <p>
* This {@link HandlerMethodArgumentResolver} should be ordered last as it supports all
* <p>This {@link HandlerMethodArgumentResolver} should be ordered last as it supports all
* types and does not require the {@link Payload} annotation.
*
* @author Rossen Stoyanchev
@@ -43,7 +41,7 @@ public class PayloadArgumentResolver implements HandlerMethodArgumentResolver {
public PayloadArgumentResolver(MessageConverter messageConverter) {
Assert.notNull(messageConverter, "converter is required");
Assert.notNull(messageConverter, "converter must not be null");
this.converter = messageConverter;
}

View File

@@ -28,7 +28,6 @@ import java.util.Iterator;
*/
public abstract class AbstractMessageCondition<T extends AbstractMessageCondition<T>> implements MessageCondition<T> {
/**
* @return the collection of objects the message condition is composed of
* (e.g. destination patterns), never {@code null}

View File

@@ -59,7 +59,6 @@ public final class DestinationPatternsMessageCondition
/**
* Additional constructor with flags for using suffix pattern (.*) and
* trailing slash matches.
*
* @param patterns the URL patterns to use; if 0, the condition will match to every request.
* @param pathMatcher for path matching with patterns
*/
@@ -140,12 +139,10 @@ public final class DestinationPatternsMessageCondition
* Check if any of the patterns match the given Message destination and return an instance
* that is guaranteed to contain matching patterns, sorted via
* {@link org.springframework.util.PathMatcher#getPatternComparator(String)}.
*
* @param message the message to match to
*
* @return the same instance if the condition contains no patterns;
* or a new condition with sorted matching patterns;
* or {@code null} either if a destination can not be extracted or there is no match
* or a new condition with sorted matching patterns;
* or {@code null} either if a destination can not be extracted or there is no match
*/
@Override
public DestinationPatternsMessageCondition getMatchingCondition(Message<?> message) {
@@ -180,7 +177,6 @@ public final class DestinationPatternsMessageCondition
* {@link org.springframework.util.PathMatcher#getPatternComparator(String)}.
* If all compared patterns match equally, but one instance has more patterns,
* it is considered a closer match.
*
* <p>It is assumed that both instances have been obtained via
* {@link #getMatchingCondition(Message)} to ensure they
* contain only patterns that match the request and are sorted with

View File

@@ -18,7 +18,6 @@ package org.springframework.messaging.handler.condition;
import org.springframework.messaging.Message;
/**
* Contract for mapping conditions to messages.
*
@@ -26,8 +25,7 @@ import org.springframework.messaging.Message;
* matched to a specific Message, as well as compared to each other in the
* context of a Message to determine which one matches a request more closely.
*
* @param <T> The kind of condition that this condition can be combined
* with or compared to
* @param <T> The kind of condition that this condition can be combined with or compared to
*
* @author Rossen Stoyanchev
* @since 4.0
@@ -37,7 +35,6 @@ public interface MessageCondition<T> {
/**
* Define the rules for combining this condition with another.
* For example combining type- and method-level conditions.
*
* @param other the condition to combine with
* @return the resulting message condition
*/
@@ -48,9 +45,7 @@ public interface MessageCondition<T> {
* potentially new condition with content tailored to the current message.
* For example a condition with destination patterns might return a new
* condition with sorted, matching patterns only.
*
* @return a condition instance in case of a match;
* or {@code null} if there is no match.
* @return a condition instance in case of a match; or {@code null} if there is no match.
*/
T getMatchingCondition(Message<?> message);

View File

@@ -46,7 +46,7 @@ public abstract class AbstractExceptionHandlerMethodResolver {
* Protected constructor accepting exception-to-method mappings.
*/
protected AbstractExceptionHandlerMethodResolver(Map<Class<? extends Throwable>, Method> mappedMethods) {
Assert.notNull(mappedMethods, "'mappedMethods' is required");
Assert.notNull(mappedMethods, "Mapped Methods must not be null");
this.mappedMethods.putAll(mappedMethods);
}

View File

@@ -41,8 +41,8 @@ import java.util.concurrent.ConcurrentHashMap;
* Also supports discovering and invoking exception handling methods to process
* exceptions raised during message handling.
*
* @param <T> the type of the Object that contains information mapping
* a {@link HandlerMethod} to incoming messages
* @param <T> the type of the Object that contains information mapping a
* {@link HandlerMethod} to incoming messages
*
* @author Rossen Stoyanchev
* @since 4.0
@@ -80,8 +80,7 @@ public abstract class AbstractMethodMessageHandler<T>
* matching part is removed from destination before performing a lookup for a matching
* message handling method. Prefixes without a trailing slash will have one appended
* automatically.
* <p>
* By default the list of prefixes is empty in which case all destinations match.
* <p>By default the list of prefixes is empty in which case all destinations match.
*/
public void setDestinationPrefixes(Collection<String> prefixes) {
this.destinationPrefixes.clear();
@@ -103,7 +102,6 @@ public abstract class AbstractMethodMessageHandler<T>
/**
* Sets the list of custom {@code HandlerMethodArgumentResolver}s that will be used
* after resolvers for supported argument type.
*
* @param customArgumentResolvers the list of resolvers; never {@code null}.
*/
public void setCustomArgumentResolvers(List<HandlerMethodArgumentResolver> customArgumentResolvers) {
@@ -118,7 +116,6 @@ public abstract class AbstractMethodMessageHandler<T>
/**
* Set the list of custom {@code HandlerMethodReturnValueHandler}s that will be used
* after return value handlers for known types.
*
* @param customReturnValueHandlers the list of custom return value handlers, never {@code null}.
*/
public void setCustomReturnValueHandlers(List<HandlerMethodReturnValueHandler> customReturnValueHandlers) {
@@ -202,8 +199,7 @@ public abstract class AbstractMethodMessageHandler<T>
/**
* Return the list of argument resolvers to use. Invoked only if the resolvers
* have not already been set via {@link #setArgumentResolvers(java.util.List)}.
* <p>
* Sub-classes should also take into account custom argument types configured via
* <p>Sub-classes should also take into account custom argument types configured via
* {@link #setCustomArgumentResolvers(java.util.List)}.
*/
protected abstract List<? extends HandlerMethodArgumentResolver> initArgumentResolvers();
@@ -211,9 +207,8 @@ public abstract class AbstractMethodMessageHandler<T>
/**
* Return the list of return value handlers to use. Invoked only if the return
* value handlers have not already been set via {@link #setReturnValueHandlers(java.util.List)}.
* <p>
* Sub-classes should also take into account custom return value types configured via
* {@link #setCustomReturnValueHandlers(java.util.List)}.
* <p>Sub-classes should also take into account custom return value types configured
* via {@link #setCustomReturnValueHandlers(java.util.List)}.
*/
protected abstract List<? extends HandlerMethodReturnValueHandler> initReturnValueHandlers();
@@ -226,7 +221,6 @@ public abstract class AbstractMethodMessageHandler<T>
/**
* Detect if the given handler has any methods that can handle messages and if
* so register it with the extracted mapping information.
*
* @param handler the handler to check, either an instance of a Spring bean name
*/
protected final void detectHandlerMethods(Object handler) {
@@ -251,10 +245,8 @@ public abstract class AbstractMethodMessageHandler<T>
/**
* Provide the mapping for a handler method.
*
* @param method the method to provide a mapping for
* @param handlerType the handler type, possibly a sub-type of the method's declaring class
*
* @return the mapping, or {@code null} if the method is not mapped
*/
protected abstract T getMappingForMethod(Method method, Class<?> handlerType);
@@ -262,11 +254,9 @@ public abstract class AbstractMethodMessageHandler<T>
/**
* Register a handler method and its unique mapping.
*
* @param handler the bean name of the handler or the handler instance
* @param method the method to register
* @param mapping the mapping conditions associated with the handler method
*
* @throws IllegalStateException if another method was already registered
* under the same mapping
*/
@@ -345,9 +335,7 @@ public abstract class AbstractMethodMessageHandler<T>
/**
* Find if the given destination matches any of the configured allowed destination
* prefixes and if a match is found return the destination with the prefix removed.
* <p>
* If no destination prefixes are configured, the destination is returned as is.
*
* <p>If no destination prefixes are configured, the destination is returned as is.
* @return the destination to use to find matching message handling methods
* or {@code null} if the destination does not match
*/
@@ -422,10 +410,8 @@ public abstract class AbstractMethodMessageHandler<T>
/**
* Check if a mapping matches the current message and return a possibly
* new mapping with conditions relevant to the current request.
*
* @param mapping the mapping to get a match for
* @param message the message being handled
*
* @return the match or {@code null} if there is no match
*/
protected abstract T getMatchingMapping(T mapping, Message<?> message);
@@ -433,7 +419,6 @@ public abstract class AbstractMethodMessageHandler<T>
/**
* Return a comparator for sorting matching mappings.
* The returned comparator should sort 'better' matches higher.
*
* @param message the current Message
* @return the comparator, never {@code null}
*/

View File

@@ -64,8 +64,8 @@ public class HandlerMethod {
* Create an instance from a bean instance and a method.
*/
public HandlerMethod(Object bean, Method method) {
Assert.notNull(bean, "bean is required");
Assert.notNull(method, "method is required");
Assert.notNull(bean, "bean must not be null");
Assert.notNull(method, "method must not be null");
this.bean = bean;
this.beanFactory = null;
this.method = method;
@@ -78,8 +78,8 @@ public class HandlerMethod {
* @throws NoSuchMethodException when the method cannot be found
*/
public HandlerMethod(Object bean, String methodName, Class<?>... parameterTypes) throws NoSuchMethodException {
Assert.notNull(bean, "bean is required");
Assert.notNull(methodName, "method is required");
Assert.notNull(bean, "bean must not be null");
Assert.notNull(methodName, "method must not be null");
this.bean = bean;
this.beanFactory = null;
this.method = bean.getClass().getMethod(methodName, parameterTypes);
@@ -93,9 +93,9 @@ public class HandlerMethod {
* re-create the {@code HandlerMethod} with an initialized the bean.
*/
public HandlerMethod(String beanName, BeanFactory beanFactory, Method method) {
Assert.hasText(beanName, "beanName is required");
Assert.notNull(beanFactory, "beanFactory is required");
Assert.notNull(method, "method is required");
Assert.hasText(beanName, "beanName must not be null");
Assert.notNull(beanFactory, "beanFactory must not be null");
Assert.notNull(method, "method must not be null");
Assert.isTrue(beanFactory.containsBean(beanName),
"Bean factory [" + beanFactory + "] does not contain bean [" + beanName + "]");
this.bean = beanName;
@@ -109,7 +109,7 @@ public class HandlerMethod {
* Copy constructor for use in sub-classes.
*/
protected HandlerMethod(HandlerMethod handlerMethod) {
Assert.notNull(handlerMethod, "HandlerMethod is required");
Assert.notNull(handlerMethod, "HandlerMethod must not be null");
this.bean = handlerMethod.bean;
this.beanFactory = handlerMethod.beanFactory;
this.method = handlerMethod.method;
@@ -121,8 +121,8 @@ public class HandlerMethod {
* Re-create HandlerMethod with the resolved handler.
*/
private HandlerMethod(HandlerMethod handlerMethod, Object handler) {
Assert.notNull(handlerMethod, "handlerMethod is required");
Assert.notNull(handler, "handler is required");
Assert.notNull(handlerMethod, "handlerMethod must not be null");
Assert.notNull(handler, "handler must not be null");
this.bean = handler;
this.beanFactory = handlerMethod.beanFactory;
this.method = handlerMethod.method;

View File

@@ -19,7 +19,6 @@ package org.springframework.messaging.handler.method;
import org.springframework.core.MethodParameter;
import org.springframework.messaging.Message;
/**
* Strategy interface for resolving method parameters into argument values in
* the context of a given {@link Message}.
@@ -32,25 +31,20 @@ public interface HandlerMethodArgumentResolver {
/**
* Whether the given {@linkplain MethodParameter method parameter} is
* supported by this resolver.
*
* @param parameter the method parameter to check
* @return {@code true} if this resolver supports the supplied parameter;
* {@code false} otherwise
*/
boolean supportsParameter(MethodParameter parameter);
/**
* Resolves a method parameter into an argument value from a given message.
*
* @param parameter the method parameter to resolve. This parameter must
* have previously been passed to
* {@link #supportsParameter(org.springframework.core.MethodParameter)}
* and it must have returned {@code true}
* @param message
*
* @return the resolved argument value, or {@code null}.
*
* @throws Exception in case of errors with the preparation of argument values
*/
Object resolveArgument(MethodParameter parameter, Message<?> message) throws Exception;

View File

@@ -19,7 +19,6 @@ package org.springframework.messaging.handler.method;
import org.springframework.core.MethodParameter;
import org.springframework.messaging.Message;
/**
* Strategy interface to handle the value returned from the invocation of a
* method handling a {@link Message}.
@@ -32,7 +31,6 @@ public interface HandlerMethodReturnValueHandler {
/**
* Whether the given {@linkplain MethodParameter method return type} is
* supported by this handler.
*
* @param returnType the method return type to check
* @return {@code true} if this handler supports the supplied return type;
* {@code false} otherwise
@@ -41,7 +39,6 @@ public interface HandlerMethodReturnValueHandler {
/**
* Handle the given return value.
*
* @param returnValue the value returned from the handler method
* @param returnType the type of the return value. This type must have
* previously been passed to

View File

@@ -39,7 +39,6 @@ public abstract class HandlerMethodSelector {
/**
* Selects handler methods for the given handler type. Callers of this method define handler methods
* of interest through the {@link MethodFilter} parameter.
*
* @param handlerType the handler type to search handler methods on
* @param handlerMethodFilter a {@link MethodFilter} to help recognize handler methods of interest
* @return the selected methods, or an empty set

View File

@@ -24,15 +24,14 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.support.NativeMessageHeaderAccessor;
import org.springframework.util.Assert;
/**
* A base class for working with message headers in simple messaging protocols that
* support basic messaging patterns. Provides uniform access to specific values common
* across protocols such as a destination, message type (e.g. publish, subscribe, etc),
* session id, and others.
* <p>
* Use one of the static factory method in this class, then call getters and setters, and
* at the end if necessary call {@link #toMap()} to obtain the updated headers.
*
* <p>Use one of the static factory method in this class, then call getters and setters,
* and at the end if necessary call {@link #toMap()} to obtain the updated headers.
*
* @author Rossen Stoyanchev
* @since 4.0
@@ -58,7 +57,7 @@ public class SimpMessageHeaderAccessor extends NativeMessageHeaderAccessor {
*/
protected SimpMessageHeaderAccessor(SimpMessageType messageType, Map<String, List<String>> externalSourceHeaders) {
super(externalSourceHeaders);
Assert.notNull(messageType, "messageType is required");
Assert.notNull(messageType, "MessageType must not be null");
setHeader(MESSAGE_TYPE_HEADER, messageType);
}
@@ -104,7 +103,7 @@ public class SimpMessageHeaderAccessor extends NativeMessageHeaderAccessor {
}
public void setDestination(String destination) {
Assert.notNull(destination, "destination is required");
Assert.notNull(destination, "Destination must not be null");
setHeader(DESTINATION_HEADER, destination);
}

View File

@@ -22,7 +22,6 @@ import org.springframework.messaging.MessagingException;
import org.springframework.messaging.core.MessagePostProcessor;
import org.springframework.messaging.core.MessageSendingOperations;
/**
* A specialization of {@link MessageSendingOperations} with methods for use with
* the Spring Framework support for simple messaging protocols (like STOMP).
@@ -34,19 +33,24 @@ public interface SimpMessageSendingOperations extends MessageSendingOperations<S
/**
* Send a message to a specific user.
*
* @param user the user that should receive the message.
* @param destination the destination to send the message to.
* @param payload the payload to send
*/
void convertAndSendToUser(String user, String destination, Object payload) throws MessagingException;
/**
* Send a message to a specific user.
* @param user the user that should receive the message.
* @param destination the destination to send the message to.
* @param payload the payload to send
* @param headers the message headers
*/
void convertAndSendToUser(String user, String destination, Object payload, Map<String, Object> headers)
throws MessagingException;
/**
* Send a message to a specific user.
*
* @param user the user that should receive the message.
* @param destination the destination to send the message to.
* @param payload the payload to send
@@ -55,6 +59,14 @@ public interface SimpMessageSendingOperations extends MessageSendingOperations<S
void convertAndSendToUser(String user, String destination, Object payload,
MessagePostProcessor postProcessor) throws MessagingException;
/**
* Send a message to a specific user.
* @param user the user that should receive the message.
* @param destination the destination to send the message to.
* @param payload the payload to send
* @param headers the message headers
* @param postProcessor a postProcessor to post-process or modify the created message
*/
void convertAndSendToUser(String user, String destination, Object payload, Map<String, Object> headers,
MessagePostProcessor postProcessor) throws MessagingException;

View File

@@ -16,7 +16,6 @@
package org.springframework.messaging.simp;
/**
* A generic representation of different kinds of messages found in simple messaging
* protocols like STOMP.

View File

@@ -26,7 +26,6 @@ import org.springframework.messaging.core.MessagePostProcessor;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.util.Assert;
/**
* A specialization of {@link AbstractMessageSendingTemplate} that adds String-based
* destinations as a message header.
@@ -44,8 +43,12 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate<String
private volatile long sendTimeout = -1;
/**
* Create a new {@link SimpMessagingTemplate} instance.
* @param messageChannel the message channel (must not be {@code null})
*/
public SimpMessagingTemplate(MessageChannel messageChannel) {
Assert.notNull(messageChannel, "messageChannel is required");
Assert.notNull(messageChannel, "MessageChannel must not be null");
this.messageChannel = messageChannel;
}
@@ -56,7 +59,7 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate<String
* @see org.springframework.messaging.simp.handler.UserDestinationMessageHandler
*/
public void setUserDestinationPrefix(String prefix) {
Assert.notNull(prefix, "userDestinationPrefix is required");
Assert.notNull(prefix, "UserDestinationPrefix must not be null");
this.userDestinationPrefix = prefix;
}
@@ -101,7 +104,7 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate<String
@Override
protected void doSend(String destination, Message<?> message) {
Assert.notNull(destination, "destination is required");
Assert.notNull(destination, "Destination must not be null");
SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(message);
headers.setDestination(destination);
@@ -146,8 +149,7 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate<String
@Override
public void convertAndSendToUser(String user, String destination, Object payload, Map<String, Object> headers,
MessagePostProcessor postProcessor) throws MessagingException {
Assert.notNull(user, "user is required");
Assert.notNull(user, "User must not be null");
super.convertAndSend(this.userDestinationPrefix + user + destination, payload, headers, postProcessor);
}

View File

@@ -25,7 +25,6 @@ import java.lang.annotation.Target;
import org.springframework.messaging.Message;
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
/**
* Annotation that can be used on methods processing an input message to indicate that the
* method's return value should be converted to a {@link Message} and sent to the
@@ -36,7 +35,6 @@ import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
*
* @author Rossen Stoyanchev
* @since 4.0
*
* @see org.springframework.messaging.handler.annotation.SendTo
* @see org.springframework.messaging.simp.handler.UserDestinationMessageHandler
*/

View File

@@ -22,20 +22,19 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation for mapping subscription messages onto specific handler methods based
* on the destination of a subscription. Supported with STOMP over WebSocket only
* (e.g. STOMP SUBSCRIBE frame).
* <p>
* This is a method-level annotations that can be combined with a type-level
*
* <p>This is a method-level annotations that can be combined with a type-level
* {@link org.springframework.messaging.handler.annotation.MessageMapping @MessageMapping}
* <p>
* Supports the same method arguments as
*
* <p>Supports the same method arguments as
* {@link org.springframework.messaging.handler.annotation.MessageMapping}, however
* subscription messages typically do not have a body.
* <p>
* The return value also follows the same rules as for
*
* <p>The return value also follows the same rules as for
* {@link org.springframework.messaging.handler.annotation.MessageMapping} except if
* the method is not annotated with
* {@link org.springframework.messaging.handler.annotation.SendTo} or {@link SendToUser},
@@ -52,8 +51,7 @@ public @interface SubscribeMapping {
/**
* Destination-based mapping expressed by this annotation.
* <p>
* For STOMP over WebSocket messages: this is the destination of the STOMP message
* <p>For STOMP over WebSocket messages: this is the destination of the STOMP message
* (e.g. "/positions"). Ant-style path patterns (e.g. "/price.stock.*") are supported
* and so are path template variables (e.g. "/price.stock.{ticker}"").
*/

View File

@@ -19,9 +19,7 @@ package org.springframework.messaging.simp.annotation.support;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
/**
*
* @author Rossen Stoyanchev
* @since 4.0
*/

View File

@@ -23,14 +23,12 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.handler.method.HandlerMethodArgumentResolver;
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
/**
* @author Rossen Stoyanchev
* @since 4.0
*/
public class PrincipalMethodArgumentResolver implements HandlerMethodArgumentResolver {
@Override
public boolean supportsParameter(MethodParameter parameter) {
Class<?> paramType = parameter.getParameterType();

View File

@@ -32,12 +32,11 @@ import org.springframework.messaging.support.MessageBuilder;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
* A {@link HandlerMethodReturnValueHandler} for sending to destinations specified in a
* {@link SendTo} or {@link SendToUser} method-level annotations.
* <p>
* The value returned from the method is converted, and turned to a {@link Message} and
*
* <p>The value returned from the method is converted, and turned to a {@link Message} and
* sent through the provided {@link MessageChannel}. The
* message is then enriched with the sessionId of the input message as well as the
* destination from the annotation(s). If multiple destinations are specified, a copy of
@@ -58,7 +57,7 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH
public SendToMethodReturnValueHandler(SimpMessageSendingOperations messagingTemplate, boolean annotationRequired) {
Assert.notNull(messagingTemplate, "messagingTemplate is required");
Assert.notNull(messagingTemplate, "messagingTemplate must not be null");
this.messagingTemplate = messagingTemplate;
this.annotationRequired = annotationRequired;
}
@@ -68,8 +67,7 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH
* Configure a default prefix to add to message destinations in cases where a method
* is not annotated with {@link SendTo @SendTo} or does not specify any destinations
* through the annotation's value attribute.
* <p>
* By default, the prefix is set to "/topic".
* <p>By default, the prefix is set to "/topic".
*/
public void setDefaultDestinationPrefix(String defaultDestinationPrefix) {
this.defaultDestinationPrefix = defaultDestinationPrefix;
@@ -87,8 +85,7 @@ public class SendToMethodReturnValueHandler implements HandlerMethodReturnValueH
* Configure a default prefix to add to message destinations in cases where a
* method is annotated with {@link SendToUser @SendToUser} but does not specify
* any destinations through the annotation's value attribute.
* <p>
* By default, the prefix is set to "/queue".
* <p>By default, the prefix is set to "/queue".
*/
public void setDefaultUserDestinationPrefix(String prefix) {
this.defaultUserDestinationPrefix = prefix;

View File

@@ -29,7 +29,6 @@ import org.springframework.messaging.simp.annotation.SubscribeMapping;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.util.Assert;
/**
* A {@link HandlerMethodReturnValueHandler} for replying directly to a subscription. It
* supports methods annotated with {@link org.springframework.messaging.simp.annotation.SubscribeMapping} unless they're also annotated
@@ -49,10 +48,10 @@ public class SubscriptionMethodReturnValueHandler implements HandlerMethodReturn
/**
* @param messagingTemplate a messaging template for sending messages directly
* to clients, e.g. in response to a subscription
* to clients, e.g. in response to a subscription
*/
public SubscriptionMethodReturnValueHandler(MessageSendingOperations<String> messagingTemplate) {
Assert.notNull(messagingTemplate, "messagingTemplate is required");
Assert.notNull(messagingTemplate, "messagingTemplate must not be null");
this.messagingTemplate = messagingTemplate;
}

View File

@@ -39,7 +39,7 @@ public abstract class AbstractBrokerRegistration {
public AbstractBrokerRegistration(MessageChannel clientOutboundChannel, String[] destinationPrefixes) {
Assert.notNull(clientOutboundChannel, "'clientOutboundChannel' is required");
Assert.notNull(clientOutboundChannel, "'clientOutboundChannel' must not be null");
this.clientOutboundChannel = clientOutboundChannel;
this.destinationPrefixes = (destinationPrefixes != null)
? Arrays.<String>asList(destinationPrefixes) : Collections.<String>emptyList();

View File

@@ -30,7 +30,6 @@ import org.springframework.util.MimeTypeUtils;
import java.util.ArrayList;
import java.util.List;
/**
* Provides essential configuration for handling messages with simple messaging
* protocols such as STOMP.
@@ -278,12 +277,15 @@ public abstract class AbstractMessageBrokerConfiguration {
@Override
protected void startInternal() {
}
@Override
protected void stopInternal() {
}
@Override
protected void handleMessageInternal(Message<?> message) {
}
};
}

View File

@@ -22,7 +22,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* A registration class for customizing the configuration for a
* {@link org.springframework.messaging.MessageChannel}.

View File

@@ -74,12 +74,10 @@ public class MessageBrokerRegistry {
* annotated methods. For example destinations prefixed with "/app" may be
* processed by annotated methods while other destinations may target the
* message broker (e.g. "/topic", "/queue").
* <p>
* When messages are processed, the matching prefix is removed from the destination in
* order to form the lookup path. This means annotations should not contain the
* <p>When messages are processed, the matching prefix is removed from the destination
* in order to form the lookup path. This means annotations should not contain the
* destination prefix.
* <p>
* Prefixes that do not have a trailing slash will have one automatically appended.
* <p>Prefixes that do not have a trailing slash will have one automatically appended.
*/
public MessageBrokerRegistry setApplicationDestinationPrefixes(String... prefixes) {
this.applicationDestinationPrefixes = prefixes;
@@ -91,14 +89,12 @@ public class MessageBrokerRegistry {
* provide the ability for a user to subscribe to queue names unique to their
* session as well as for others to send messages to those unique,
* user-specific queues.
* <p>
* For example when a user attempts to subscribe to "/user/queue/position-updates",
* <p>For example when a user attempts to subscribe to "/user/queue/position-updates",
* the destination may be translated to "/queue/position-updatesi9oqdfzo" yielding a
* unique queue name that does not collide with any other user attempting to do the same.
* Subsequently when messages are sent to "/user/{username}/queue/position-updates",
* the destination is translated to "/queue/position-updatesi9oqdfzo".
* <p>
* The default prefix used to identify such destinations is "/user/".
* <p>The default prefix used to identify such destinations is "/user/".
*/
public MessageBrokerRegistry setUserDestinationPrefix(String destinationPrefix) {
this.userDestinationPrefix = destinationPrefix;

View File

@@ -19,7 +19,6 @@ package org.springframework.messaging.simp.config;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.simp.handler.SimpleBrokerMessageHandler;
/**
* Registration class for configuring a {@link SimpleBrokerMessageHandler}.
*
@@ -33,6 +32,7 @@ public class SimpleBrokerRegistration extends AbstractBrokerRegistration {
super(clientOutboundChannel, destinationPrefixes);
}
@Override
protected SimpleBrokerMessageHandler getMessageHandler() {
return new SimpleBrokerMessageHandler(getClientOutboundChannel(), getDestinationPrefixes());

View File

@@ -90,8 +90,7 @@ public class StompBrokerRelayRegistration extends AbstractBrokerRegistration {
* Set the interval, in milliseconds, at which the "system" relay session will,
* in the absence of any other data being sent, send a heartbeat to the STOMP broker.
* A value of zero will prevent heartbeats from being sent to the broker.
* <p>
* The default value is 10000.
* <p>The default value is 10000.
*/
public StompBrokerRelayRegistration setSystemHeartbeatSendInterval(long systemHeartbeatSendInterval) {
this.systemHeartbeatSendInterval = systemHeartbeatSendInterval;
@@ -103,8 +102,7 @@ public class StompBrokerRelayRegistration extends AbstractBrokerRegistration {
* expects, in the absence of any other data, to receive a heartbeat from the STOMP
* broker. A value of zero will configure the relay session to expect not to receive
* heartbeats from the broker.
* <p>
* The default value is 10000.
* <p>The default value is 10000.
*/
public StompBrokerRelayRegistration setSystemHeartbeatReceiveInterval(long heartbeatReceiveInterval) {
this.systemHeartbeatReceiveInterval = heartbeatReceiveInterval;
@@ -114,8 +112,7 @@ public class StompBrokerRelayRegistration extends AbstractBrokerRegistration {
/**
* Configure whether the {@link StompBrokerRelayMessageHandler} should start
* automatically when the Spring ApplicationContext is refreshed.
* <p>
* The default setting is {@code true}.
* <p>The default setting is {@code true}.
*/
public StompBrokerRelayRegistration setAutoStartup(boolean autoStartup) {
this.autoStartup = autoStartup;

View File

@@ -30,9 +30,7 @@ import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.simp.BrokerAvailabilityEvent;
import org.springframework.util.CollectionUtils;
/**
*
* @author Rossen Stoyanchev
* @since 4.0
*/

View File

@@ -23,7 +23,6 @@ import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
import org.springframework.messaging.simp.SimpMessageType;
import org.springframework.util.MultiValueMap;
/**
* @author Rossen Stoyanchev
* @since 4.0

View File

@@ -227,7 +227,7 @@ public class DefaultSubscriptionRegistry extends AbstractSubscriptionRegistry {
public SessionSubscriptionInfo(String sessionId) {
Assert.notNull(sessionId, "sessionId is required");
Assert.notNull(sessionId, "sessionId must not be null");
this.sessionId = sessionId;
}

View File

@@ -30,8 +30,8 @@ import java.util.Set;
/**
* A default implementation of {@link UserDestinationResolver}.
* <p>
* Resolves messages sent to destination patterns "/user/{user-name}/**" as well as
*
* <p>Resolves messages sent to destination patterns "/user/{user-name}/**" as well as
* subscriptions to destinations "/user/queue/**" where the "/user/" prefix used to
* recognize such destinations is customizable via
* {@link #setUserDestinationPrefix(String)}.
@@ -54,24 +54,21 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver {
/**
* Create an instance that will access user session id information through
* the provided registry.
*
* @param userSessionRegistry the registry, never {@code null}
*/
public DefaultUserDestinationResolver(UserSessionRegistry userSessionRegistry) {
Assert.notNull(userSessionRegistry, "'userSessionRegistry' is required");
Assert.notNull(userSessionRegistry, "'userSessionRegistry' must not be null");
this.userSessionRegistry = userSessionRegistry;
}
/**
* The prefix used to identify user destinations. Any destinations that do not
* start with the given prefix are not be resolved.
* <p>
* The default value is "/user/".
*
* <p>The default value is "/user/".
* @param prefix the prefix to use
*/
public void setUserDestinationPrefix(String prefix) {
Assert.hasText(prefix, "prefix is required");
Assert.hasText(prefix, "prefix must not be empty");
this.destinationPrefix = prefix.endsWith("/") ? prefix : prefix + "/";
this.subscriptionDestinationPrefix = this.destinationPrefix + "queue/";
}
@@ -79,8 +76,7 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver {
/**
* Return the prefix used to identify user destinations. Any destinations that do not
* start with the given prefix are not be resolved.
* <p>
* By default "/user/queue/".
* <p>By default "/user/queue/".
*/
public String getDestinationPrefix() {
return this.destinationPrefix;
@@ -88,8 +84,7 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver {
/**
* Return the prefix used to identify user destinations for (un)subscribe messages.
* <p>
* By default "/user/queue/".
* <p>By default "/user/queue/".
*/
public String getSubscriptionDestinationPrefix() {
return this.subscriptionDestinationPrefix;

View File

@@ -46,10 +46,8 @@ public class DefaultUserSessionRegistry implements UserSessionRegistry {
@Override
public void registerSessionId(String user, String sessionId) {
Assert.notNull(user, "'user' is required");
Assert.notNull(user, "'sessionId' is required");
Assert.notNull(user, "User must not be null");
Assert.notNull(sessionId, "Session ID must not be null");
synchronized (this.lock) {
Set<String> set = this.userSessionIds.get(user);
if (set == null) {
@@ -62,10 +60,8 @@ public class DefaultUserSessionRegistry implements UserSessionRegistry {
@Override
public void unregisterSessionId(String userName, String sessionId) {
Assert.notNull(userName, "'userName' is required");
Assert.notNull(userName, "'sessionId' is required");
Assert.notNull(userName, "User Name must not be null");
Assert.notNull(sessionId, "Session ID must not be null");
synchronized (lock) {
Set<String> set = this.userSessionIds.get(userName);
if (set != null) {

View File

@@ -64,7 +64,6 @@ import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.PathMatcher;
/**
* A handler for messages delegating to {@link org.springframework.messaging.simp.annotation.SubscribeMapping @SubscribeMapping} and
* {@link MessageMapping @MessageMapping} annotated methods.
@@ -95,8 +94,8 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
public SimpAnnotationMethodMessageHandler(SimpMessageSendingOperations brokerTemplate,
MessageChannel clientOutboundChannel) {
Assert.notNull(brokerTemplate, "brokerTemplate is required");
Assert.notNull(clientOutboundChannel, "clientOutboundChannel is required");
Assert.notNull(brokerTemplate, "BrokerTemplate must not be null");
Assert.notNull(clientOutboundChannel, "ClientOutboundChannel must not be null");
this.brokerTemplate = brokerTemplate;
this.clientMessagingTemplate = new SimpMessagingTemplate(clientOutboundChannel);
@@ -111,7 +110,6 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
* from serialize form with a specific MIME type to an Object matching the target
* method parameter. The converter is also used when sending message to the message
* broker.
*
* @see CompositeMessageConverter
*/
public void setMessageConverter(MessageConverter converter) {
@@ -131,8 +129,7 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
/**
* Configure a {@link ConversionService} to use when resolving method arguments, for
* example message header values.
* <p>
* By default an instance of {@link DefaultFormattingConversionService} is used.
* <p>By default an instance of {@link DefaultFormattingConversionService} is used.
*/
public void setConversionService(ConversionService conversionService) {
this.conversionService = conversionService;
@@ -148,8 +145,7 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
/**
* Set the PathMatcher implementation to use for matching destinations
* against configured destination patterns.
* <p>
* By default AntPathMatcher is used
* <p>By default AntPathMatcher is used
*/
public void setPathMatcher(PathMatcher pathMatcher) {
Assert.notNull(pathMatcher, "PathMatcher must not be null");

View File

@@ -45,11 +45,10 @@ public class SimpMessageTypeMessageCondition extends AbstractMessageCondition<Si
/**
* A constructor accepting a message type.
*
* @param messageType the message type to match messages to
*/
public SimpMessageTypeMessageCondition(SimpMessageType messageType) {
Assert.notNull(messageType, "'messageType' is required");
Assert.notNull(messageType, "MessageType must not be null");
this.messageType = messageType;
}

View File

@@ -26,7 +26,6 @@ import org.springframework.messaging.support.MessageBuilder;
import org.springframework.util.Assert;
import org.springframework.util.MultiValueMap;
/**
* @author Rossen Stoyanchev
* @since 4.0
@@ -45,7 +44,7 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler {
*/
public SimpleBrokerMessageHandler(MessageChannel messageChannel, Collection<String> destinationPrefixes) {
super(destinationPrefixes);
Assert.notNull(messageChannel, "messageChannel is required");
Assert.notNull(messageChannel, "MessageChannel must not be null");
this.messageChannel = messageChannel;
}
@@ -55,7 +54,7 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler {
}
public void setSubscriptionRegistry(SubscriptionRegistry subscriptionRegistry) {
Assert.notNull(subscriptionRegistry, "subscriptionRegistry is required");
Assert.notNull(subscriptionRegistry, "SubscriptionRegistry must not be null");
this.subscriptionRegistry = subscriptionRegistry;
}

View File

@@ -46,7 +46,6 @@ public interface SubscriptionRegistry {
/**
* Find all subscriptions that should receive the given message.
*
* @param message the message
* @return a {@link MultiValueMap} from sessionId to subscriptionId's, possibly empty.
*/

View File

@@ -50,17 +50,14 @@ public class UserDestinationMessageHandler implements MessageHandler {
/**
* Create an instance of the handler with the given messaging template and a
* user destination resolver.
*
* @param messagingTemplate a messaging template to use for sending messages
* with translated user destinations
* with translated user destinations
* @param userDestinationResolver the resolver to use to find queue suffixes for a user
*/
public UserDestinationMessageHandler(MessageSendingOperations<String> messagingTemplate,
UserDestinationResolver userDestinationResolver) {
Assert.notNull(messagingTemplate, "messagingTemplate is required");
Assert.notNull(userDestinationResolver, "destinationResolver is required");
Assert.notNull(messagingTemplate, "MessagingTemplate must not be null");
Assert.notNull(userDestinationResolver, "DestinationResolver must not be null");
this.messagingTemplate = messagingTemplate;
this.userDestinationResolver = userDestinationResolver;
}

View File

@@ -20,13 +20,12 @@ import org.springframework.messaging.Message;
import java.util.Set;
/**
* A strategy for resolving unique, user destinations per session. User destinations
* provide a user with the ability to subscribe to a queue unique to their session
* as well others with the ability to send messages to those queues.
* <p>
* For example when a user attempts to subscribe to "/user/queue/position-updates",
*
* <p>For example when a user attempts to subscribe to "/user/queue/position-updates",
* the destination may be resolved to "/queue/position-updates-useri9oqdfzo" yielding a
* unique queue name that does not collide with any other user attempting to do the same.
* Subsequently when messages are sent to "/user/{username}/queue/position-updates",
@@ -43,11 +42,9 @@ public interface UserDestinationResolver {
* Resolve the destination of the message to one or more user/session-specific target
* destinations. If the user has multiple sessions, the method may return more than
* one target destinations.
*
* @param message the message to resolve
*
* @return the resolved unique user destinations or an empty Set if the message
* destination is not recognized as a user destination
* destination is not recognized as a user destination
*/
Set<String> resolveDestination(Message<?> message);

View File

@@ -4,21 +4,18 @@ import java.util.Set;
/**
* A registry for looking up active session id's by user.
* <p>
* Used in support of resolving unique session-specific user destinations.
*
* <p>Used in support of resolving unique session-specific user destinations.
* See {@link DefaultUserDestinationResolver} for more details.
*
* @author Rossen Stoyanchev
* @since 4.0
*
* @see DefaultUserDestinationResolver
*/
public interface UserSessionRegistry {
/**
* Return the active session id's for the given user.
*
* @param user the user
* @return a set with 0 or more session id's
*/
@@ -26,7 +23,6 @@ public interface UserSessionRegistry {
/**
* Register an active session id for the given user.
*
* @param user the user
* @param sessionId the session id
*/
@@ -34,11 +30,9 @@ public interface UserSessionRegistry {
/**
* Unregister the session id for a user.
*
* @param user the user
* @param sessionId the session id
*/
void unregisterSessionId(String user, String sessionId);
}

View File

@@ -39,7 +39,6 @@ import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;
import org.springframework.util.concurrent.ListenableFutureTask;
/**
* A {@link MessageHandler} that handles messages by forwarding them to a STOMP broker.
* For each new {@link SimpMessageType#CONNECT CONNECT} message, an independent TCP
@@ -49,8 +48,8 @@ import org.springframework.util.concurrent.ListenableFutureTask;
* sends messages back on the TCP connection, those messages are enriched with the session
* id of the client and sent back downstream through the {@link MessageChannel} provided
* to the constructor.
* <p>
* This class also automatically opens a default "system" TCP connection to the message
*
* <p>This class also automatically opens a default "system" TCP connection to the message
* broker that is used for sending messages that originate from the server application (as
* opposed to from a client). Such messages are recognized because they are not associated
* with any client and therefore do not have a session id header. The "system" connection
@@ -103,11 +102,11 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
/**
* @param messageChannel the channel to send messages from the STOMP broker to
* @param destinationPrefixes the broker supported destination prefixes; destinations
* that do not match the given prefix are ignored.
* that do not match the given prefix are ignored.
*/
public StompBrokerRelayMessageHandler(MessageChannel messageChannel, Collection<String> destinationPrefixes) {
super(destinationPrefixes);
Assert.notNull(messageChannel, "messageChannel is required");
Assert.notNull(messageChannel, "MessageChannel must not be null");
this.messageChannel = messageChannel;
}
@@ -145,10 +144,8 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
* Set the interval, in milliseconds, at which the "system" connection will, in the
* absence of any other data being sent, send a heartbeat to the STOMP broker. A value
* of zero will prevent heartbeats from being sent to the broker.
* <p>
* The default value is 10000.
* <p>
* See class-level documentation for more information on the "system" connection.
* <p>The default value is 10000.
* <p>See class-level documentation for more information on the "system" connection.
*/
public void setSystemHeartbeatSendInterval(long systemHeartbeatSendInterval) {
this.systemHeartbeatSendInterval = systemHeartbeatSendInterval;
@@ -167,10 +164,8 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
* expects, in the absence of any other data, to receive a heartbeat from the STOMP
* broker. A value of zero will configure the connection to expect not to receive
* heartbeats from the broker.
* <p>
* The default value is 10000.
* <p>
* See class-level documentation for more information on the "system" connection.
* <p>The default value is 10000.
* <p>See class-level documentation for more information on the "system" connection.
*/
public void setSystemHeartbeatReceiveInterval(long heartbeatReceiveInterval) {
this.systemHeartbeatReceiveInterval = heartbeatReceiveInterval;
@@ -187,8 +182,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
/**
* Set the login for the "system" connection used to send messages to the STOMP
* broker without having a client session (e.g. REST/HTTP request handling method).
* <p>
* See class-level documentation for more information on the "system" connection.
* <p>See class-level documentation for more information on the "system" connection.
*/
public void setSystemLogin(String systemLogin) {
Assert.hasText(systemLogin, "systemLogin must not be empty");
@@ -205,8 +199,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
/**
* Set the passcode for the "system" connection used to send messages to the STOMP
* broker without having a client session (e.g. REST/HTTP request handling method).
* <p>
* See class-level documentation for more information on the "system" connection.
* <p>See class-level documentation for more information on the "system" connection.
*/
public void setSystemPasscode(String systemPasscode) {
this.systemPasscode = systemPasscode;
@@ -225,8 +218,7 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
* the STOMP broker. This may be useful for example in a cloud environment where the
* actual host to which the TCP connection is established is different from the host
* providing the cloud-based STOMP service.
* <p>
* By default this property is not set.
* <p>By default this property is not set.
*/
public void setVirtualHost(String virtualHost) {
this.virtualHost = virtualHost;
@@ -374,8 +366,8 @@ public class StompBrokerRelayMessageHandler extends AbstractBrokerMessageHandler
private StompConnectionHandler(String sessionId, StompHeaderAccessor connectHeaders,
boolean isRemoteClientSession) {
Assert.notNull(sessionId, "sessionId is required");
Assert.notNull(connectHeaders, "connectHeaders is required");
Assert.notNull(sessionId, "SessionId must not be null");
Assert.notNull(connectHeaders, "ConnectHeaders must not be null");
this.sessionId = sessionId;
this.connectHeaders = connectHeaders;

View File

@@ -23,9 +23,7 @@ import java.util.Map;
import org.springframework.messaging.simp.SimpMessageType;
/**
*
* @author Rossen Stoyanchev
* @since 4.0
*/

View File

@@ -32,13 +32,12 @@ import org.springframework.util.MimeType;
import org.springframework.util.MimeTypeUtils;
import org.springframework.util.StringUtils;
/**
* Can be used to prepare headers for a new STOMP message, or to access and/or modify
* STOMP-specific headers of an existing message.
* <p>
* Use one of the static factory method in this class, then call getters and setters, and
* at the end if necessary call {@link #toMap()} to obtain the updated headers
*
* <p>Use one of the static factory method in this class, then call getters and setters,
* and at the end if necessary call {@link #toMap()} to obtain the updated headers
* or call {@link #toNativeHeaderMap()} to obtain only the STOMP-specific headers.
*
* @author Rossen Stoyanchev
@@ -101,7 +100,7 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
super(command.getMessageType(), externalSourceHeaders);
Assert.notNull(command, "command is required");
Assert.notNull(command, "Command must not be null");
setHeader(COMMAND_HEADER, command);
if (externalSourceHeaders != null) {

View File

@@ -31,7 +31,6 @@ import org.springframework.util.ObjectUtils;
*
* @author Mark Fisher
* @since 4.0
*
* @see MessageBuilder
*/
public class GenericMessage<T> implements Message<T>, Serializable {
@@ -46,7 +45,6 @@ public class GenericMessage<T> implements Message<T>, Serializable {
/**
* Create a new message with the given payload.
*
* @param payload the message payload
*/
public GenericMessage(T payload) {
@@ -56,7 +54,6 @@ public class GenericMessage<T> implements Message<T>, Serializable {
/**
* Create a new message with the given payload. The provided map will be used to
* populate the message headers
*
* @param payload the message payload
* @param headers message headers
* @see MessageHeaders

View File

@@ -51,11 +51,11 @@ public final class MessageBuilder<T> {
this.headerAccessor = new MessageHeaderAccessor(originalMessage);
}
/**
* Create a builder for a new {@link Message} instance pre-populated with all of the
* headers copied from the provided message. The payload of the provided Message will
* also be used as the payload for the new message.
*
* @param message the Message from which the payload and all headers will be copied
*/
public static <T> MessageBuilder<T> fromMessage(Message<T> message) {
@@ -65,7 +65,6 @@ public final class MessageBuilder<T> {
/**
* Create a builder for a new {@link Message} instance with the provided payload.
*
* @param payload the payload for the new message
*/
public static <T> MessageBuilder<T> withPayload(T payload) {
@@ -78,7 +77,7 @@ public final class MessageBuilder<T> {
* @param headerAccessor the headers for the message
*/
public MessageBuilder<T> setHeaders(MessageHeaderAccessor headerAccessor) {
Assert.notNull(headerAccessor, "headerAccessor is required");
Assert.notNull(headerAccessor, "HeaderAccessor must not be null");
this.headerAccessor = headerAccessor;
return this;
}

View File

@@ -28,7 +28,6 @@ import org.springframework.messaging.MessagingException;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
/**
* Abstract base class for {@link MessageChannel} implementations.
*

View File

@@ -19,7 +19,6 @@ package org.springframework.messaging.support.channel;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.SubscribableChannel;
/**
* Abstract base class for {@link SubscribableChannel} implementations.
*

View File

@@ -26,7 +26,6 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
/**
* A convenience wrapper class for invoking a list of {@link ChannelInterceptor}s.
*

View File

@@ -29,7 +29,6 @@ import org.springframework.messaging.support.MessageBuilder;
import org.springframework.util.Assert;
import org.springframework.util.MimeType;
/**
* Abstract base class for {@link MessageConverter} implementations including support for
* common properties and a partial implementation of the conversion methods mainly to
@@ -63,7 +62,7 @@ public abstract class AbstractMessageConverter implements MessageConverter {
* @param supportedMimeTypes the supported MIME types
*/
protected AbstractMessageConverter(Collection<MimeType> supportedMimeTypes) {
Assert.notNull(supportedMimeTypes, "'supportedMimeTypes' is required");
Assert.notNull(supportedMimeTypes, "SupportedMimeTypes must not be null");
this.supportedMimeTypes = new ArrayList<MimeType>(supportedMimeTypes);
}
@@ -77,8 +76,7 @@ public abstract class AbstractMessageConverter implements MessageConverter {
/**
* Configure the {@link ContentTypeResolver} to use.
* <p>
* The default value is {@code null}. However when {@link CompositeMessageConverter}
* <p>The default value is {@code null}. However when {@link CompositeMessageConverter}
* is used it configures all of its delegates with a default resolver.
*/
public void setContentTypeResolver(ContentTypeResolver resolver) {
@@ -95,15 +93,13 @@ public abstract class AbstractMessageConverter implements MessageConverter {
/**
* Configure the preferred serialization class to use (byte[] or String) when
* converting an Object payload to a {@link Message}.
* <p>
* The default value is byte[].
*
* @param clazz either byte[] or String
* <p>The default value is byte[].
* @param payloadClass either byte[] or String
*/
public void setSerializedPayloadClass(Class<?> clazz) {
Assert.isTrue(byte[].class.equals(clazz) || String.class.equals(clazz),
"Payload class must be byte[] or String: " + clazz);
this.serializedPayloadClass = clazz;
public void setSerializedPayloadClass(Class<?> payloadClass) {
Assert.isTrue(byte[].class.equals(payloadClass) || String.class.equals(payloadClass),
"Payload class must be byte[] or String: " + payloadClass);
this.serializedPayloadClass = payloadClass;
}
/**
@@ -117,10 +113,8 @@ public abstract class AbstractMessageConverter implements MessageConverter {
* Returns the default content type for the payload. Called when
* {@link #toMessage(Object, MessageHeaders)} is invoked without message headers or
* without a content type header.
* <p>
* By default, this returns the first element of the {@link #getSupportedMimeTypes()
* <p>By default, this returns the first element of the {@link #getSupportedMimeTypes()
* supportedMimeTypes}, if any. Can be overridden in sub-classes.
*
* @param payload the payload being converted to message
* @return the content type, or {@code null} if not known
*/
@@ -131,7 +125,6 @@ public abstract class AbstractMessageConverter implements MessageConverter {
/**
* Whether the given class is supported by this converter.
*
* @param clazz the class to test for support
* @return {@code true} if supported; {@code false} otherwise
*/

View File

@@ -20,7 +20,6 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.util.MimeTypeUtils;
/**
* A {@link MessageConverter} that supports MIME type "application/octet-stream" with the
* payload converted to and from a byte[].

View File

@@ -24,7 +24,6 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.util.Assert;
/**
* A {@link MessageConverter} that delegates to a list of other converters to invoke until
* one of them returns a non-null value.
@@ -52,8 +51,8 @@ public class CompositeMessageConverter implements MessageConverter {
* the given {@link ContentTypeResolver}.
*/
public CompositeMessageConverter(Collection<MessageConverter> converters, ContentTypeResolver resolver) {
Assert.notEmpty(converters, "converters is required");
Assert.notNull(resolver, "contentTypeResolver is required");
Assert.notEmpty(converters, "Converters must not be null");
Assert.notNull(resolver, "ContentTypeResolver must not be null");
this.converters = new ArrayList<MessageConverter>(converters);
this.contentTypeResolver = resolver;
applyContentTypeResolver(converters, resolver);

View File

@@ -19,7 +19,6 @@ package org.springframework.messaging.support.converter;
import org.springframework.messaging.MessageHeaders;
import org.springframework.util.MimeType;
/**
* Resolve the content type for a message given a set of {@link MessageHeaders}.
*

View File

@@ -19,7 +19,6 @@ package org.springframework.messaging.support.converter;
import org.springframework.messaging.MessageHeaders;
import org.springframework.util.MimeType;
/**
* A default {@link ContentTypeResolver} that checks the
* {@link MessageHeaders#CONTENT_TYPE} header or falls back to a default, if a default is

View File

@@ -33,7 +33,6 @@ import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
/**
* A Jackson 2 based {@link MessageConverter} implementation.
*

View File

@@ -19,7 +19,6 @@ package org.springframework.messaging.support.converter;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
/**
* A converter to turn the payload of a {@link Message} from serialized form to a typed
* Object and vice versa. The {@link MessageHeaders#CONTENT_TYPE} message header may be
@@ -35,15 +34,12 @@ public interface MessageConverter {
* Convert the payload of a {@link Message} from serialized form to a typed Object of
* the specified target class. The {@link MessageHeaders#CONTENT_TYPE} header should
* indicate the MIME type to convert from.
* <p>
* If the converter does not support the specified media type or cannot perform the
* <p>If the converter does not support the specified media type or cannot perform the
* conversion, it should return {@code null}.
*
* @param message the input message
* @param targetClass the target class for the conversion
*
* @return the result of the conversion or {@code null} if the converter cannot
* perform the conversion
* perform the conversion
*/
Object fromMessage(Message<?> message, Class<?> targetClass);
@@ -53,15 +49,12 @@ public interface MessageConverter {
* may contain a {@link MessageHeaders#CONTENT_TYPE} header to specify the target
* media type for the conversion and it may contain additional headers to be added to
* the message.
* <p>
* If the converter does not support the specified media type or cannot perform the
* <p>If the converter does not support the specified media type or cannot perform the
* conversion, it should return {@code null}.
*
* @param payload the Object to convert
* @param header optional headers for the message, may be {@code null}
*
* @return the new message or {@code null} if the converter does not support the
* Object type or the target media type
* Object type or the target media type
*/
Message<?> toMessage(Object payload, MessageHeaders header);

View File

@@ -24,8 +24,8 @@ import org.springframework.util.ClassUtils;
/**
* A simple converter that simply unwraps the message payload as long as it matches the
* expected target class. Or reversely, simply wraps the payload in a message.
* <p>
* Note that this converter ignores any content type information that may be present in
*
* <p>Note that this converter ignores any content type information that may be present in
* message headers and should not be used if payload conversion is actually required.
*
* @author Rossen Stoyanchev

View File

@@ -22,7 +22,6 @@ import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.util.MimeType;
/**
* A {@link MessageConverter} that supports MIME type "text/plain" with the
* payload converted to and from a String.

View File

@@ -46,8 +46,7 @@ abstract class AbstractPromiseToListenableFutureAdapter<S, T> implements Listena
protected AbstractPromiseToListenableFutureAdapter(Promise<S> promise) {
Assert.notNull(promise, "promise is required");
Assert.notNull(promise, "Promise must not be null");
this.promise = promise;
this.promise.onSuccess(new Consumer<S>() {

View File

@@ -16,7 +16,6 @@
package org.springframework.messaging.support.tcp;
/**
* A simple strategy for making reconnect attempts at a fixed interval.
*
@@ -35,6 +34,7 @@ public class FixedIntervalReconnectStrategy implements ReconnectStrategy {
this.interval = interval;
}
@Override
public Long getTimeToNextAttempt(int attemptCount) {
return this.interval;

View File

@@ -18,7 +18,6 @@ package org.springframework.messaging.support.tcp;
import reactor.core.composable.Promise;
/**
* A Promise-to-ListenableFutureAdapter where the source and the target from the Promise and
* the ListenableFuture respectively are of the same type.
@@ -29,13 +28,14 @@ import reactor.core.composable.Promise;
class PassThroughPromiseToListenableFutureAdapter<T> extends AbstractPromiseToListenableFutureAdapter<T, T> {
public PassThroughPromiseToListenableFutureAdapter(Promise<T> promise) {
super(promise);
}
public PassThroughPromiseToListenableFutureAdapter(Promise<T> promise) {
super(promise);
}
@Override
protected T adapt(T result) {
return result;
}
}
@Override
protected T adapt(T result) {
return result;
}
}

View File

@@ -85,7 +85,7 @@ public class ReactorNettyTcpClient<P> implements TcpOperations<P> {
public ListenableFuture<Void> connect(final TcpConnectionHandler<P> connectionHandler,
final ReconnectStrategy reconnectStrategy) {
Assert.notNull(reconnectStrategy, "'reconnectStrategy' is required");
Assert.notNull(reconnectStrategy, "ReconnectStrategy must not be null");
Stream<TcpConnection<Message<P>, Message<P>>> stream =
this.tcpClient.open(new Reconnect() {

View File

@@ -27,7 +27,6 @@ public interface ReconnectStrategy {
/**
* Return the time to the next attempt to reconnect.
*
* @param attemptCount how many reconnect attempts have been made already
* @return the amount of time in milliseconds or {@code null} to stop
*/

View File

@@ -32,9 +32,8 @@ public interface TcpConnection<P> {
/**
* Send the given message.
* @param message the message
*
* @return a ListenableFuture that can be used to determine when and if the
* message was successfully sent
* message was successfully sent
*/
ListenableFuture<Void> send(Message<P> message);

View File

@@ -30,30 +30,25 @@ public interface TcpOperations<P> {
/**
* Open a new connection.
*
* @param connectionHandler a handler to manage the connection
*
* @return a ListenableFuture that can be used to determine when and if the
* connection is successfully established
* connection is successfully established
*/
ListenableFuture<Void> connect(TcpConnectionHandler<P> connectionHandler);
/**
* Open a new connection and a strategy for reconnecting if the connection fails.
*
* @param connectionHandler a handler to manage the connection
* @param reconnectStrategy a strategy for reconnecting
*
* @return a ListenableFuture that can be used to determine when and if the
* initial connection is successfully established
* initial connection is successfully established
*/
ListenableFuture<Void> connect(TcpConnectionHandler<P> connectionHandler, ReconnectStrategy reconnectStrategy);
/**
* Shut down and close any open connections.
*
* @return a ListenableFuture that can be used to determine when and if the
* connection is successfully closed
* connection is successfully closed
*/
ListenableFuture<Void> shutdown();