Moved messaging.support.converter to messaging.converter; moved messaging.support.tcp to messaging.tcp; moved messaging.support.channel to messaging.support itself; moved handler.condition to handler itself; reworked handler.method into handler.support
This commit is contained in:
parent
947f3d4b2b
commit
c4163c7475
|
@ -22,7 +22,6 @@ package org.springframework.messaging;
|
|||
* @author Mark Fisher
|
||||
* @author Arjen Poutsma
|
||||
* @since 4.0
|
||||
*
|
||||
* @see org.springframework.messaging.support.MessageBuilder
|
||||
*/
|
||||
public interface Message<T> {
|
||||
|
|
|
@ -35,10 +35,8 @@ public interface MessageChannel {
|
|||
* the method returns {@code true}. If the message cannot be sent due to a
|
||||
* non-fatal reason, the method returns {@code false}. The method may also
|
||||
* throw a RuntimeException in case of non-recoverable errors.
|
||||
* <p>
|
||||
* This method may block indefinitely, depending on the implementation.
|
||||
* <p>This method may block indefinitely, depending on the implementation.
|
||||
* To provide a maximum wait time, use {@link #send(Message, long)}.
|
||||
*
|
||||
* @param message the message to send
|
||||
* @return whether or not the message was sent
|
||||
*/
|
||||
|
@ -47,11 +45,10 @@ public interface MessageChannel {
|
|||
/**
|
||||
* Send a message, blocking until either the message is accepted or the
|
||||
* specified timeout period elapses.
|
||||
*
|
||||
* @param message the message to send
|
||||
* @param timeout the timeout in milliseconds or {@link #INDEFINITE_TIMEOUT}
|
||||
* @return {@code true} if the message is sent, {@code false} if not including
|
||||
* a timeout of an interrupt of the send
|
||||
* @return {@code true} if the message is sent, {@code false} if not
|
||||
* including a timeout of an interrupt of the send
|
||||
*/
|
||||
boolean send(Message<?> message, long timeout);
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ package org.springframework.messaging;
|
|||
@SuppressWarnings("serial")
|
||||
public class MessageDeliveryException extends MessagingException {
|
||||
|
||||
|
||||
public MessageDeliveryException(String description) {
|
||||
super(description);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ public interface MessageHandler {
|
|||
|
||||
/**
|
||||
* Handle the given message.
|
||||
*
|
||||
* @param message the message to be handled
|
||||
*/
|
||||
void handleMessage(Message<?> message) throws MessagingException;
|
||||
|
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
package org.springframework.messaging;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
|
||||
/**
|
||||
* Exception that indicates an error occurred during message handling.
|
||||
*
|
||||
|
|
|
@ -21,7 +21,6 @@ import java.io.ObjectInputStream;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -33,6 +32,7 @@ import java.util.UUID;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.util.AlternativeJdkIdGenerator;
|
||||
import org.springframework.util.IdGenerator;
|
||||
|
||||
|
@ -63,7 +63,6 @@ import org.springframework.util.IdGenerator;
|
|||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @since 4.0
|
||||
*
|
||||
* @see org.springframework.messaging.support.MessageBuilder
|
||||
* @see org.springframework.messaging.support.MessageHeaderAccessor
|
||||
*/
|
||||
|
@ -93,8 +92,6 @@ public final class MessageHeaders implements Map<String, Object>, Serializable {
|
|||
|
||||
public static final String CONTENT_TYPE = "contentType";
|
||||
|
||||
public static final List<String> HEADER_NAMES = Arrays.asList(ID, TIMESTAMP);
|
||||
|
||||
|
||||
private final Map<String, Object> headers;
|
||||
|
||||
|
@ -102,7 +99,7 @@ public final class MessageHeaders implements Map<String, Object>, Serializable {
|
|||
public MessageHeaders(Map<String, Object> headers) {
|
||||
this.headers = (headers != null) ? new HashMap<String, Object>(headers) : new HashMap<String, Object>();
|
||||
this.headers.put(ID, ((idGenerator != null) ? idGenerator : defaultIdGenerator).generateId());
|
||||
this.headers.put(TIMESTAMP, new Long(System.currentTimeMillis()));
|
||||
this.headers.put(TIMESTAMP, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
|
||||
|
@ -199,31 +196,31 @@ public final class MessageHeaders implements Map<String, Object>, Serializable {
|
|||
// Unsupported operations
|
||||
|
||||
/**
|
||||
* Since MessageHeaders are immutable the call to this method will result in {@link UnsupportedOperationException}
|
||||
* Since MessageHeaders are immutable, the call to this method will result in {@link UnsupportedOperationException}.
|
||||
*/
|
||||
public Object put(String key, Object value) {
|
||||
throw new UnsupportedOperationException("MessageHeaders is immutable.");
|
||||
throw new UnsupportedOperationException("MessageHeaders is immutable");
|
||||
}
|
||||
|
||||
/**
|
||||
* Since MessageHeaders are immutable the call to this method will result in {@link UnsupportedOperationException}
|
||||
* Since MessageHeaders are immutable, the call to this method will result in {@link UnsupportedOperationException}.
|
||||
*/
|
||||
public void putAll(Map<? extends String, ? extends Object> t) {
|
||||
throw new UnsupportedOperationException("MessageHeaders is immutable.");
|
||||
throw new UnsupportedOperationException("MessageHeaders is immutable");
|
||||
}
|
||||
|
||||
/**
|
||||
* Since MessageHeaders are immutable the call to this method will result in {@link UnsupportedOperationException}
|
||||
* Since MessageHeaders are immutable, the call to this method will result in {@link UnsupportedOperationException}.
|
||||
*/
|
||||
public Object remove(Object key) {
|
||||
throw new UnsupportedOperationException("MessageHeaders is immutable.");
|
||||
throw new UnsupportedOperationException("MessageHeaders is immutable");
|
||||
}
|
||||
|
||||
/**
|
||||
* Since MessageHeaders are immutable the call to this method will result in {@link UnsupportedOperationException}
|
||||
* Since MessageHeaders are immutable, the call to this method will result in {@link UnsupportedOperationException}.
|
||||
*/
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException("MessageHeaders is immutable.");
|
||||
throw new UnsupportedOperationException("MessageHeaders is immutable");
|
||||
}
|
||||
|
||||
// Serialization methods
|
||||
|
|
|
@ -26,7 +26,7 @@ package org.springframework.messaging;
|
|||
@SuppressWarnings("serial")
|
||||
public class MessagingException extends RuntimeException {
|
||||
|
||||
private volatile Message<?> failedMessage;
|
||||
private final Message<?> failedMessage;
|
||||
|
||||
|
||||
public MessagingException(Message<?> message) {
|
||||
|
@ -64,8 +64,4 @@ public class MessagingException extends RuntimeException {
|
|||
return this.failedMessage;
|
||||
}
|
||||
|
||||
public void setFailedMessage(Message<?> message) {
|
||||
this.failedMessage = message;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,6 @@ public interface PollableChannel extends MessageChannel {
|
|||
|
||||
/**
|
||||
* Receive a message from this channel, blocking indefinitely if necessary.
|
||||
*
|
||||
* @return the next available {@link Message} or {@code null} if interrupted
|
||||
*/
|
||||
Message<?> receive();
|
||||
|
@ -34,10 +33,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}.
|
||||
* @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);
|
||||
|
||||
|
|
|
@ -25,10 +25,8 @@ package org.springframework.messaging;
|
|||
*/
|
||||
public interface SubscribableChannel extends MessageChannel {
|
||||
|
||||
|
||||
/**
|
||||
* Register a message handler.
|
||||
*
|
||||
* @return {@code true} if the handler was subscribed or {@code false} if it
|
||||
* was already subscribed.
|
||||
*/
|
||||
|
@ -36,7 +34,6 @@ public interface SubscribableChannel extends MessageChannel {
|
|||
|
||||
/**
|
||||
* Un-register a message handler.
|
||||
*
|
||||
* @return {@code true} if the handler was un-registered, or {@code false}
|
||||
* if was not registered.
|
||||
*/
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.converter;
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
@ -23,6 +23,7 @@ import java.util.List;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.converter;
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.converter;
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.converter;
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.util.MimeType;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.converter;
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.util.MimeType;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.converter;
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.converter;
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessagingException;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.converter;
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.converter;
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
|
@ -44,7 +44,7 @@ public class SimpleMessageConverter implements MessageConverter {
|
|||
|
||||
@Override
|
||||
public Message<?> toMessage(Object payload, MessageHeaders headers) {
|
||||
return (payload != null) ? MessageBuilder.withPayload(payload).copyHeaders(headers).build() : null;
|
||||
return (payload != null ? MessageBuilder.withPayload(payload).copyHeaders(headers).build() : null);
|
||||
}
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.converter;
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* Provides support for message conversion.
|
||||
*/
|
||||
package org.springframework.messaging.converter;
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.core;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -34,8 +35,7 @@ import org.springframework.util.Assert;
|
|||
* @since 4.0
|
||||
*/
|
||||
public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends AbstractMessagingTemplate<D>
|
||||
implements
|
||||
DestinationResolvingMessageSendingOperations<D>,
|
||||
implements DestinationResolvingMessageSendingOperations<D>,
|
||||
DestinationResolvingMessageReceivingOperations<D>,
|
||||
DestinationResolvingMessageRequestReplyOperations<D> {
|
||||
|
||||
|
@ -45,10 +45,8 @@ public abstract class AbstractDestinationResolvingMessagingTemplate<D> extends A
|
|||
/**
|
||||
* Configure the {@link DestinationResolver} to use to resolve String destination
|
||||
* names into actual destinations of type {@code <D>}.
|
||||
* <p>
|
||||
* This field does not have a default setting. If not configured, methods that
|
||||
* <p>This field does not have a default setting. If not configured, methods that
|
||||
* require resolving a destination name will raise an {@link IllegalArgumentException}.
|
||||
*
|
||||
* @param destinationResolver the destination resolver to use
|
||||
*/
|
||||
public void setDestinationResolver(DestinationResolver<D> destinationResolver) {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.core;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -22,8 +23,8 @@ import org.apache.commons.logging.LogFactory;
|
|||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.support.converter.MessageConverter;
|
||||
import org.springframework.messaging.support.converter.SimpleMessageConverter;
|
||||
import org.springframework.messaging.converter.MessageConverter;
|
||||
import org.springframework.messaging.converter.SimpleMessageConverter;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
@ -46,8 +47,6 @@ public abstract class AbstractMessageSendingTemplate<D> implements MessageSendin
|
|||
* Configure the default destination to use in send methods that don't have
|
||||
* a destination argument. If a default destination is not configured, send methods
|
||||
* without a destination argument will raise an exception if invoked.
|
||||
*
|
||||
* @param defaultDestination the default destination
|
||||
*/
|
||||
public void setDefaultDestination(D defaultDestination) {
|
||||
this.defaultDestination = defaultDestination;
|
||||
|
@ -62,9 +61,7 @@ public abstract class AbstractMessageSendingTemplate<D> implements MessageSendin
|
|||
|
||||
/**
|
||||
* Set the {@link MessageConverter} to use in {@code convertAndSend} methods.
|
||||
* <p>
|
||||
* By default {@link SimpleMessageConverter} is used.
|
||||
*
|
||||
* <p>By default, {@link SimpleMessageConverter} is used.
|
||||
* @param messageConverter the message converter to use
|
||||
*/
|
||||
public void setMessageConverter(MessageConverter messageConverter) {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.core;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.core;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
|
@ -32,7 +33,7 @@ import org.springframework.util.Assert;
|
|||
public class BeanFactoryMessageChannelDestinationResolver
|
||||
implements DestinationResolver<MessageChannel>, BeanFactoryAware {
|
||||
|
||||
private volatile BeanFactory beanFactory;
|
||||
private BeanFactory beanFactory;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -43,16 +44,9 @@ public class BeanFactoryMessageChannelDestinationResolver
|
|||
public BeanFactoryMessageChannelDestinationResolver() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* A constructor that accepts a {@link BeanFactory} useful if instantiating this
|
||||
* resolver manually rather than having it defined as a Spring-managed bean.
|
||||
*
|
||||
* @param beanFactory the bean factory to perform lookups against
|
||||
*/
|
||||
public BeanFactoryMessageChannelDestinationResolver(BeanFactory beanFactory) {
|
||||
|
@ -61,15 +55,21 @@ public class BeanFactoryMessageChannelDestinationResolver
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MessageChannel resolveDestination(String name) {
|
||||
Assert.state(this.beanFactory != null, "No BeanFactory configured");
|
||||
try {
|
||||
return this.beanFactory.getBean(name, MessageChannel.class);
|
||||
}
|
||||
catch (BeansException e) {
|
||||
catch (BeansException ex) {
|
||||
throw new DestinationResolutionException(
|
||||
"Failed to find MessageChannel bean with name '" + name + "'", e);
|
||||
"Failed to find MessageChannel bean with name '" + name + "'", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,22 +28,10 @@ import org.springframework.messaging.MessagingException;
|
|||
@SuppressWarnings("serial")
|
||||
public class DestinationResolutionException extends MessagingException {
|
||||
|
||||
|
||||
/**
|
||||
* Create an instance with the given description only.
|
||||
*
|
||||
* @param description the description
|
||||
*/
|
||||
public DestinationResolutionException(String description) {
|
||||
super(description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an instance with the given description and original cause.
|
||||
*
|
||||
* @param description the description
|
||||
* @param cause the root cause
|
||||
*/
|
||||
public DestinationResolutionException(String description, Throwable cause) {
|
||||
super(description, cause);
|
||||
}
|
||||
|
|
|
@ -25,10 +25,8 @@ package org.springframework.messaging.core;
|
|||
*/
|
||||
public interface DestinationResolver<D> {
|
||||
|
||||
|
||||
/**
|
||||
* Resolve the given destination name.
|
||||
*
|
||||
* @param name the destination name to resolve
|
||||
* @return the destination, never {@code null}
|
||||
*/
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.core;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
|
@ -25,14 +26,12 @@ import org.springframework.messaging.MessagingException;
|
|||
* @author Mark Fisher
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*
|
||||
* @see DestinationResolver
|
||||
*/
|
||||
public interface DestinationResolvingMessageReceivingOperations<D> extends MessageReceivingOperations<D> {
|
||||
|
||||
/**
|
||||
* Resolve the given destination name and receive a message from it.
|
||||
*
|
||||
* @param destinationName the destination name to resolve
|
||||
*/
|
||||
Message<?> receive(String destinationName) throws MessagingException;
|
||||
|
@ -40,7 +39,6 @@ public interface DestinationResolvingMessageReceivingOperations<D> extends Messa
|
|||
/**
|
||||
* Resolve the given destination name, receive a message from it, convert the
|
||||
* payload to the specified target type.
|
||||
*
|
||||
* @param destinationName the destination name to resolve
|
||||
* @param targetClass the target class for the converted payload
|
||||
*/
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.core;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -27,7 +28,6 @@ import org.springframework.messaging.MessagingException;
|
|||
* @author Mark Fisher
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*
|
||||
* @see DestinationResolver
|
||||
*/
|
||||
public interface DestinationResolvingMessageRequestReplyOperations<D> extends MessageRequestReplyOperations<D> {
|
||||
|
@ -35,26 +35,24 @@ public interface DestinationResolvingMessageRequestReplyOperations<D> extends Me
|
|||
/**
|
||||
* Resolve the given destination name to a destination and send the given message,
|
||||
* receive a reply and return it.
|
||||
*
|
||||
* @param destinationName the name of the target destination
|
||||
* @param requestMessage the mesage to send
|
||||
* @return the received message, possibly {@code null} if the message could not
|
||||
* be received, for example due to a timeout
|
||||
* be received, for example due to a timeout
|
||||
*/
|
||||
Message<?> sendAndReceive(String destinationName, Message<?> requestMessage) throws MessagingException;
|
||||
|
||||
/**
|
||||
* Resolve the given destination name, convert the payload request Object
|
||||
* to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message and send it to the resolved destination, receive a reply
|
||||
* and convert its body to the specified target class.
|
||||
*
|
||||
* @param destinationName the name of the target destination
|
||||
* @param request the payload for the request message to send
|
||||
* @param targetClass the target class to convert the payload of the reply to
|
||||
* @return the converted payload of the reply message, possibly {@code null} if
|
||||
* the message could not be received, for example due to a timeout
|
||||
* the message could not be received, for example due to a timeout
|
||||
*/
|
||||
<T> T convertSendAndReceive(String destinationName, Object request, Class<T> targetClass)
|
||||
throws MessagingException;
|
||||
|
@ -62,16 +60,15 @@ public interface DestinationResolvingMessageRequestReplyOperations<D> extends Me
|
|||
/**
|
||||
* Resolve the given destination name, convert the payload request Object
|
||||
* to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message with the given headers and send it to the resolved destination,
|
||||
* receive a reply and convert its body to the specified target class.
|
||||
*
|
||||
* @param destinationName the name of the target destination
|
||||
* @param request the payload for the request message to send
|
||||
* @param headers the headers for the request message to send
|
||||
* @param targetClass the target class to convert the payload of the reply to
|
||||
* @return the converted payload of the reply message, possibly {@code null} if
|
||||
* the message could not be received, for example due to a timeout
|
||||
* the message could not be received, for example due to a timeout
|
||||
*/
|
||||
<T> T convertSendAndReceive(String destinationName, Object request, Map<String, Object> headers,
|
||||
Class<T> targetClass) throws MessagingException;
|
||||
|
@ -79,17 +76,16 @@ public interface DestinationResolvingMessageRequestReplyOperations<D> extends Me
|
|||
/**
|
||||
* Resolve the given destination name, convert the payload request Object
|
||||
* to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message, apply the given post process, and send the resulting
|
||||
* message to the resolved destination, then receive a reply and convert its
|
||||
* body to the specified target class.
|
||||
*
|
||||
* @param destinationName the name of the target destination
|
||||
* @param request the payload for the request message to send
|
||||
* @param targetClass the target class to convert the payload of the reply to
|
||||
* @param requestPostProcessor post process for the request message
|
||||
* @return the converted payload of the reply message, possibly {@code null} if
|
||||
* the message could not be received, for example due to a timeout
|
||||
* the message could not be received, for example due to a timeout
|
||||
*/
|
||||
<T> T convertSendAndReceive(String destinationName, Object request,
|
||||
Class<T> targetClass, MessagePostProcessor requestPostProcessor) throws MessagingException;
|
||||
|
@ -97,18 +93,17 @@ public interface DestinationResolvingMessageRequestReplyOperations<D> extends Me
|
|||
/**
|
||||
* Resolve the given destination name, convert the payload request Object
|
||||
* to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message with the given headers, apply the given post process,
|
||||
* and send the resulting message to the resolved destination, then receive
|
||||
* a reply and convert its body to the specified target class.
|
||||
*
|
||||
* @param destinationName the name of the target destination
|
||||
* @param request the payload for the request message to send
|
||||
* @param headers the headers for the request message to send
|
||||
* @param targetClass the target class to convert the payload of the reply to
|
||||
* @param requestPostProcessor post process for the request message
|
||||
* @return the converted payload of the reply message, possibly {@code null} if
|
||||
* the message could not be received, for example due to a timeout
|
||||
* the message could not be received, for example due to a timeout
|
||||
*/
|
||||
<T> T convertSendAndReceive(String destinationName, Object request, Map<String, Object> headers,
|
||||
Class<T> targetClass, MessagePostProcessor requestPostProcessor) throws MessagingException;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.core;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -27,14 +28,12 @@ import org.springframework.messaging.MessagingException;
|
|||
* @author Mark Fisher
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*
|
||||
* @see DestinationResolver
|
||||
*/
|
||||
public interface DestinationResolvingMessageSendingOperations<D> extends MessageSendingOperations<D> {
|
||||
|
||||
/**
|
||||
* Resolve the given destination name to a destination and send a message to it.
|
||||
*
|
||||
* @param destinationName the destination name to resolve
|
||||
* @param message the message to send
|
||||
*/
|
||||
|
@ -43,9 +42,8 @@ public interface DestinationResolvingMessageSendingOperations<D> extends Message
|
|||
/**
|
||||
* Resolve the given destination name to a destination, convert the payload Object
|
||||
* to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message and send it to the resolved destination.
|
||||
|
||||
* @param destinationName the destination name to resolve
|
||||
* @param payload the Object to use as payload
|
||||
*/
|
||||
|
@ -54,10 +52,9 @@ public interface DestinationResolvingMessageSendingOperations<D> extends Message
|
|||
/**
|
||||
* Resolve the given destination name to a destination, convert the payload
|
||||
* Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message with the given headers and send it to the resolved
|
||||
* destination.
|
||||
|
||||
* @param destinationName the destination name to resolve
|
||||
* @param payload the Object to use as payload
|
||||
* @param headers headers for the message to send
|
||||
|
@ -68,10 +65,9 @@ public interface DestinationResolvingMessageSendingOperations<D> extends Message
|
|||
/**
|
||||
* Resolve the given destination name to a destination, convert the payload
|
||||
* Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message, apply the given post processor, and send the resulting
|
||||
* message to the resolved destination.
|
||||
|
||||
* @param destinationName the destination name to resolve
|
||||
* @param payload the Object to use as payload
|
||||
* @param postProcessor the post processor to apply to the message
|
||||
|
@ -82,10 +78,9 @@ public interface DestinationResolvingMessageSendingOperations<D> extends Message
|
|||
/**
|
||||
* Resolve the given destination name to a destination, convert the payload
|
||||
* Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message with the given headers, apply the given post processor,
|
||||
* and send the resulting message to the resolved destination.
|
||||
|
||||
* @param destinationName the destination name to resolve
|
||||
* @param payload the Object to use as payload
|
||||
* @param headers headers for the message to send
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.core;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
@ -20,6 +21,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.springframework.messaging.Message;
|
|||
* @author Mark Fisher
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*
|
||||
* @see MessageSendingOperations
|
||||
* @see MessageRequestReplyOperations
|
||||
*/
|
||||
|
@ -33,9 +32,9 @@ public interface MessagePostProcessor {
|
|||
|
||||
/**
|
||||
* Process the given message.
|
||||
*
|
||||
* @param message the message to process
|
||||
* @return a new or the same message, never {@code null}
|
||||
* @return a post-processed variant of the message,
|
||||
* or simply the incoming message; never {@code null}
|
||||
*/
|
||||
Message<?> postProcessMessage(Message<?> message);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.core;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
|
@ -26,49 +27,42 @@ import org.springframework.messaging.MessagingException;
|
|||
* @author Mark Fisher
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*
|
||||
* @see GenericMessagingTemplate
|
||||
*/
|
||||
public interface MessageReceivingOperations<D> {
|
||||
|
||||
/**
|
||||
* Receive a message from a default destination.
|
||||
*
|
||||
* @return the received message, possibly {@code null} if the message could not
|
||||
* be received, for example due to a timeout
|
||||
* be received, for example due to a timeout
|
||||
*/
|
||||
Message<?> receive() throws MessagingException;
|
||||
|
||||
/**
|
||||
* Receive a message from the given destination.
|
||||
*
|
||||
* @param destination the target destination
|
||||
* @return the received message, possibly {@code null} if the message could not
|
||||
* be received, for example due to a timeout
|
||||
* be received, for example due to a timeout
|
||||
*/
|
||||
Message<?> receive(D destination) throws MessagingException;
|
||||
|
||||
/**
|
||||
* Receive a message from a default destination and convert its payload to the
|
||||
* specified target class.
|
||||
*
|
||||
* @param targetClass the target class to convert the payload to
|
||||
* @return the converted payload of the reply message, possibly {@code null} if
|
||||
* the message could not be received, for example due to a timeout
|
||||
* the message could not be received, for example due to a timeout
|
||||
*/
|
||||
<T> T receiveAndConvert(Class<T> targetClass) throws MessagingException;
|
||||
|
||||
/**
|
||||
* Receive a message from the given destination and convert its payload to the
|
||||
* specified target class.
|
||||
*
|
||||
* @param destination the target destination
|
||||
* @param targetClass the target class to convert the payload to
|
||||
* @return the converted payload of the reply message, possibly {@code null} if
|
||||
* the message could not be received, for example due to a timeout
|
||||
* the message could not be received, for example due to a timeout
|
||||
*/
|
||||
<T> T receiveAndConvert(D destination, Class<T> targetClass) throws MessagingException;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.core;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -28,119 +29,110 @@ import org.springframework.messaging.MessagingException;
|
|||
* @author Mark Fisher
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*
|
||||
* @see GenericMessagingTemplate
|
||||
*/
|
||||
public interface MessageRequestReplyOperations<D> {
|
||||
|
||||
/**
|
||||
* Send a request message and receive the reply from a default destination.
|
||||
*
|
||||
* @param requestMessage the message to send
|
||||
* @return the reply, possibly {@code null} if the message could not be received,
|
||||
* for example due to a timeout
|
||||
* for example due to a timeout
|
||||
*/
|
||||
Message<?> sendAndReceive(Message<?> requestMessage) throws MessagingException;
|
||||
|
||||
/**
|
||||
* Send a request message and receive the reply from the given destination.
|
||||
*
|
||||
* @param destination the target destination
|
||||
* @param requestMessage the message to send
|
||||
* @return the reply, possibly {@code null} if the message could not be received,
|
||||
* for example due to a timeout
|
||||
* for example due to a timeout
|
||||
*/
|
||||
Message<?> sendAndReceive(D destination, Message<?> requestMessage) throws MessagingException;
|
||||
|
||||
/**
|
||||
* Convert the given request Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter}, send
|
||||
* {@link org.springframework.messaging.converter.MessageConverter}, send
|
||||
* it as a {@link Message} to a default destination, receive the reply and convert
|
||||
* its body of the specified target class.
|
||||
*
|
||||
* @param request payload for the request message to send
|
||||
* @param targetClass the target type to convert the payload of the reply to
|
||||
* @return the payload of the reply message, possibly {@code null} if the message
|
||||
* could not be received, for example due to a timeout
|
||||
* could not be received, for example due to a timeout
|
||||
*/
|
||||
<T> T convertSendAndReceive(Object request, Class<T> targetClass) throws MessagingException;
|
||||
|
||||
/**
|
||||
* Convert the given request Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter}, send
|
||||
* {@link org.springframework.messaging.converter.MessageConverter}, send
|
||||
* it as a {@link Message} to the given destination, receive the reply and convert
|
||||
* its body of the specified target class.
|
||||
*
|
||||
* @param destination the target destination
|
||||
* @param request payload for the request message to send
|
||||
* @param targetClass the target type to convert the payload of the reply to
|
||||
* @return the payload of the reply message, possibly {@code null} if the message
|
||||
* could not be received, for example due to a timeout
|
||||
* could not be received, for example due to a timeout
|
||||
*/
|
||||
<T> T convertSendAndReceive(D destination, Object request, Class<T> targetClass) throws MessagingException;
|
||||
|
||||
/**
|
||||
* Convert the given request Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter}, send
|
||||
* {@link org.springframework.messaging.converter.MessageConverter}, send
|
||||
* it as a {@link Message} with the given headers, to the specified destination,
|
||||
* receive the reply and convert its body of the specified target class.
|
||||
*
|
||||
* @param destination the target destination
|
||||
* @param request payload for the request message to send
|
||||
* @param headers headers for the request message to send
|
||||
* @param targetClass the target type to convert the payload of the reply to
|
||||
* @return the payload of the reply message, possibly {@code null} if the message
|
||||
* could not be received, for example due to a timeout
|
||||
* could not be received, for example due to a timeout
|
||||
*/
|
||||
<T> T convertSendAndReceive(D destination, Object request, Map<String, Object> headers, Class<T> targetClass)
|
||||
throws MessagingException;
|
||||
|
||||
/**
|
||||
* Convert the given request Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* apply the given post processor and send the resulting {@link Message} to a
|
||||
* default destination, receive the reply and convert its body of the given
|
||||
* target class.
|
||||
*
|
||||
* @param request payload for the request message to send
|
||||
* @param targetClass the target type to convert the payload of the reply to
|
||||
* @param requestPostProcessor post process to apply to the request message
|
||||
* @return the payload of the reply message, possibly {@code null} if the message
|
||||
* could not be received, for example due to a timeout
|
||||
* could not be received, for example due to a timeout
|
||||
*/
|
||||
<T> T convertSendAndReceive(Object request, Class<T> targetClass, MessagePostProcessor requestPostProcessor)
|
||||
throws MessagingException;
|
||||
|
||||
/**
|
||||
* Convert the given request Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* apply the given post processor and send the resulting {@link Message} to the
|
||||
* given destination, receive the reply and convert its body of the given
|
||||
* target class.
|
||||
*
|
||||
* @param destination the target destination
|
||||
* @param request payload for the request message to send
|
||||
* @param targetClass the target type to convert the payload of the reply to
|
||||
* @param requestPostProcessor post process to apply to the request message
|
||||
* @return the payload of the reply message, possibly {@code null} if the message
|
||||
* could not be received, for example due to a timeout
|
||||
* could not be received, for example due to a timeout
|
||||
*/
|
||||
<T> T convertSendAndReceive(D destination, Object request, Class<T> targetClass,
|
||||
MessagePostProcessor requestPostProcessor) throws MessagingException;
|
||||
|
||||
/**
|
||||
* Convert the given request Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message with the given headers, apply the given post processor
|
||||
* and send the resulting {@link Message} to the specified destination, receive
|
||||
* the reply and convert its body of the given target class.
|
||||
*
|
||||
* @param destination the target destination
|
||||
* @param request payload for the request message to send
|
||||
* @param targetClass the target type to convert the payload of the reply to
|
||||
* @param requestPostProcessor post process to apply to the request message
|
||||
* @return the payload of the reply message, possibly {@code null} if the message
|
||||
* could not be received, for example due to a timeout
|
||||
* could not be received, for example due to a timeout
|
||||
*/
|
||||
<T> T convertSendAndReceive(D destination, Object request, Map<String, Object> headers,
|
||||
Class<T> targetClass, MessagePostProcessor requestPostProcessor) throws MessagingException;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.core;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -33,14 +34,12 @@ public interface MessageSendingOperations<D> {
|
|||
|
||||
/**
|
||||
* Send a message to a default destination.
|
||||
*
|
||||
* @param message the message to send
|
||||
*/
|
||||
void send(Message<?> message) throws MessagingException;
|
||||
|
||||
/**
|
||||
* Send a message to the given destination.
|
||||
*
|
||||
* @param destination the target destination
|
||||
* @param message the message to send
|
||||
*/
|
||||
|
@ -48,18 +47,16 @@ public interface MessageSendingOperations<D> {
|
|||
|
||||
/**
|
||||
* Convert the given Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message and send it to a default destination.
|
||||
*
|
||||
* @param payload the Object to use as payload
|
||||
*/
|
||||
void convertAndSend(Object payload) throws MessagingException;
|
||||
|
||||
/**
|
||||
* Convert the given Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message and send it to the given destination.
|
||||
*
|
||||
* @param destination the target destination
|
||||
* @param payload the Object to use as payload
|
||||
*/
|
||||
|
@ -67,10 +64,9 @@ public interface MessageSendingOperations<D> {
|
|||
|
||||
/**
|
||||
* Convert the given Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message with the given headers and send it to
|
||||
* a default destination.
|
||||
*
|
||||
* @param destination the target destination
|
||||
* @param payload the Object to use as payload
|
||||
* @param headers headers for the message to send
|
||||
|
@ -79,10 +75,9 @@ public interface MessageSendingOperations<D> {
|
|||
|
||||
/**
|
||||
* Convert the given Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message, apply the given post processor, and send
|
||||
* the resulting message to a default destination.
|
||||
*
|
||||
* @param payload the Object to use as payload
|
||||
* @param postProcessor the post processor to apply to the message
|
||||
*/
|
||||
|
@ -90,10 +85,9 @@ public interface MessageSendingOperations<D> {
|
|||
|
||||
/**
|
||||
* Convert the given Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message, apply the given post processor, and send
|
||||
* the resulting message to the given destination.
|
||||
*
|
||||
* @param destination the target destination
|
||||
* @param payload the Object to use as payload
|
||||
* @param postProcessor the post processor to apply to the message
|
||||
|
@ -102,10 +96,9 @@ public interface MessageSendingOperations<D> {
|
|||
|
||||
/**
|
||||
* Convert the given Object to serialized form, possibly using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter},
|
||||
* {@link org.springframework.messaging.converter.MessageConverter},
|
||||
* wrap it as a message with the given headers, apply the given post processor,
|
||||
* and send the resulting message to the given destination.
|
||||
*
|
||||
* @param destination the target destination
|
||||
* @param payload the Object to use as payload
|
||||
* @param headers headers for the message to send
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.handler.condition;
|
||||
package org.springframework.messaging.handler;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
@ -30,18 +30,18 @@ public abstract class AbstractMessageCondition<T extends AbstractMessageConditio
|
|||
|
||||
/**
|
||||
* @return the collection of objects the message condition is composed of
|
||||
* (e.g. destination patterns), never {@code null}
|
||||
* .g. destination patterns), never {@code null}
|
||||
*/
|
||||
protected abstract Collection<?> getContent();
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (o != null && getClass().equals(o.getClass())) {
|
||||
AbstractMessageCondition<?> other = (AbstractMessageCondition<?>) o;
|
||||
if (obj != null && getClass().equals(obj.getClass())) {
|
||||
AbstractMessageCondition<?> other = (AbstractMessageCondition<?>) obj;
|
||||
return getContent().equals(other.getContent());
|
||||
}
|
||||
return false;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.handler.condition;
|
||||
package org.springframework.messaging.handler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -27,7 +27,6 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.handler.method.AbstractMethodMessageHandler;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.PathMatcher;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
@ -42,6 +41,9 @@ import org.springframework.util.StringUtils;
|
|||
public final class DestinationPatternsMessageCondition
|
||||
extends AbstractMessageCondition<DestinationPatternsMessageCondition> {
|
||||
|
||||
public static final String LOOKUP_DESTINATION_HEADER = "lookupDestination";
|
||||
|
||||
|
||||
private final Set<String> patterns;
|
||||
|
||||
private final PathMatcher pathMatcher;
|
||||
|
@ -146,8 +148,7 @@ public final class DestinationPatternsMessageCondition
|
|||
*/
|
||||
@Override
|
||||
public DestinationPatternsMessageCondition getMatchingCondition(Message<?> message) {
|
||||
|
||||
String destination = (String) message.getHeaders().get(AbstractMethodMessageHandler.LOOKUP_DESTINATION_HEADER);
|
||||
String destination = (String) message.getHeaders().get(LOOKUP_DESTINATION_HEADER);
|
||||
if (destination == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -184,8 +185,7 @@ public final class DestinationPatternsMessageCondition
|
|||
*/
|
||||
@Override
|
||||
public int compareTo(DestinationPatternsMessageCondition other, Message<?> message) {
|
||||
|
||||
String destination = (String) message.getHeaders().get(AbstractMethodMessageHandler.LOOKUP_DESTINATION_HEADER);
|
||||
String destination = (String) message.getHeaders().get(LOOKUP_DESTINATION_HEADER);
|
||||
Comparator<String> patternComparator = this.pathMatcher.getPatternComparator(destination);
|
||||
|
||||
Iterator<String> iterator = patterns.iterator();
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.handler.method;
|
||||
package org.springframework.messaging.handler;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.handler.method;
|
||||
package org.springframework.messaging.handler;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.handler.condition;
|
||||
package org.springframework.messaging.handler;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
|
|
@ -39,7 +39,7 @@ import org.springframework.messaging.Message;
|
|||
* <li>{@link Message} to get access to the complete message being processed.</li>
|
||||
* <li>{@link Payload}-annotated method arguments to extract the payload of
|
||||
* a message and optionally convert it using a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter}.
|
||||
* {@link org.springframework.messaging.converter.MessageConverter}.
|
||||
* The presence of the annotation is not required since it is assumed by default
|
||||
* for method arguments that are not annotated.</li>
|
||||
* <li>{@link Header}-annotated method arguments to extract a specific
|
||||
|
@ -72,12 +72,12 @@ import org.springframework.messaging.Message;
|
|||
* to use {@link org.springframework.messaging.simp.annotation.SendToUser} to
|
||||
* have the message directed to a specific user only if connected.
|
||||
* Also the return value is converted with a
|
||||
* {@link org.springframework.messaging.support.converter.MessageConverter}.
|
||||
* {@link org.springframework.messaging.converter.MessageConverter}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
*
|
||||
* @see org.springframework.messaging.simp.handler.SimpAnnotationMethodMessageHandler
|
||||
* @see org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler
|
||||
*/
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.lang.annotation.Target;
|
|||
* @author Brian Clozel
|
||||
* @since 4.0
|
||||
* @see org.springframework.messaging.handler.annotation.MessageMapping
|
||||
* @see org.springframework.messaging.simp.handler.SimpAnnotationMethodMessageHandler
|
||||
* @see org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler
|
||||
*/
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.messaging.support.converter.MessageConverter;
|
||||
import org.springframework.messaging.converter.MessageConverter;
|
||||
|
||||
/**
|
||||
* Annotation that binds a method parameter to the payload of a message. The payload may
|
||||
|
|
|
@ -27,10 +27,8 @@ public interface ValueConstants {
|
|||
/**
|
||||
* Constant defining a value for no default - as a replacement for {@code null} which
|
||||
* we cannot use in annotation attributes.
|
||||
* <p>
|
||||
* This is an artificial arrangement of 16 unicode characters, with its sole purpose
|
||||
* <p>This is an artificial arrangement of 16 unicode characters, with its sole purpose
|
||||
* being to never match user-declared values.
|
||||
*
|
||||
* @see Header#defaultValue()
|
||||
*/
|
||||
String DEFAULT_NONE = "\n\t\t\n\t\t\n\uE000\uE001\uE002\n\t\t\t\t\n";
|
||||
|
|
|
@ -29,7 +29,7 @@ import org.springframework.core.convert.TypeDescriptor;
|
|||
import org.springframework.core.convert.support.DefaultConversionService;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.handler.annotation.ValueConstants;
|
||||
import org.springframework.messaging.handler.method.HandlerMethodArgumentResolver;
|
||||
import org.springframework.messaging.handler.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@ import java.util.Map;
|
|||
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.messaging.handler.annotation.MessageExceptionHandler;
|
||||
import org.springframework.messaging.handler.method.AbstractExceptionHandlerMethodResolver;
|
||||
import org.springframework.messaging.handler.method.HandlerMethodSelector;
|
||||
import org.springframework.messaging.handler.support.AbstractExceptionHandlerMethodResolver;
|
||||
import org.springframework.messaging.handler.HandlerMethodSelector;
|
||||
import org.springframework.util.ReflectionUtils.MethodFilter;
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.springframework.messaging.Message;
|
|||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.handler.annotation.Header;
|
||||
import org.springframework.messaging.handler.annotation.Headers;
|
||||
import org.springframework.messaging.handler.method.HandlerMethodArgumentResolver;
|
||||
import org.springframework.messaging.handler.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.messaging.support.MessageHeaderAccessor;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.springframework.messaging.handler.annotation.support;
|
|||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.handler.method.HandlerMethodArgumentResolver;
|
||||
import org.springframework.messaging.handler.support.HandlerMethodArgumentResolver;
|
||||
|
||||
/**
|
||||
* A {@link HandlerMethodArgumentResolver} for {@link Message} parameters.
|
||||
|
|
|
@ -19,8 +19,8 @@ package org.springframework.messaging.handler.annotation.support;
|
|||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.handler.annotation.Payload;
|
||||
import org.springframework.messaging.handler.method.HandlerMethodArgumentResolver;
|
||||
import org.springframework.messaging.support.converter.MessageConverter;
|
||||
import org.springframework.messaging.handler.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.messaging.converter.MessageConverter;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* Basic abstractions for working with message handlers.
|
||||
*/
|
||||
package org.springframework.messaging.handler;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.handler.method;
|
||||
package org.springframework.messaging.handler.support;
|
||||
|
||||
import org.springframework.core.ExceptionDepthComparator;
|
||||
import org.springframework.util.Assert;
|
|
@ -14,10 +14,22 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.handler.method;
|
||||
package org.springframework.messaging.handler.support;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
@ -26,23 +38,27 @@ import org.springframework.core.MethodParameter;
|
|||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.handler.DestinationPatternsMessageCondition;
|
||||
import org.springframework.messaging.handler.HandlerMethod;
|
||||
import org.springframework.messaging.handler.HandlerMethodSelector;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.util.*;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Abstract base class for HandlerMethod-based message handling. Provides most of
|
||||
* the logic required to discover handler methods at startup, find a matching handler
|
||||
* method at runtime for a given message and invoke it.
|
||||
* <p>
|
||||
* Also supports discovering and invoking exception handling methods to process
|
||||
*
|
||||
* <p>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
|
||||
* {@link org.springframework.messaging.handler.HandlerMethod} to incoming messages
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
|
@ -52,15 +68,14 @@ public abstract class AbstractMethodMessageHandler<T>
|
|||
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
public static final String LOOKUP_DESTINATION_HEADER = "lookupDestination";
|
||||
|
||||
|
||||
private Collection<String> destinationPrefixes = new ArrayList<String>();
|
||||
|
||||
private List<HandlerMethodArgumentResolver> customArgumentResolvers = new ArrayList<HandlerMethodArgumentResolver>();
|
||||
|
||||
private List<HandlerMethodReturnValueHandler> customReturnValueHandlers = new ArrayList<HandlerMethodReturnValueHandler>();
|
||||
|
||||
private HandlerMethodArgumentResolverComposite argumentResolvers = new HandlerMethodArgumentResolverComposite();
|
||||
|
||||
private HandlerMethodReturnValueHandlerComposite returnValueHandlers =new HandlerMethodReturnValueHandlerComposite();
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
@ -306,7 +321,6 @@ public abstract class AbstractMethodMessageHandler<T>
|
|||
|
||||
@Override
|
||||
public void handleMessage(Message<?> message) throws MessagingException {
|
||||
|
||||
String destination = getDestination(message);
|
||||
if (destination == null) {
|
||||
logger.trace("Ignoring message, no destination");
|
||||
|
@ -325,7 +339,8 @@ public abstract class AbstractMethodMessageHandler<T>
|
|||
logger.debug("Handling message, lookupDestination=" + lookupDestination);
|
||||
}
|
||||
|
||||
message = MessageBuilder.fromMessage(message).setHeader(LOOKUP_DESTINATION_HEADER, lookupDestination).build();
|
||||
message = MessageBuilder.fromMessage(message).setHeader(
|
||||
DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, lookupDestination).build();
|
||||
|
||||
handleMessageInternal(message, lookupDestination);
|
||||
}
|
||||
|
@ -337,7 +352,7 @@ public abstract class AbstractMethodMessageHandler<T>
|
|||
* 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.
|
||||
* @return the destination to use to find matching message handling methods
|
||||
* or {@code null} if the destination does not match
|
||||
* or {@code null} if the destination does not match
|
||||
*/
|
||||
protected String getLookupDestination(String destination) {
|
||||
if (destination == null) {
|
||||
|
@ -355,7 +370,6 @@ public abstract class AbstractMethodMessageHandler<T>
|
|||
}
|
||||
|
||||
protected void handleMessageInternal(Message<?> message, String lookupDestination) {
|
||||
|
||||
List<Match> matches = new ArrayList<Match>();
|
||||
|
||||
List<T> mappingsByUrl = this.destinationLookup.get(lookupDestination);
|
||||
|
@ -378,8 +392,7 @@ public abstract class AbstractMethodMessageHandler<T>
|
|||
Collections.sort(matches, comparator);
|
||||
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Found " + matches.size() + " matching mapping(s) for ["
|
||||
+ lookupDestination + "] : " + matches);
|
||||
logger.trace("Found " + matches.size() + " matching mapping(s) for [" + lookupDestination + "] : " + matches);
|
||||
}
|
||||
|
||||
Match bestMatch = matches.get(0);
|
||||
|
@ -388,9 +401,8 @@ public abstract class AbstractMethodMessageHandler<T>
|
|||
if (comparator.compare(bestMatch, secondBestMatch) == 0) {
|
||||
Method m1 = bestMatch.handlerMethod.getMethod();
|
||||
Method m2 = secondBestMatch.handlerMethod.getMethod();
|
||||
throw new IllegalStateException(
|
||||
"Ambiguous handler methods mapped for destination '"
|
||||
+ lookupDestination + "': {" + m1 + ", " + m2 + "}");
|
||||
throw new IllegalStateException("Ambiguous handler methods mapped for destination '" +
|
||||
lookupDestination + "': {" + m1 + ", " + m2 + "}");
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.handler.method;
|
||||
package org.springframework.messaging.handler.support;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.messaging.Message;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.handler.method;
|
||||
package org.springframework.messaging.handler.support;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.handler.method;
|
||||
package org.springframework.messaging.handler.support;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.messaging.Message;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.handler.method;
|
||||
package org.springframework.messaging.handler.support;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.handler.method;
|
||||
package org.springframework.messaging.handler.support;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
@ -25,13 +25,14 @@ import org.springframework.core.GenericTypeResolver;
|
|||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.ParameterNameDiscoverer;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.handler.HandlerMethod;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
* Invokes the handler method for a given message after resolving
|
||||
* its method argument values through registered {@link HandlerMethodArgumentResolver}s.
|
||||
* <p>
|
||||
* Use {@link #setMessageMethodArgumentResolvers(HandlerMethodArgumentResolverComposite)}
|
||||
*
|
||||
* <p>Use {@link #setMessageMethodArgumentResolvers(HandlerMethodArgumentResolverComposite)}
|
||||
* to customize the list of argument resolvers.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
* Abstractions and classes for working with message-handling methods.
|
||||
*/
|
||||
package org.springframework.messaging.handler.method;
|
||||
package org.springframework.messaging.handler.support;
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.simp;
|
||||
|
||||
import java.util.Map;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* Annotations and support classes for handling messages from simple messaging
|
||||
* protocols (like STOMP).
|
||||
* Annotations and for handling messages from simple messaging protocols
|
||||
* (like STOMP).
|
||||
*/
|
||||
package org.springframework.messaging.simp.annotation;
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.security.Principal;
|
|||
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.handler.method.HandlerMethodArgumentResolver;
|
||||
import org.springframework.messaging.handler.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.springframework.messaging.Message;
|
|||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.core.MessagePostProcessor;
|
||||
import org.springframework.messaging.handler.annotation.SendTo;
|
||||
import org.springframework.messaging.handler.method.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.messaging.handler.support.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
|
||||
import org.springframework.messaging.simp.SimpMessageSendingOperations;
|
||||
import org.springframework.messaging.simp.annotation.SendToUser;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.simp.handler;
|
||||
package org.springframework.messaging.simp.annotation.support;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
|
@ -34,7 +34,12 @@ import org.springframework.format.support.DefaultFormattingConversionService;
|
|||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.messaging.converter.ByteArrayMessageConverter;
|
||||
import org.springframework.messaging.converter.CompositeMessageConverter;
|
||||
import org.springframework.messaging.converter.MessageConverter;
|
||||
import org.springframework.messaging.converter.StringMessageConverter;
|
||||
import org.springframework.messaging.core.AbstractMessageSendingTemplate;
|
||||
import org.springframework.messaging.handler.HandlerMethod;
|
||||
import org.springframework.messaging.handler.annotation.MessageMapping;
|
||||
import org.springframework.messaging.handler.annotation.support.AnnotationExceptionHandlerMethodResolver;
|
||||
import org.springframework.messaging.handler.annotation.support.HeaderMethodArgumentResolver;
|
||||
|
@ -42,25 +47,18 @@ import org.springframework.messaging.handler.annotation.support.HeadersMethodArg
|
|||
import org.springframework.messaging.handler.annotation.support.MessageMethodArgumentResolver;
|
||||
import org.springframework.messaging.handler.annotation.support.PathVariableMethodArgumentResolver;
|
||||
import org.springframework.messaging.handler.annotation.support.PayloadArgumentResolver;
|
||||
import org.springframework.messaging.handler.condition.DestinationPatternsMessageCondition;
|
||||
import org.springframework.messaging.handler.method.AbstractExceptionHandlerMethodResolver;
|
||||
import org.springframework.messaging.handler.method.AbstractMethodMessageHandler;
|
||||
import org.springframework.messaging.handler.method.HandlerMethod;
|
||||
import org.springframework.messaging.handler.method.HandlerMethodArgumentResolver;
|
||||
import org.springframework.messaging.handler.method.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.messaging.handler.support.AbstractExceptionHandlerMethodResolver;
|
||||
import org.springframework.messaging.handler.support.AbstractMethodMessageHandler;
|
||||
import org.springframework.messaging.handler.DestinationPatternsMessageCondition;
|
||||
import org.springframework.messaging.handler.support.HandlerMethodArgumentResolver;
|
||||
import org.springframework.messaging.handler.support.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
|
||||
import org.springframework.messaging.simp.SimpMessageSendingOperations;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.messaging.simp.annotation.SubscribeMapping;
|
||||
import org.springframework.messaging.simp.annotation.support.PrincipalMethodArgumentResolver;
|
||||
import org.springframework.messaging.simp.annotation.support.SendToMethodReturnValueHandler;
|
||||
import org.springframework.messaging.simp.annotation.support.SubscriptionMethodReturnValueHandler;
|
||||
import org.springframework.messaging.simp.handler.SimpMessageMappingInfo;
|
||||
import org.springframework.messaging.simp.handler.SimpMessageTypeMessageCondition;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.messaging.support.channel.AbstractSubscribableChannel;
|
||||
import org.springframework.messaging.support.converter.ByteArrayMessageConverter;
|
||||
import org.springframework.messaging.support.converter.CompositeMessageConverter;
|
||||
import org.springframework.messaging.support.converter.MessageConverter;
|
||||
import org.springframework.messaging.support.converter.StringMessageConverter;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.Assert;
|
||||
|
@ -92,7 +90,7 @@ public class SimpAnnotationMethodMessageHandler extends AbstractMethodMessageHan
|
|||
|
||||
private PathMatcher pathMatcher = new AntPathMatcher();
|
||||
|
||||
private Object lifecycleMonitor = new Object();
|
||||
private final Object lifecycleMonitor = new Object();
|
||||
|
||||
private volatile boolean running = false;
|
||||
|
|
@ -21,7 +21,7 @@ import org.springframework.messaging.Message;
|
|||
import org.springframework.messaging.core.MessagePostProcessor;
|
||||
import org.springframework.messaging.core.MessageSendingOperations;
|
||||
import org.springframework.messaging.handler.annotation.SendTo;
|
||||
import org.springframework.messaging.handler.method.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.messaging.handler.support.HandlerMethodReturnValueHandler;
|
||||
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
|
||||
import org.springframework.messaging.simp.SimpMessageType;
|
||||
import org.springframework.messaging.simp.annotation.SendToUser;
|
||||
|
@ -33,8 +33,8 @@ 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
|
||||
* with {@link SendTo} or {@link SendToUser}.
|
||||
* <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
|
||||
* then enriched with the sessionId, subscriptionId, and destination of the input message.
|
||||
* The message is then sent directly back to the connected client.
|
||||
*
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
/**
|
||||
* Support classes for handling messages from simple messaging protocols
|
||||
* (like STOMP).
|
||||
*/
|
||||
package org.springframework.messaging.simp.annotation.support;
|
|
@ -16,20 +16,32 @@
|
|||
|
||||
package org.springframework.messaging.simp.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.converter.ByteArrayMessageConverter;
|
||||
import org.springframework.messaging.converter.CompositeMessageConverter;
|
||||
import org.springframework.messaging.converter.DefaultContentTypeResolver;
|
||||
import org.springframework.messaging.converter.MappingJackson2MessageConverter;
|
||||
import org.springframework.messaging.converter.MessageConverter;
|
||||
import org.springframework.messaging.converter.StringMessageConverter;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.messaging.simp.handler.*;
|
||||
import org.springframework.messaging.support.channel.AbstractSubscribableChannel;
|
||||
import org.springframework.messaging.support.channel.ExecutorSubscribableChannel;
|
||||
import org.springframework.messaging.support.converter.*;
|
||||
import org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler;
|
||||
import org.springframework.messaging.simp.handler.AbstractBrokerMessageHandler;
|
||||
import org.springframework.messaging.simp.handler.DefaultUserDestinationResolver;
|
||||
import org.springframework.messaging.simp.handler.DefaultUserSessionRegistry;
|
||||
import org.springframework.messaging.simp.handler.SimpleBrokerMessageHandler;
|
||||
import org.springframework.messaging.simp.handler.UserDestinationMessageHandler;
|
||||
import org.springframework.messaging.simp.handler.UserDestinationResolver;
|
||||
import org.springframework.messaging.simp.handler.UserSessionRegistry;
|
||||
import org.springframework.messaging.support.AbstractSubscribableChannel;
|
||||
import org.springframework.messaging.support.ExecutorSubscribableChannel;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.util.ClassUtils;
|
||||
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.
|
||||
|
|
|
@ -16,12 +16,12 @@
|
|||
|
||||
package org.springframework.messaging.simp.config;
|
||||
|
||||
import org.springframework.messaging.support.channel.ChannelInterceptor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
|
||||
/**
|
||||
* A registration class for customizing the configuration for a
|
||||
* {@link org.springframework.messaging.MessageChannel}.
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
|
|
|
@ -17,14 +17,14 @@
|
|||
package org.springframework.messaging.simp.handler;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.handler.condition.DestinationPatternsMessageCondition;
|
||||
import org.springframework.messaging.handler.condition.MessageCondition;
|
||||
import org.springframework.messaging.handler.DestinationPatternsMessageCondition;
|
||||
import org.springframework.messaging.handler.MessageCondition;
|
||||
|
||||
/**
|
||||
* Encapsulates the following request mapping conditions:
|
||||
* <ol>
|
||||
* <li>{@link SimpMessageTypeMessageCondition}
|
||||
* <li>{@link DestinationPatternsMessageCondition}
|
||||
* <li>{@link SimpMessageTypeMessageCondition}
|
||||
* <li>{@link DestinationPatternsMessageCondition}
|
||||
* </ol>
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.springframework.messaging.simp.handler;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.handler.condition.AbstractMessageCondition;
|
||||
import org.springframework.messaging.handler.AbstractMessageCondition;
|
||||
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
|
||||
import org.springframework.messaging.simp.SimpMessageType;
|
||||
import org.springframework.util.Assert;
|
||||
|
|
|
@ -20,8 +20,13 @@ import java.util.Set;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.messaging.*;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.messaging.core.MessageSendingOperations;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import org.springframework.util.Assert;
|
||||
|
|
|
@ -21,23 +21,26 @@ import java.util.Map;
|
|||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.springframework.messaging.*;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
|
||||
import org.springframework.messaging.simp.SimpMessageType;
|
||||
import org.springframework.messaging.simp.handler.AbstractBrokerMessageHandler;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
import org.springframework.messaging.support.tcp.FixedIntervalReconnectStrategy;
|
||||
import org.springframework.messaging.support.tcp.ReactorNettyTcpClient;
|
||||
import org.springframework.messaging.support.tcp.TcpConnection;
|
||||
import org.springframework.messaging.support.tcp.TcpConnectionHandler;
|
||||
import org.springframework.messaging.support.tcp.TcpOperations;
|
||||
import org.springframework.messaging.tcp.FixedIntervalReconnectStrategy;
|
||||
import org.springframework.messaging.tcp.TcpConnection;
|
||||
import org.springframework.messaging.tcp.TcpConnectionHandler;
|
||||
import org.springframework.messaging.tcp.TcpOperations;
|
||||
import org.springframework.messaging.tcp.reactor.ReactorNettyTcpClient;
|
||||
import org.springframework.util.Assert;
|
||||
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.
|
||||
* A {@link org.springframework.messaging.MessageHandler} that handles messages by forwarding them to a STOMP broker.
|
||||
* For each new {@link SimpMessageType#CONNECT CONNECT} message, an independent TCP
|
||||
* connection to the broker is opened and used exclusively for all messages from the
|
||||
* client that originated the CONNECT message. Messages from the same client are
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.nio.charset.Charset;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.simp.SimpMessageType;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
|
|
|
@ -14,12 +14,13 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.channel;
|
||||
package org.springframework.messaging.support;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
@ -36,12 +37,12 @@ import org.springframework.util.ObjectUtils;
|
|||
*/
|
||||
public abstract class AbstractMessageChannel implements MessageChannel, BeanNameAware {
|
||||
|
||||
protected Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private String beanName;
|
||||
protected final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private final ChannelInterceptorChain interceptorChain = new ChannelInterceptorChain();
|
||||
|
||||
private String beanName;
|
||||
|
||||
|
||||
public AbstractMessageChannel() {
|
||||
this.beanName = getClass().getSimpleName() + "@" + ObjectUtils.getIdentityHexString(this);
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.channel;
|
||||
package org.springframework.messaging.support;
|
||||
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
|
@ -27,7 +27,6 @@ import org.springframework.messaging.SubscribableChannel;
|
|||
*/
|
||||
public abstract class AbstractSubscribableChannel extends AbstractMessageChannel implements SubscribableChannel {
|
||||
|
||||
|
||||
@Override
|
||||
public final boolean subscribe(MessageHandler handler) {
|
||||
if (hasSubscription(handler)) {
|
||||
|
@ -40,6 +39,15 @@ public abstract class AbstractSubscribableChannel extends AbstractMessageChannel
|
|||
return subscribeInternal(handler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean unsubscribe(MessageHandler handler) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("[" + getBeanName() + "] unsubscribing " + handler);
|
||||
}
|
||||
return unsubscribeInternal(handler);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Whether the given {@link MessageHandler} is already subscribed.
|
||||
*/
|
||||
|
@ -50,14 +58,6 @@ public abstract class AbstractSubscribableChannel extends AbstractMessageChannel
|
|||
*/
|
||||
protected abstract boolean subscribeInternal(MessageHandler handler);
|
||||
|
||||
@Override
|
||||
public final boolean unsubscribe(MessageHandler handler) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("[" + getBeanName() + "] unsubscribing " + handler);
|
||||
}
|
||||
return unsubscribeInternal(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe the given {@link MessageHandler}.
|
||||
*/
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.channel;
|
||||
package org.springframework.messaging.support;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
|
@ -14,19 +14,19 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.channel;
|
||||
package org.springframework.messaging.support;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
* A {@link ChannelInterceptor} with empty method implementations as a convenience.
|
||||
* A {@link ChannelInterceptor} base class with empty method implementations
|
||||
* as a convenience.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @since 4.0
|
||||
*/
|
||||
public class ChannelInterceptorAdapter implements ChannelInterceptor {
|
||||
|
||||
public abstract class ChannelInterceptorAdapter implements ChannelInterceptor {
|
||||
|
||||
public Message<?> preSend(Message<?> message, MessageChannel channel) {
|
||||
return message;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.channel;
|
||||
package org.springframework.messaging.support;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.channel;
|
||||
package org.springframework.messaging.support;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
|
@ -1,5 +0,0 @@
|
|||
/**
|
||||
* Provides {@link org.springframework.messaging.MessageChannel} implementations
|
||||
* classes as well as channel interceptor support.
|
||||
*/
|
||||
package org.springframework.messaging.support.channel;
|
|
@ -1,4 +0,0 @@
|
|||
/**
|
||||
* Provides support for message conversion.
|
||||
*/
|
||||
package org.springframework.messaging.support.converter;
|
|
@ -1,6 +1,7 @@
|
|||
/**
|
||||
* Provides implementations of {@link org.springframework.messaging.Message} along with
|
||||
* a MessageBuilder and MessageHeaderAccessor for building and working with messages
|
||||
* and message headers.
|
||||
* a MessageBuilder and MessageHeaderAccessor for building and working with messages and
|
||||
* message headers, as well as various {@link org.springframework.messaging.MessageChannel}
|
||||
* implementations and channel interceptor support.
|
||||
*/
|
||||
package org.springframework.messaging.support;
|
|
@ -1,9 +0,0 @@
|
|||
/**
|
||||
* Contains abstractions and implementation classes for establishing TCP connections via
|
||||
* {@link org.springframework.messaging.support.tcp.TcpOperations TcpOperations},
|
||||
* handling messages via
|
||||
* {@link org.springframework.messaging.support.tcp.TcpConnectionHandler TcpConnectionHandler},
|
||||
* as well as sending messages via
|
||||
* {@link org.springframework.messaging.support.tcp.TcpConnection TcpConnection}.
|
||||
*/
|
||||
package org.springframework.messaging.support.tcp;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.tcp;
|
||||
package org.springframework.messaging.tcp;
|
||||
|
||||
/**
|
||||
* A simple strategy for making reconnect attempts at a fixed interval.
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.tcp;
|
||||
package org.springframework.messaging.tcp;
|
||||
|
||||
|
||||
/**
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.tcp;
|
||||
package org.springframework.messaging.tcp;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.tcp;
|
||||
package org.springframework.messaging.tcp;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.tcp;
|
||||
package org.springframework.messaging.tcp;
|
||||
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* Contains abstractions and implementation classes for establishing TCP connections via
|
||||
* {@link org.springframework.messaging.tcp.TcpOperations TcpOperations},
|
||||
* handling messages via
|
||||
* {@link org.springframework.messaging.tcp.TcpConnectionHandler TcpConnectionHandler},
|
||||
* as well as sending messages via
|
||||
* {@link org.springframework.messaging.tcp.TcpConnection TcpConnection}.
|
||||
*/
|
||||
package org.springframework.messaging.tcp;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.tcp;
|
||||
package org.springframework.messaging.tcp.reactor;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.tcp;
|
||||
package org.springframework.messaging.tcp.reactor;
|
||||
|
||||
import reactor.core.composable.Promise;
|
||||
|
|
@ -14,13 +14,16 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.tcp;
|
||||
package org.springframework.messaging.tcp.reactor;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.tcp.ReconnectStrategy;
|
||||
import org.springframework.messaging.tcp.TcpConnectionHandler;
|
||||
import org.springframework.messaging.tcp.TcpOperations;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
|
||||
|
@ -43,7 +46,7 @@ import reactor.tuple.Tuple;
|
|||
import reactor.tuple.Tuple2;
|
||||
|
||||
/**
|
||||
* A Reactor/Netty implementation of {@link TcpOperations}.
|
||||
* A Reactor/Netty implementation of {@link org.springframework.messaging.tcp.TcpOperations}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
|
@ -14,9 +14,10 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.tcp;
|
||||
package org.springframework.messaging.tcp.reactor;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.tcp.TcpConnection;
|
||||
import org.springframework.util.concurrent.ListenableFuture;
|
||||
|
||||
import reactor.core.composable.Promise;
|
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* Contains support for TCP messaging based on Reactor.
|
||||
*/
|
||||
package org.springframework.messaging.tcp.reactor;
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.converter;
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -32,7 +32,7 @@ import org.springframework.util.MimeTypeUtils;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test fixture for {@link AbstractMessageConverter}.
|
||||
* Test fixture for {@link org.springframework.messaging.converter.AbstractMessageConverter}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.converter;
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -23,12 +23,13 @@ import java.util.Map;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.converter.DefaultContentTypeResolver;
|
||||
import org.springframework.util.MimeTypeUtils;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test fixture for {@link DefaultContentTypeResolver}.
|
||||
* Test fixture for {@link org.springframework.messaging.converter.DefaultContentTypeResolver}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.converter;
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
|
@ -32,7 +32,7 @@ import org.springframework.util.MimeType;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test fixture for {@link MappingJackson2MessageConverter}.
|
||||
* Test fixture for {@link org.springframework.messaging.converter.MappingJackson2MessageConverter}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.support.converter;
|
||||
package org.springframework.messaging.converter;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
|
@ -31,7 +31,7 @@ import org.springframework.util.MimeTypeUtils;
|
|||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Test fixture for {@link StringMessageConverter}.
|
||||
* Test fixture for {@link org.springframework.messaging.converter.StringMessageConverter}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
|
@ -16,20 +16,19 @@
|
|||
|
||||
package org.springframework.messaging.core;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.messaging.support.channel.ExecutorSubscribableChannel;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.support.ExecutorSubscribableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link AbstractDestinationResolvingMessagingTemplate}.
|
||||
|
|
|
@ -16,16 +16,22 @@
|
|||
|
||||
package org.springframework.messaging.core;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.messaging.*;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.messaging.support.channel.ExecutorSubscribableChannel;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.messaging.support.ExecutorSubscribableChannel;
|
||||
import org.springframework.messaging.support.GenericMessage;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import static junit.framework.Assert.assertNull;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -45,9 +51,7 @@ public class GenericMessagingTemplateTests {
|
|||
|
||||
@Before
|
||||
public void setup() {
|
||||
|
||||
this.template = new GenericMessagingTemplate();
|
||||
|
||||
this.executor = new ThreadPoolTaskExecutor();
|
||||
this.executor.afterPropertiesSet();
|
||||
}
|
||||
|
@ -55,7 +59,6 @@ public class GenericMessagingTemplateTests {
|
|||
|
||||
@Test
|
||||
public void sendAndReceive() {
|
||||
|
||||
SubscribableChannel channel = new ExecutorSubscribableChannel(this.executor);
|
||||
channel.subscribe(new MessageHandler() {
|
||||
@Override
|
||||
|
@ -72,7 +75,6 @@ public class GenericMessagingTemplateTests {
|
|||
|
||||
@Test
|
||||
public void sendAndReceiveTimeout() throws InterruptedException {
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
this.template.setReceiveTimeout(1);
|
||||
|
|
|
@ -14,23 +14,22 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.messaging.handler.condition;
|
||||
package org.springframework.messaging.handler;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.handler.method.AbstractMethodMessageHandler;
|
||||
import org.springframework.messaging.support.MessageBuilder;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Unit tests for DestinationPatternsMessageCondition.
|
||||
* Unit tests for {@link DestinationPatternsMessageCondition}.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
*/
|
||||
public class DestinationPatternsMessageConditionTests {
|
||||
|
||||
|
||||
@Test
|
||||
public void prependSlash() {
|
||||
DestinationPatternsMessageCondition c = condition("foo");
|
||||
|
@ -136,7 +135,7 @@ public class DestinationPatternsMessageConditionTests {
|
|||
|
||||
private Message<?> messageTo(String destination) {
|
||||
return MessageBuilder.withPayload(new byte[0]).setHeader(
|
||||
AbstractMethodMessageHandler.LOOKUP_DESTINATION_HEADER, destination).build();
|
||||
DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, destination).build();
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue