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