Build on top of Spring 4's new messaging types

This commit updates Spring Integration to depend upon Spring 4, making
use of the message types that have moved from Spring Integration into
Spring's new spring-messaging module.

The default message converter no longer supports conversion of a
message that is null, throwing an IllegalArgumentException if an
attempt is made to convert null. Furthermore, GenericMessagingTemplate
does not support sending null, again throwing an
IllegalArgumentException. Previously, MessagingTemplate had no-oped an
attempt to send null.

ConcurrentAggregatorTests and AggregatorTests both had a single test
that was specifically testing the behaviour of an aggregator that
returns null for its message. These tests have been removed.

CorrelatingMessageHandlerTests have been updated to specify some
additional behaviour for its mocks so that null messages are not
returned.

These are the only functional changes that have been made. All other
changes are simply for moving to the repackaged and/or renamed types.

In the move to being part of core Spring, a number of constants and
header accessor methods have moved from MessageHeaders to
MessageHeaderAccessor. This commit continues this pattern for
the enterprise integration headers that are specific to Spring
Integration. A new class, EiMessageHeaderAccessor, has been created.
This class provides constants and methods for working with SI-specific
headers. The main code and tests have been updated to use this new
class.
This commit is contained in:
Andy Wilkinson
2013-09-10 13:35:53 +01:00
committed by Gary Russell
parent 8dca61c62a
commit 28ab8394de
1156 changed files with 3332 additions and 5834 deletions

View File

@@ -0,0 +1,82 @@
package org.springframework.integration;
import java.util.Date;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageHeaderAccessor;
import org.springframework.util.Assert;
public class EiMessageHeaderAccessor extends MessageHeaderAccessor {
public static final String CORRELATION_ID = "correlationId";
public static final String EXPIRATION_DATE = "expirationDate";
public static final String PRIORITY = "priority";
public static final String SEQUENCE_NUMBER = "sequenceNumber";
public static final String SEQUENCE_SIZE = "sequenceSize";
public static final String SEQUENCE_DETAILS = "sequenceDetails";
public static final String POSTPROCESS_RESULT = "postProcessResult";
public EiMessageHeaderAccessor(Message<?> message) {
super(message);
}
public Long getExpirationDate() {
return this.getHeader(EXPIRATION_DATE, Long.class);
}
public Object getCorrelationId() {
return this.getHeader(CORRELATION_ID);
}
public Integer getSequenceNumber() {
Integer sequenceNumber = this.getHeader(SEQUENCE_NUMBER, Integer.class);
return (sequenceNumber != null ? sequenceNumber : 0);
}
public Integer getSequenceSize() {
Integer sequenceSize = this.getHeader(SEQUENCE_SIZE, Integer.class);
return (sequenceSize != null ? sequenceSize : 0);
}
public Integer getPriority() {
return this.getHeader(PRIORITY, Integer.class);
}
@SuppressWarnings("unchecked")
public <T> T getHeader(String key, Class<T> type) {
Object value = getHeader(key);
if (value == null) {
return null;
}
if (!type.isAssignableFrom(value.getClass())) {
throw new IllegalArgumentException("Incorrect type specified for header '" + key + "'. Expected [" + type
+ "] but actual type is [" + value.getClass() + "]");
}
return (T) value;
}
protected void verifyType(String headerName, Object headerValue) {
if (headerName != null && headerValue != null) {
super.verifyType(headerName, headerValue);
if (EiMessageHeaderAccessor.EXPIRATION_DATE.equals(headerName)) {
Assert.isTrue(headerValue instanceof Date || headerValue instanceof Long, "The '" + headerName
+ "' header value must be a Date or Long.");
}
else if (EiMessageHeaderAccessor.SEQUENCE_NUMBER.equals(headerName)
|| EiMessageHeaderAccessor.SEQUENCE_SIZE.equals(headerName)) {
Assert.isTrue(Integer.class.isAssignableFrom(headerValue.getClass()), "The '" + headerName
+ "' header value must be an Integer.");
}
else if (EiMessageHeaderAccessor.PRIORITY.equals(headerName)) {
Assert.isTrue(Integer.class.isAssignableFrom(headerValue.getClass()), "The '" + headerName
+ "' header value must be an Integer.");
}
}
}
}

View File

@@ -1,31 +0,0 @@
/*
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration;
/**
* The central interface that any Message type must implement.
*
* @author Mark Fisher
* @author Arjen Poutsma
*/
public interface Message<T> {
MessageHeaders getHeaders();
T getPayload();
}

View File

@@ -1,54 +0,0 @@
/*
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration;
/**
* Base channel interface defining common behavior for sending messages.
*
* @author Mark Fisher
*/
public interface MessageChannel {
/**
* Send a {@link Message} to this channel. May throw a RuntimeException for
* non-recoverable errors. Otherwise, if the Message cannot be sent for a
* non-fatal reason this method will return 'false', and if the Message is
* sent successfully, it will return 'true'.
*
* <p>Depending on the implementation, this method may block indefinitely.
* To provide a maximum wait time, use {@link #send(Message, long)}.
*
* @param message the {@link Message} to send
*
* @return whether or not the Message has been sent successfully
*/
boolean send(Message<?> message);
/**
* Send a message, blocking until either the message is accepted or the
* specified timeout period elapses.
*
* @param message the {@link Message} to send
* @param timeout the timeout in milliseconds
*
* @return <code>true</code> if the message is sent successfully,
* <code>false</code> if the specified timeout period elapses or
* the send is interrupted
*/
boolean send(Message<?> message, long timeout);
}

View File

@@ -1,43 +0,0 @@
/*
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration;
/**
* Exception that indicates an error occurred during message delivery.
*
* @author Mark Fisher
*/
@SuppressWarnings("serial")
public class MessageDeliveryException extends MessagingException {
public MessageDeliveryException(String description) {
super(description);
}
public MessageDeliveryException(Message<?> undeliveredMessage) {
super(undeliveredMessage);
}
public MessageDeliveryException(Message<?> undeliveredMessage, String description) {
super(undeliveredMessage, description);
}
public MessageDeliveryException(Message<?> undeliveredMessage, String description, Throwable cause) {
super(undeliveredMessage, description, cause);
}
}

View File

@@ -16,6 +16,8 @@
package org.springframework.integration;
import org.springframework.integration.dispatcher.MessageDispatcher;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageDeliveryException;
/**
* Exception that indicates an internal error occurred within

View File

@@ -16,9 +16,12 @@
package org.springframework.integration;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessagingException;
/**
* Exception that indicates an error occurred during message handling.
*
*
* @author Mark Fisher
*/
@SuppressWarnings("serial")

View File

@@ -1,305 +0,0 @@
/*
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.eaio.uuid.UUIDGen;
/**
* The headers for a {@link Message}.<br>
* IMPORTANT: MessageHeaders are immutable. Any mutating operation (e.g., put(..), putAll(..) etc.)
* will result in {@link UnsupportedOperationException}
* To create MessageHeaders instance use fluent MessageBuilder API
* <pre>
* MessageBuilder.withPayload("foo").setHeader("key1", "value1").setHeader("key2", "value2");
* </pre>
* or create an instance of GenericMessage passing payload as {@link Object} and headers as a regular {@link Map}
* <pre>
* Map headers = new HashMap();
* headers.put("key1", "value1");
* headers.put("key2", "value2");
* new GenericMessage("foo", headers);
* </pre>
*
* @author Arjen Poutsma
* @author Mark Fisher
* @author Oleg Zhurakousky
* @author Gary Russell
*/
public final class MessageHeaders implements Map<String, Object>, Serializable {
private static final long serialVersionUID = 6901029029524535147L;
private static final Log logger = LogFactory.getLog(MessageHeaders.class);
private static volatile IdGenerator idGenerator = null;
/**
* The key for the Message ID. This is an automatically generated UUID and
* should never be explicitly set in the header map <b>except</b> in the
* case of Message deserialization where the serialized Message's generated
* UUID is being restored.
*/
public static final String ID = "id";
public static final String TIMESTAMP = "timestamp";
public static final String CORRELATION_ID = "correlationId";
public static final String REPLY_CHANNEL = "replyChannel";
public static final String ERROR_CHANNEL = "errorChannel";
public static final String EXPIRATION_DATE = "expirationDate";
public static final String PRIORITY = "priority";
public static final String SEQUENCE_NUMBER = "sequenceNumber";
public static final String SEQUENCE_SIZE = "sequenceSize";
public static final String SEQUENCE_DETAILS = "sequenceDetails";
public static final String CONTENT_TYPE = "content-type";
public static final String POSTPROCESS_RESULT = "postProcessResult";
private final Map<String, Object> headers;
public MessageHeaders(Map<String, Object> headers) {
this.headers = (headers != null) ? new HashMap<String, Object>(headers) : new HashMap<String, Object>();
if (MessageHeaders.idGenerator == null) {
UUID uuid = new UUID(UUIDGen.newTime(), UUIDGen.getClockSeqAndNode());
this.headers.put(ID, uuid);
}
else {
this.headers.put(ID, MessageHeaders.idGenerator.generateId());
}
this.headers.put(TIMESTAMP, new Long(System.currentTimeMillis()));
}
public UUID getId() {
return this.get(ID, UUID.class);
}
public Long getTimestamp() {
return this.get(TIMESTAMP, Long.class);
}
public Long getExpirationDate() {
return this.get(EXPIRATION_DATE, Long.class);
}
public Object getCorrelationId() {
return this.get(CORRELATION_ID);
}
public Object getReplyChannel() {
return this.get(REPLY_CHANNEL);
}
public Object getErrorChannel() {
return this.get(ERROR_CHANNEL);
}
public Integer getSequenceNumber() {
Integer sequenceNumber = this.get(SEQUENCE_NUMBER, Integer.class);
return (sequenceNumber != null ? sequenceNumber : 0);
}
public Integer getSequenceSize() {
Integer sequenceSize = this.get(SEQUENCE_SIZE, Integer.class);
return (sequenceSize != null ? sequenceSize : 0);
}
public Integer getPriority() {
return this.get(PRIORITY, Integer.class);
}
@SuppressWarnings("unchecked")
public <T> T get(Object key, Class<T> type) {
Object value = this.headers.get(key);
if (value == null) {
return null;
}
if (!type.isAssignableFrom(value.getClass())) {
throw new IllegalArgumentException("Incorrect type specified for header '" + key + "'. Expected [" + type
+ "] but actual type is [" + value.getClass() + "]");
}
return (T) value;
}
@Override
public int hashCode() {
return this.headers.hashCode();
}
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object != null && object instanceof MessageHeaders) {
MessageHeaders other = (MessageHeaders) object;
return this.headers.equals(other.headers);
}
return false;
}
@Override
public String toString() {
return this.headers.toString();
}
/*
* Map implementation
*/
public boolean containsKey(Object key) {
return this.headers.containsKey(key);
}
public boolean containsValue(Object value) {
return this.headers.containsValue(value);
}
public Set<Map.Entry<String, Object>> entrySet() {
return Collections.unmodifiableSet(this.headers.entrySet());
}
public Object get(Object key) {
return this.headers.get(key);
}
public boolean isEmpty() {
return this.headers.isEmpty();
}
public Set<String> keySet() {
return Collections.unmodifiableSet(this.headers.keySet());
}
public int size() {
return this.headers.size();
}
public Collection<Object> values() {
return Collections.unmodifiableCollection(this.headers.values());
}
/*
* Unsupported operations
*/
/**
* Since MessageHeaders are immutable the call to this method will result in {@link UnsupportedOperationException}
*/
public Object put(String key, Object value) {
throw new UnsupportedOperationException("MessageHeaders is immutable.");
}
/**
* Since MessageHeaders are immutable the call to this method will result in {@link UnsupportedOperationException}
*/
public void putAll(Map<? extends String, ? extends Object> t) {
throw new UnsupportedOperationException("MessageHeaders is immutable.");
}
/**
* Since MessageHeaders are immutable the call to this method will result in {@link UnsupportedOperationException}
*/
public Object remove(Object key) {
throw new UnsupportedOperationException("MessageHeaders is immutable.");
}
/**
* Since MessageHeaders are immutable the call to this method will result in {@link UnsupportedOperationException}
*/
public void clear() {
throw new UnsupportedOperationException("MessageHeaders is immutable.");
}
/*
* Serialization methods
*/
private void writeObject(ObjectOutputStream out) throws IOException {
List<String> keysToRemove = new ArrayList<String>();
for (Map.Entry<String, Object> entry : this.headers.entrySet()) {
if (!(entry.getValue() instanceof Serializable)) {
keysToRemove.add(entry.getKey());
}
}
for (String key : keysToRemove) {
if (logger.isInfoEnabled()) {
logger.info("removing non-serializable header: " + key);
}
this.headers.remove(key);
}
out.defaultWriteObject();
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
}
public static interface IdGenerator {
UUID generateId();
}
public static class JdkIdGenerator implements IdGenerator {
@Override
public UUID generateId() {
return UUID.randomUUID();
}
}
public static class SimpleIncrementingIdGenerator implements IdGenerator {
private final AtomicLong topBits = new AtomicLong();
private final AtomicLong bottomBits = new AtomicLong();
@Override
public UUID generateId() {
long bottomBits = this.bottomBits.incrementAndGet();
if (bottomBits == 0) {
this.topBits.incrementAndGet();
}
return new UUID(this.topBits.get(), bottomBits);
}
}
}

View File

@@ -16,9 +16,11 @@
package org.springframework.integration;
import org.springframework.messaging.Message;
/**
* Exception that indicates a message has been rejected by a selector.
*
*
* @author Mark Fisher
*/
@SuppressWarnings("serial")

View File

@@ -16,14 +16,17 @@
package org.springframework.integration;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageDeliveryException;
/**
* Exception that indicates a timeout elapsed prior to successful message delivery.
*
*
* @author Mark Fisher
*/
@SuppressWarnings("serial")
public class MessageTimeoutException extends MessageDeliveryException {
public MessageTimeoutException(String description) {
super(description);
}

View File

@@ -1,69 +0,0 @@
/*
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration;
/**
* The base exception for any failures related to messaging.
*
* @author Mark Fisher
* @author Gary Russell
*/
@SuppressWarnings("serial")
public class MessagingException extends RuntimeException {
private volatile Message<?> failedMessage;
public MessagingException(Message<?> message) {
super();
this.failedMessage = message;
}
public MessagingException(String description) {
super(description);
this.failedMessage = null;
}
public MessagingException(String description, Throwable cause) {
super(description, cause);
this.failedMessage = null;
}
public MessagingException(Message<?> message, String description) {
super(description);
this.failedMessage = message;
}
public MessagingException(Message<?> message, Throwable cause) {
super(cause);
this.failedMessage = message;
}
public MessagingException(Message<?> message, String description, Throwable cause) {
super(description, cause);
this.failedMessage = message;
}
public Message<?> getFailedMessage() {
return this.failedMessage;
}
public void setFailedMessage(Message<?> message) {
this.failedMessage = message;
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2002-2010 the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
@@ -20,15 +20,16 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.EiMessageHeaderAccessor;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.util.Assert;
/**
* Base class for MessageGroupProcessor implementations that aggregate the group of Messages into a single Message.
*
*
* @author Iwein Fuld
* @author Alexander Peters
* @author Mark Fisher
@@ -41,7 +42,7 @@ public abstract class AbstractAggregatingMessageGroupProcessor implements Messag
public final Object processMessageGroup(MessageGroup group) {
Assert.notNull(group, "MessageGroup must not be null");
Map<String, Object> headers = this.aggregateHeaders(group);
Object payload = this.aggregatePayloads(group, headers);
MessageBuilder<?> builder;
@@ -51,7 +52,7 @@ public abstract class AbstractAggregatingMessageGroupProcessor implements Messag
else {
builder = MessageBuilder.withPayload(payload).copyHeadersIfAbsent(headers);
}
return builder.popSequenceDetails().build();
}
@@ -67,7 +68,7 @@ public abstract class AbstractAggregatingMessageGroupProcessor implements Messag
MessageHeaders currentHeaders = message.getHeaders();
for (String key : currentHeaders.keySet()) {
if (MessageHeaders.ID.equals(key) || MessageHeaders.TIMESTAMP.equals(key)
|| MessageHeaders.SEQUENCE_SIZE.equals(key) || MessageHeaders.SEQUENCE_NUMBER.equals(key)) {
|| EiMessageHeaderAccessor.SEQUENCE_SIZE.equals(key) || EiMessageHeaderAccessor.SEQUENCE_NUMBER.equals(key)) {
continue;
}
Object value = currentHeaders.get(key);

View File

@@ -22,13 +22,9 @@ import java.util.concurrent.locks.Lock;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.MessagingException;
import org.springframework.integration.EiMessageHeaderAccessor;
import org.springframework.integration.channel.NullChannel;
import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.handler.AbstractMessageHandler;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.MessageGroupStore;
@@ -36,9 +32,14 @@ import org.springframework.integration.store.MessageGroupStore.MessageGroupCallb
import org.springframework.integration.store.MessageStore;
import org.springframework.integration.store.SimpleMessageGroup;
import org.springframework.integration.store.SimpleMessageStore;
import org.springframework.integration.support.converter.SimpleMessageConverter;
import org.springframework.integration.util.DefaultLockRegistry;
import org.springframework.integration.util.LockRegistry;
import org.springframework.integration.util.UUIDConverter;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.core.GenericMessagingTemplate;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -80,7 +81,7 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageH
private MessageChannel outputChannel;
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
private final GenericMessagingTemplate messagingTemplate = new GenericMessagingTemplate();
private volatile MessageChannel discardChannel = new NullChannel();
@@ -102,7 +103,7 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageH
setMessageStore(store);
this.outputProcessor = processor;
this.correlationStrategy = correlationStrategy == null ?
new HeaderAttributeCorrelationStrategy(MessageHeaders.CORRELATION_ID) : correlationStrategy;
new HeaderAttributeCorrelationStrategy(EiMessageHeaderAccessor.CORRELATION_ID) : correlationStrategy;
this.releaseStrategy = releaseStrategy == null ? new SequenceSizeReleaseStrategy() : releaseStrategy;
this.messagingTemplate.setSendTimeout(DEFAULT_SEND_TIMEOUT);
sequenceAware = this.releaseStrategy instanceof SequenceSizeReleaseStrategy;
@@ -329,7 +330,7 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageH
Message<?> lastReleasedMessage = sorted.get(partialSequence.size()-1);
return lastReleasedMessage.getHeaders().getSequenceNumber();
return new EiMessageHeaderAccessor(lastReleasedMessage).getSequenceNumber();
}
private MessageGroup store(Object correlationKey, Message<?> message) {
@@ -449,9 +450,10 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageH
if (this.size() == 0) {
return true;
}
Integer messageSequenceNumber = message.getHeaders().getSequenceNumber();
EiMessageHeaderAccessor messageHeaderAccessor = new EiMessageHeaderAccessor(message);
Integer messageSequenceNumber = messageHeaderAccessor.getSequenceNumber();
if (messageSequenceNumber != null && messageSequenceNumber > 0) {
Integer messageSequenceSize = message.getHeaders().getSequenceSize();
Integer messageSequenceSize = messageHeaderAccessor.getSequenceSize();
if (!messageSequenceSize.equals(this.getSequenceSize())) {
return false;
}
@@ -464,7 +466,7 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageH
private boolean containsSequenceNumber(Collection<Message<?>> messages, Integer messageSequenceNumber) {
for (Message<?> member : messages) {
Integer memberSequenceNumber = member.getHeaders().getSequenceNumber();
Integer memberSequenceNumber = new EiMessageHeaderAccessor(member).getSequenceNumber();
if (messageSequenceNumber.equals(memberSequenceNumber)) {
return true;
}

View File

@@ -15,7 +15,7 @@ package org.springframework.integration.aggregator;
import java.util.Collection;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.MessageGroupStore;

View File

@@ -20,7 +20,7 @@ import java.util.concurrent.ConcurrentMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.handler.AbstractMessageHandler;
import org.springframework.integration.store.MessageGroup;

View File

@@ -16,7 +16,7 @@
package org.springframework.integration.aggregator;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
/**
* Strategy for determining how messages can be correlated. Implementations

View File

@@ -21,7 +21,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.store.MessageGroup;
import org.springframework.util.Assert;

View File

@@ -24,7 +24,7 @@ import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor;
import org.springframework.util.Assert;

View File

@@ -21,14 +21,13 @@ import java.util.Map;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.core.convert.ConversionService;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.store.MessageGroup;
/**
* A {@link MessageGroupProcessor} implementation that evaluates a SpEL expression. The SpEL context root is the list of
* all Messages in the group. The evaluation result can be any Object and is send as new Message payload to the output
* channel.
*
*
* @author Alex Peters
* @author Dave Syer
*/

View File

@@ -23,7 +23,7 @@ import org.springframework.expression.ExpressionParser;
import org.springframework.expression.ParseException;
import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.util.AbstractExpressionEvaluator;
/**

View File

@@ -16,7 +16,7 @@
package org.springframework.integration.aggregator;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
/**
* Default implementation of {@link CorrelationStrategy}. Uses a header

View File

@@ -17,7 +17,7 @@ package org.springframework.integration.aggregator;
import java.util.Collection;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
/**
* @author Dave Syer
@@ -27,4 +27,4 @@ public interface MessageListProcessor {
Object process(Collection<? extends Message<?>> messages);
}
}

View File

@@ -18,19 +18,20 @@ package org.springframework.integration.aggregator;
import java.util.Comparator;
import org.springframework.integration.Message;
import org.springframework.integration.EiMessageHeaderAccessor;
import org.springframework.messaging.Message;
/**
* A {@link Comparator} implementation based on the 'sequence number'
* property of a {@link Message Message's} header.
*
*
* @author Mark Fisher
*/
public class MessageSequenceComparator implements Comparator<Message<?>> {
public int compare(Message<?> message1, Message<?> message2) {
Integer s1 = message1.getHeaders().getSequenceNumber();
Integer s2 = message2.getHeaders().getSequenceNumber();
Integer s1 = new EiMessageHeaderAccessor(message1).getSequenceNumber();
Integer s2 = new EiMessageHeaderAccessor(message2).getSequenceNumber();
if (s1 == null) {
s1 = 0;
}

View File

@@ -18,7 +18,7 @@ package org.springframework.integration.aggregator;
import java.lang.reflect.Method;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.handler.MethodInvokingMessageProcessor;
import org.springframework.util.Assert;

View File

@@ -22,7 +22,7 @@ import java.util.Map;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.core.convert.ConversionService;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.annotation.Aggregator;
import org.springframework.integration.store.MessageGroup;

View File

@@ -22,7 +22,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.util.AbstractExpressionEvaluator;
import org.springframework.integration.util.MessagingMethodInvokerHelper;

View File

@@ -19,7 +19,8 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.EiMessageHeaderAccessor;
import org.springframework.integration.store.MessageGroup;
/**
@@ -59,6 +60,6 @@ public class ResequencingMessageGroupProcessor implements MessageGroupProcessor
}
private Integer extractSequenceNumber(Message<?> message) {
return message.getHeaders().getSequenceNumber();
return new EiMessageHeaderAccessor(message).getSequenceNumber();
}
}

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2002-2011 the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
@@ -15,13 +15,14 @@ package org.springframework.integration.aggregator;
import java.util.Collection;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.EiMessageHeaderAccessor;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.MessageGroupStore;
/**
* Resequencer specific implementation of {@link AbstractCorrelatingMessageHandler}.
* Will remove {@link MessageGroup}s only if 'sequenceSize' is provided and reached.
* Resequencer specific implementation of {@link AbstractCorrelatingMessageHandler}.
* Will remove {@link MessageGroup}s only if 'sequenceSize' is provided and reached.
*
* @author Oleg Zhurakousky
* @since 2.1
@@ -34,32 +35,32 @@ public class ResequencingMessageHandler extends AbstractCorrelatingMessageHandle
super(processor, store, correlationStrategy, releaseStrategy);
}
public ResequencingMessageHandler(MessageGroupProcessor processor,
MessageGroupStore store) {
super(processor, store);
}
public ResequencingMessageHandler(MessageGroupProcessor processor) {
super(processor);
}
@Override
protected void afterRelease(MessageGroup messageGroup, Collection<Message<?>> completedMessages) {
int size = messageGroup.getMessages().size();
int sequenceSize = 0;
Message<?> message = messageGroup.getOne();
if (message != null){
sequenceSize = message.getHeaders().getSequenceSize();
sequenceSize = new EiMessageHeaderAccessor(message).getSequenceSize();
}
// If there is no sequence then it must be incomplete or unbounded
if (sequenceSize > 0 && sequenceSize == size){
remove(messageGroup);
}
else {
if (completedMessages != null){
if (completedMessages != null){
int lastReleasedSequenceNumber = this.findLastReleasedSequenceNumber(messageGroup.getGroupId(), completedMessages);
messageStore.setLastReleasedSequenceNumberForGroup(messageGroup.getGroupId(), lastReleasedSequenceNumber);
for (Message<?> msg : completedMessages) {

View File

@@ -1,11 +1,11 @@
/*
* Copyright 2002-2010 the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
@@ -15,13 +15,14 @@ package org.springframework.integration.aggregator;
import java.util.Comparator;
import org.springframework.integration.Message;
import org.springframework.integration.EiMessageHeaderAccessor;
import org.springframework.messaging.Message;
/**
* @author Dave Syer
*
*
* @since 2.0
*
*
*/
public class SequenceNumberComparator implements Comparator<Message<?>> {
@@ -31,8 +32,8 @@ public class SequenceNumberComparator implements Comparator<Message<?>> {
* rank.
*/
public int compare(Message<?> o1, Message<?> o2) {
Integer sequenceNumber1 = o1.getHeaders().getSequenceNumber();
Integer sequenceNumber2 = o2.getHeaders().getSequenceNumber();
Integer sequenceNumber1 = new EiMessageHeaderAccessor(o1).getSequenceNumber();
Integer sequenceNumber2 = new EiMessageHeaderAccessor(o2).getSequenceNumber();
if (sequenceNumber1 == sequenceNumber2) {
return 0;
}
@@ -45,4 +46,4 @@ public class SequenceNumberComparator implements Comparator<Message<?>> {
return sequenceNumber1.compareTo(sequenceNumber2);
}
}
}

View File

@@ -24,13 +24,14 @@ import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.EiMessageHeaderAccessor;
import org.springframework.integration.store.MessageGroup;
/**
* An implementation of {@link ReleaseStrategy} that simply compares the current size of the message list to the
* expected 'sequenceSize'.
*
*
* @author Mark Fisher
* @author Marius Bogoevici
* @author Dave Syer
@@ -56,7 +57,7 @@ public class SequenceSizeReleaseStrategy implements ReleaseStrategy {
/**
* Flag that determines if partial sequences are allowed. If true then as soon as enough messages arrive that can be
* ordered they will be released, provided they all have sequence numbers greater than those already released.
*
*
* @param releasePartialSequences
*/
public void setReleasePartialSequences(boolean releasePartialSequences) {
@@ -66,38 +67,38 @@ public class SequenceSizeReleaseStrategy implements ReleaseStrategy {
public boolean canRelease(MessageGroup messageGroup) {
boolean canRelease = false;
Collection<Message<?>> messages = messageGroup.getMessages();
if (releasePartialSequences && !messages.isEmpty()) {
if (logger.isTraceEnabled()) {
logger.trace("Considering partial release of group [" + messageGroup + "]");
}
List<Message<?>> sorted = new ArrayList<Message<?>>(messages);
Collections.sort(sorted, comparator);
int nextSequenceNumber = sorted.get(0).getHeaders().getSequenceNumber();
int nextSequenceNumber = new EiMessageHeaderAccessor(sorted.get(0)).getSequenceNumber();
int lastReleasedMessageSequence = messageGroup.getLastReleasedMessageSequenceNumber();
if (nextSequenceNumber - lastReleasedMessageSequence == 1){
canRelease = true;;
}
}
}
else {
int size = messages.size();
if (size == 0){
canRelease = true;
}
else {
int sequenceSize = messageGroup.getOne().getHeaders().getSequenceSize();
int sequenceSize = new EiMessageHeaderAccessor(messageGroup.getOne()).getSequenceSize();
// If there is no sequence then it must be incomplete....
if (sequenceSize == size){
canRelease = true;
}
}
}
}
return canRelease;
}

View File

@@ -13,7 +13,7 @@
package org.springframework.integration.aggregator;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.store.MessageGroup;
/**

View File

@@ -1,4 +1,4 @@
/**
* Provides classes related to message aggregation.
*/
package org.springframework.integration.aggregator;
package org.springframework.integration.aggregator;

View File

@@ -26,7 +26,7 @@ import java.lang.annotation.Target;
* Indicates that a method is capable of playing the role of a Message Filter.
* <p>
* A method annotated with @Filter may accept a parameter of type
* {@link org.springframework.integration.Message} or of the expected
* {@link org.springframework.messaging.Message} or of the expected
* Message payload's type. Any type conversion supported by default or any
* Converters registered with the "integrationConversionService" bean will be
* applied to the Message payload if necessary. Header values can also be passed

View File

@@ -30,7 +30,7 @@ import java.lang.annotation.Target;
* where the annotation attributes can override the default channel settings.
*
* <p>A method annotated with @Gateway may accept a single non-annotated
* parameter of type {@link org.springframework.integration.Message}
* parameter of type {@link org.springframework.messaging.Message}
* or of the intended Message payload type. Method parameters may be mapped
* to individual Message header values by using the {@link Header @Header}
* parameter annotation. Alternatively, to pass the entire Message headers

View File

@@ -28,7 +28,7 @@ import java.lang.annotation.Target;
* based on a message, message header(s), or both.
* <p>
* A method annotated with @Router may accept a parameter of type
* {@link org.springframework.integration.Message} or of the expected
* {@link org.springframework.messaging.Message} or of the expected
* Message payload's type. Any type conversion supported by
* {@link org.springframework.beans.SimpleTypeConverter} will be applied to
* the Message payload if necessary. Header values can also be passed as
@@ -36,7 +36,7 @@ import java.lang.annotation.Target;
* <p>
* Return values from the annotated method may be either a Collection or Array
* whose elements are either
* {@link org.springframework.integration.MessageChannel channels} or
* {@link org.springframework.messaging.MessageChannel channels} or
* Strings. In the latter case, the endpoint hosting this router will attempt
* to resolve each channel name with the Channel Registry.
*

View File

@@ -27,7 +27,7 @@ import java.lang.annotation.Target;
* Indicates that a method is capable of handling a message or message payload.
* <p>
* A method annotated with @ServiceActivator may accept a parameter of type
* {@link org.springframework.integration.Message} or of the expected
* {@link org.springframework.messaging.Message} or of the expected
* Message payload's type. Any type conversion supported by
* {@link org.springframework.beans.SimpleTypeConverter} will be applied to
* the Message payload if necessary. Header values can also be passed as

View File

@@ -27,7 +27,7 @@ import java.lang.annotation.Target;
* payload to produce multiple messages or payloads.
* <p>
* A method annotated with @Splitter may accept a parameter of type
* {@link org.springframework.integration.Message} or of the expected
* {@link org.springframework.messaging.Message} or of the expected
* Message payload's type. Any type conversion supported by
* {@link org.springframework.beans.SimpleTypeConverter} will be applied to
* the Message payload if necessary. Header values can also be passed as

View File

@@ -1,4 +1,4 @@
/**
* Provides annotations for annotation-based configuration.
*/
package org.springframework.integration.annotation;
package org.springframework.integration.annotation;

View File

@@ -22,7 +22,6 @@ import java.util.Map;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
@@ -36,12 +35,12 @@ import org.springframework.expression.ParseException;
import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.integration.expression.ExpressionUtils;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.support.channel.ChannelResolver;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.core.DestinationResolver;
import org.springframework.messaging.core.GenericMessagingTemplate;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -56,13 +55,13 @@ import org.springframework.util.StringUtils;
*/
public class MessagePublishingInterceptor implements MethodInterceptor, BeanFactoryAware {
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
private final GenericMessagingTemplate messagingTemplate = new GenericMessagingTemplate();
private volatile PublisherMetadataSource metadataSource;
private final ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
private volatile ChannelResolver channelResolver;
private volatile DestinationResolver<MessageChannel> channelResolver;
private volatile BeanFactory beanFactory;
@@ -81,10 +80,10 @@ public class MessagePublishingInterceptor implements MethodInterceptor, BeanFact
}
public void setDefaultChannel(MessageChannel defaultChannel) {
this.messagingTemplate.setDefaultChannel(defaultChannel);
this.messagingTemplate.setDefaultDestination(defaultChannel);
}
public void setChannelResolver(ChannelResolver channelResolver) {
public void setChannelResolver(DestinationResolver<MessageChannel> channelResolver) {
this.channelResolver = channelResolver;
}
@@ -150,7 +149,7 @@ public class MessagePublishingInterceptor implements MethodInterceptor, BeanFact
MessageChannel channel = null;
if (channelName != null) {
Assert.state(this.channelResolver != null, "ChannelResolver is required to resolve channel names.");
channel = this.channelResolver.resolveChannelName(channelName);
channel = this.channelResolver.resolveDestination(channelName);
}
if (channel != null) {
this.messagingTemplate.send(channel, message);

View File

@@ -23,7 +23,6 @@ import java.util.HashSet;
import java.util.Set;
import org.aopalliance.aop.Advice;
import org.springframework.aop.ClassFilter;
import org.springframework.aop.MethodMatcher;
import org.springframework.aop.Pointcut;
@@ -35,9 +34,9 @@ import org.springframework.aop.support.annotation.AnnotationMethodMatcher;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.annotation.Publisher;
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.core.BeanFactoryMessageChannelDestinationResolver;
import org.springframework.util.Assert;
/**
@@ -73,7 +72,7 @@ public class PublisherAnnotationAdvisor extends AbstractPointcutAdvisor implemen
}
public void setBeanFactory(BeanFactory beanFactory) {
this.interceptor.setChannelResolver(new BeanFactoryChannelResolver(beanFactory));
this.interceptor.setChannelResolver(new BeanFactoryMessageChannelDestinationResolver(beanFactory));
this.interceptor.setBeanFactory(beanFactory);
}

View File

@@ -27,7 +27,7 @@ import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.Ordered;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.annotation.Publisher;
import org.springframework.util.ClassUtils;

View File

@@ -1,4 +1,4 @@
/**
* Provides classes to support message publication using AOP.
*/
package org.springframework.integration.aop;
package org.springframework.integration.aop;

View File

@@ -24,14 +24,14 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.OrderComparator;
import org.springframework.core.convert.ConversionService;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.MessagingException;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.history.MessageHistory;
import org.springframework.integration.history.TrackableComponent;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageDeliveryException;
import org.springframework.messaging.MessagingException;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

View File

@@ -16,8 +16,8 @@
package org.springframework.integration.channel;
import org.springframework.integration.Message;
import org.springframework.integration.core.PollableChannel;
import org.springframework.messaging.Message;
import org.springframework.messaging.PollableChannel;
/**
* Base class for all pollable channels.

View File

@@ -18,14 +18,14 @@ package org.springframework.integration.channel;
import java.util.concurrent.atomic.AtomicInteger;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.MessageDispatchingException;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.SubscribableChannel;
import org.springframework.integration.dispatcher.AbstractDispatcher;
import org.springframework.integration.dispatcher.MessageDispatcher;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageDeliveryException;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.util.Assert;
/**

View File

@@ -16,8 +16,8 @@
package org.springframework.integration.channel;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
/**
* Interface for interceptors that are able to view and/or modify the

View File

@@ -19,7 +19,7 @@ package org.springframework.integration.channel;
import java.util.ArrayList;
import java.util.List;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.core.MessageSelector;
import org.springframework.util.Assert;

View File

@@ -18,11 +18,11 @@ package org.springframework.integration.channel;
import java.util.concurrent.Executor;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.core.BeanFactoryMessageChannelDestinationResolver;
import org.springframework.integration.dispatcher.LoadBalancingStrategy;
import org.springframework.integration.dispatcher.RoundRobinLoadBalancingStrategy;
import org.springframework.integration.dispatcher.UnicastingDispatcher;
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
import org.springframework.integration.util.ErrorHandlingTaskExecutor;
import org.springframework.util.Assert;
import org.springframework.util.ErrorHandler;
@@ -111,7 +111,7 @@ public class ExecutorChannel extends AbstractSubscribableChannel {
public final void onInit() {
if (!(this.executor instanceof ErrorHandlingTaskExecutor)) {
ErrorHandler errorHandler = new MessagePublishingErrorHandler(
new BeanFactoryChannelResolver(this.getBeanFactory()));
new BeanFactoryMessageChannelDestinationResolver(this.getBeanFactory()));
this.executor = new ErrorHandlingTaskExecutor(this.executor, errorHandler);
}
this.dispatcher = new UnicastingDispatcher(this.executor);

View File

@@ -21,20 +21,20 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessagingException;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.message.ErrorMessage;
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
import org.springframework.integration.support.channel.ChannelResolver;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.core.BeanFactoryMessageChannelDestinationResolver;
import org.springframework.messaging.core.DestinationResolver;
import org.springframework.messaging.support.ErrorMessage;
import org.springframework.util.Assert;
import org.springframework.util.ErrorHandler;
/**
* {@link ErrorHandler} implementation that sends an {@link ErrorMessage} to a
* {@link MessageChannel}.
*
*
* @author Mark Fisher
* @author Iwein Fuld
* @author Oleg Zhurakousky
@@ -43,7 +43,7 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA
private final Log logger = LogFactory.getLog(this.getClass());
private volatile ChannelResolver channelResolver;
private volatile DestinationResolver<MessageChannel> channelResolver;
private volatile MessageChannel defaultErrorChannel;
@@ -53,7 +53,7 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA
public MessagePublishingErrorHandler() {
}
public MessagePublishingErrorHandler(ChannelResolver channelResolver) {
public MessagePublishingErrorHandler(DestinationResolver<MessageChannel> channelResolver) {
Assert.notNull(channelResolver, "channelResolver must not be null");
this.channelResolver = channelResolver;
}
@@ -70,7 +70,7 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA
public void setBeanFactory(BeanFactory beanFactory) {
Assert.notNull(beanFactory, "beanFactory must not be null");
if (this.channelResolver == null) {
this.channelResolver = new BeanFactoryChannelResolver(beanFactory);
this.channelResolver = new BeanFactoryMessageChannelDestinationResolver(beanFactory);
}
}
@@ -108,10 +108,10 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA
Message<?> failedMessage = (t instanceof MessagingException) ?
((MessagingException) t).getFailedMessage() : null;
if (this.defaultErrorChannel == null && this.channelResolver != null) {
this.defaultErrorChannel = this.channelResolver.resolveChannelName(
this.defaultErrorChannel = this.channelResolver.resolveDestination(
IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME);
}
if (failedMessage == null || failedMessage.getHeaders().getErrorChannel() == null) {
return this.defaultErrorChannel;
}
@@ -122,7 +122,7 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA
Assert.isInstanceOf(String.class, errorChannelHeader,
"Unsupported error channel header type. Expected MessageChannel or String, but actual type is [" +
errorChannelHeader.getClass() + "]");
return this.channelResolver.resolveChannelName((String) errorChannelHeader);
return this.channelResolver.resolveDestination((String) errorChannelHeader);
}
}

View File

@@ -19,8 +19,8 @@ package org.springframework.integration.channel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.Message;
import org.springframework.integration.core.PollableChannel;
import org.springframework.messaging.Message;
import org.springframework.messaging.PollableChannel;
/**
* A channel implementation that essentially behaves like "/dev/null".

View File

@@ -20,21 +20,22 @@ import java.util.Comparator;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.atomic.AtomicLong;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHeaders;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.integration.EiMessageHeaderAccessor;
import org.springframework.integration.util.UpperBound;
/**
* A message channel that prioritizes messages based on a {@link Comparator}.
* The default comparator is based upon the message header's 'priority'.
*
*
* @author Mark Fisher
* @author Oleg Zhurakousky
*/
public class PriorityChannel extends QueueChannel {
private final UpperBound upperBound;
private final AtomicLong sequenceCounter = new AtomicLong();
/**
@@ -93,11 +94,11 @@ public class PriorityChannel extends QueueChannel {
}
return message;
}
private static class SequenceFallbackComparator implements Comparator<Message<?>> {
private final Comparator<Message<?>> targetComparator;
public SequenceFallbackComparator(Comparator<Message<?>> targetComparator){
this.targetComparator = targetComparator;
}
@@ -108,14 +109,14 @@ public class PriorityChannel extends QueueChannel {
compareResult = this.targetComparator.compare(message1, message2);
}
else {
Integer priority1 = message1.getHeaders().getPriority();
Integer priority2 = message2.getHeaders().getPriority();
Integer priority1 = new EiMessageHeaderAccessor(message1).getPriority();
Integer priority2 = new EiMessageHeaderAccessor(message2).getPriority();
priority1 = priority1 != null ? priority1 : 0;
priority2 = priority2 != null ? priority2 : 0;
compareResult = priority2.compareTo(priority1);
}
if (compareResult == 0){
Long sequence1 = ((MessageWrapper) message1).getSequence();
Long sequence2 = ((MessageWrapper) message2).getSequence();
@@ -124,7 +125,7 @@ public class PriorityChannel extends QueueChannel {
return compareResult;
}
}
//we need this because of INT-2508
private class MessageWrapper implements Message<Object>{
private final Message<?> rootMessage;

View File

@@ -19,8 +19,8 @@ package org.springframework.integration.channel;
import java.util.concurrent.Executor;
import org.springframework.integration.dispatcher.BroadcastingDispatcher;
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
import org.springframework.integration.util.ErrorHandlingTaskExecutor;
import org.springframework.messaging.core.BeanFactoryMessageChannelDestinationResolver;
import org.springframework.util.ErrorHandler;
/**
@@ -139,7 +139,7 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel {
if (!(this.executor instanceof ErrorHandlingTaskExecutor)) {
if (this.errorHandler == null) {
this.errorHandler = new MessagePublishingErrorHandler(
new BeanFactoryChannelResolver(this.getBeanFactory()));
new BeanFactoryMessageChannelDestinationResolver(this.getBeanFactory()));
}
this.executor = new ErrorHandlingTaskExecutor(this.executor, this.errorHandler);
}

View File

@@ -22,7 +22,7 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.core.MessageSelector;
import org.springframework.util.Assert;

View File

@@ -17,7 +17,7 @@ package org.springframework.integration.channel;
import java.util.List;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
import org.springframework.integration.core.MessageSelector;
/**

View File

@@ -18,7 +18,7 @@ package org.springframework.integration.channel;
import java.util.concurrent.SynchronousQueue;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
/**
* A zero-capacity version of {@link QueueChannel} that delegates to a

View File

@@ -16,8 +16,8 @@
package org.springframework.integration.channel.interceptor;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.channel.ChannelInterceptor;
/**

View File

@@ -33,7 +33,7 @@ import org.springframework.beans.NotReadablePropertyException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.OrderComparator;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.channel.ChannelInterceptor;
import org.springframework.util.PatternMatchUtils;
import org.springframework.util.StringUtils;

View File

@@ -19,16 +19,16 @@ package org.springframework.integration.channel.interceptor;
import java.util.Arrays;
import java.util.List;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.core.MessageSelector;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageDeliveryException;
/**
* A {@link org.springframework.integration.channel.ChannelInterceptor} that
* delegates to a list of {@link MessageSelector MessageSelectors} to decide
* whether a {@link Message} should be accepted on the {@link MessageChannel}.
*
*
* @author Mark Fisher
*/
public class MessageSelectingInterceptor extends ChannelInterceptorAdapter {

View File

@@ -19,8 +19,8 @@ package org.springframework.integration.channel.interceptor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.Lifecycle;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.channel.ChannelInterceptor;
import org.springframework.integration.core.MessageSelector;
import org.springframework.jmx.export.annotation.ManagedAttribute;

View File

@@ -1,4 +1,4 @@
/**
* Provides classes related to channel interception.
*/
package org.springframework.integration.channel.interceptor;
package org.springframework.integration.channel.interceptor;

View File

@@ -1,4 +1,4 @@
/**
* Provides classes representing various channel types.
*/
package org.springframework.integration.channel;
package org.springframework.integration.channel;

View File

@@ -13,7 +13,7 @@
package org.springframework.integration.channel.registry;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.MessageChannel;
/**
* A strategy interface used to bind a {@link MessageChannel} to a logical name. The name

View File

@@ -18,12 +18,12 @@ import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.channel.AbstractMessageChannel;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.channel.PublishSubscribeChannel;
import org.springframework.integration.channel.interceptor.WireTap;
import org.springframework.integration.core.SubscribableChannel;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.integration.handler.BridgeHandler;
import org.springframework.util.Assert;

View File

@@ -25,12 +25,12 @@ import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.context.Orderable;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;

View File

@@ -22,9 +22,9 @@ import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.handler.MessageProcessor;
import org.springframework.messaging.MessageHandler;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

View File

@@ -33,11 +33,11 @@ import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.SmartLifecycle;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.SubscribableChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.integration.endpoint.AbstractEndpoint;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.endpoint.PollingConsumer;

View File

@@ -18,26 +18,26 @@ package org.springframework.integration.config;
import java.lang.reflect.Method;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.EiMessageHeaderAccessor;
import org.springframework.integration.aggregator.CorrelationStrategy;
import org.springframework.integration.aggregator.MethodInvokingCorrelationStrategy;
import org.springframework.integration.aggregator.HeaderAttributeCorrelationStrategy;
import org.springframework.integration.aggregator.MethodInvokingCorrelationStrategy;
import org.springframework.util.StringUtils;
/**
* Convenience factory for XML configuration of a {@link CorrelationStrategy}. Encapsulates the knowledge of the default
* strategy and search algorithms for POJO and annotated methods.
*
*
* @author Dave Syer
*
*
*/
public class CorrelationStrategyFactoryBean implements FactoryBean<CorrelationStrategy> {
private CorrelationStrategy delegate = new HeaderAttributeCorrelationStrategy(MessageHeaders.CORRELATION_ID);
private CorrelationStrategy delegate = new HeaderAttributeCorrelationStrategy(EiMessageHeaderAccessor.CORRELATION_ID);
/**
* Create a factory and set up the delegate which clients of the factory will see as its product.
*
*
* @param target the target object (null if default strategy is acceptable)
*/
public CorrelationStrategyFactoryBean(Object target) {
@@ -46,7 +46,7 @@ public class CorrelationStrategyFactoryBean implements FactoryBean<CorrelationSt
/**
* Create a factory and set up the delegate which clients of the factory will see as its product.
*
*
* @param target the target object (null if default strategy is acceptable)
* @param methodName the method name to invoke in the target (null if it can be inferred)
*/

View File

@@ -21,7 +21,7 @@ import java.util.List;
import org.springframework.context.Lifecycle;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.expression.MethodFilter;
import org.springframework.integration.core.MessageHandler;
import org.springframework.messaging.MessageHandler;
import org.springframework.integration.handler.ExpressionCommandMessageProcessor;
import org.springframework.integration.handler.ServiceActivatingHandler;
import org.springframework.jmx.export.annotation.ManagedAttribute;

View File

@@ -17,8 +17,8 @@
package org.springframework.integration.config;
import org.springframework.expression.Expression;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.core.MessageHandler;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.integration.core.MessageSelector;
import org.springframework.integration.filter.ExpressionEvaluatingSelector;
import org.springframework.integration.filter.MessageFilter;

View File

@@ -30,8 +30,8 @@ import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ApplicationContextEvent;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.MessageHeaders.IdGenerator;
import org.springframework.messaging.MessageHeaders;
import org.springframework.messaging.MessageHeaders.IdGenerator;
import org.springframework.util.ReflectionUtils;
/**

View File

@@ -1,5 +1,9 @@
/*
<<<<<<< HEAD
* Copyright 2002-2013 the original author or authors.
=======
* Copyright 2002-2011 the original author or authors.
>>>>>>> Further Spring 4 updates.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
@@ -17,16 +21,15 @@ import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.expression.Expression;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.router.AbstractMappingMessageRouter;
import org.springframework.integration.router.AbstractMessageRouter;
import org.springframework.integration.router.ExpressionEvaluatingRouter;
import org.springframework.integration.router.MethodInvokingRouter;
import org.springframework.integration.support.channel.ChannelResolver;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.core.DestinationResolver;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -55,10 +58,9 @@ public class RouterFactoryBean extends AbstractStandardMessageHandlerFactoryBean
private volatile Boolean ignoreSendFailures;
private volatile ChannelResolver channelResolver;
private volatile DestinationResolver<MessageChannel> channelResolver;
public void setChannelResolver(ChannelResolver channelResolver) {
public void setChannelResolver(DestinationResolver<MessageChannel> channelResolver) {
this.channelResolver = channelResolver;
}

View File

@@ -17,12 +17,12 @@
package org.springframework.integration.config;
import org.springframework.expression.Expression;
import org.springframework.integration.Message;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor;
import org.springframework.integration.handler.MessageProcessor;
import org.springframework.integration.handler.ServiceActivatingHandler;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.util.StringUtils;
/**

View File

@@ -24,7 +24,7 @@ import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.SmartLifecycle;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.core.MessageSource;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
import org.springframework.integration.scheduling.PollerMetadata;

View File

@@ -17,12 +17,12 @@
package org.springframework.integration.config;
import org.springframework.expression.Expression;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.splitter.AbstractMessageSplitter;
import org.springframework.integration.splitter.DefaultMessageSplitter;
import org.springframework.integration.splitter.ExpressionEvaluatingSplitter;
import org.springframework.integration.splitter.MethodInvokingSplitter;
import org.springframework.messaging.MessageHandler;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

View File

@@ -17,12 +17,12 @@
package org.springframework.integration.config;
import org.springframework.expression.Expression;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.transformer.ExpressionEvaluatingTransformer;
import org.springframework.integration.transformer.MessageTransformingHandler;
import org.springframework.integration.transformer.MethodInvokingTransformer;
import org.springframework.integration.transformer.Transformer;
import org.springframework.messaging.MessageHandler;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

View File

@@ -23,22 +23,21 @@ import java.util.Collection;
import java.util.List;
import org.aopalliance.aop.Advice;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.Order;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.context.Orderable;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.SubscribableChannel;
import org.springframework.integration.endpoint.AbstractEndpoint;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
import org.springframework.integration.support.channel.ChannelResolver;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.messaging.core.BeanFactoryMessageChannelDestinationResolver;
import org.springframework.messaging.core.DestinationResolver;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -57,13 +56,13 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
protected final BeanFactory beanFactory;
protected final ChannelResolver channelResolver;
protected final DestinationResolver<MessageChannel> channelResolver;
public AbstractMethodAnnotationPostProcessor(ListableBeanFactory beanFactory) {
Assert.notNull(beanFactory, "BeanFactory must not be null");
this.beanFactory = beanFactory;
this.channelResolver = new BeanFactoryChannelResolver(beanFactory);
this.channelResolver = new BeanFactoryMessageChannelDestinationResolver(beanFactory);
}
@@ -128,7 +127,7 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
AbstractEndpoint endpoint = null;
String inputChannelName = (String) AnnotationUtils.getValue(annotation, INPUT_CHANNEL_ATTRIBUTE);
if (StringUtils.hasText(inputChannelName)) {
MessageChannel inputChannel = this.channelResolver.resolveChannelName(inputChannelName);
MessageChannel inputChannel = this.channelResolver.resolveDestination(inputChannelName);
Assert.notNull(inputChannel, "failed to resolve inputChannel '" + inputChannelName + "'");
Assert.isTrue(inputChannel instanceof SubscribableChannel,
"The input channel for an Annotation-based endpoint must be a SubscribableChannel.");

View File

@@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicReference;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.aggregator.AggregatingMessageHandler;
import org.springframework.integration.aggregator.MethodInvokingCorrelationStrategy;
import org.springframework.integration.aggregator.MethodInvokingMessageGroupProcessor;
@@ -30,7 +30,7 @@ import org.springframework.integration.aggregator.MethodInvokingReleaseStrategy;
import org.springframework.integration.annotation.Aggregator;
import org.springframework.integration.annotation.CorrelationStrategy;
import org.springframework.integration.annotation.ReleaseStrategy;
import org.springframework.integration.core.MessageHandler;
import org.springframework.messaging.MessageHandler;
import org.springframework.integration.store.SimpleMessageStore;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
@@ -38,7 +38,7 @@ import org.springframework.util.StringUtils;
/**
* Post-processor for the {@link Aggregator @Aggregator} annotation.
*
*
* @author Mark Fisher
* @author Oleg Zhurakousky
*/
@@ -57,13 +57,13 @@ public class AggregatorAnnotationPostProcessor extends AbstractMethodAnnotationP
AggregatingMessageHandler handler = new AggregatingMessageHandler(processor, new SimpleMessageStore(), correlationStrategy, releaseStrategy);
String discardChannelName = annotation.discardChannel();
if (StringUtils.hasText(discardChannelName)) {
MessageChannel discardChannel = this.channelResolver.resolveChannelName(discardChannelName);
MessageChannel discardChannel = this.channelResolver.resolveDestination(discardChannelName);
Assert.notNull(discardChannel, "failed to resolve discardChannel '" + discardChannelName + "'");
handler.setDiscardChannel(discardChannel);
}
String outputChannelName = annotation.outputChannel();
if (StringUtils.hasText(outputChannelName)) {
handler.setOutputChannel(this.channelResolver.resolveChannelName(outputChannelName));
handler.setOutputChannel(this.channelResolver.resolveDestination(outputChannelName));
}
handler.setSendTimeout(annotation.sendTimeout());
handler.setSendPartialResultOnExpiry(annotation.sendPartialResultsOnExpiry());

View File

@@ -20,7 +20,7 @@ import java.lang.reflect.Method;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.integration.annotation.Filter;
import org.springframework.integration.core.MessageHandler;
import org.springframework.messaging.MessageHandler;
import org.springframework.integration.filter.MessageFilter;
import org.springframework.integration.filter.MethodInvokingSelector;
import org.springframework.util.Assert;
@@ -48,7 +48,7 @@ public class FilterAnnotationPostProcessor extends AbstractMethodAnnotationPostP
MessageFilter filter = new MessageFilter(selector);
String outputChannelName = annotation.outputChannel();
if (StringUtils.hasText(outputChannelName)) {
filter.setOutputChannel(this.channelResolver.resolveChannelName(outputChannelName));
filter.setOutputChannel(this.channelResolver.resolveDestination(outputChannelName));
}
filter.setDiscardWithinAdvice(annotation.discardWithinAdvice());
return filter;

View File

@@ -19,9 +19,9 @@ package org.springframework.integration.config.annotation;
import java.lang.reflect.Method;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.MessageChannel;
import org.springframework.integration.annotation.Router;
import org.springframework.integration.core.MessageHandler;
import org.springframework.messaging.MessageHandler;
import org.springframework.integration.router.MethodInvokingRouter;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -44,7 +44,7 @@ public class RouterAnnotationPostProcessor extends AbstractMethodAnnotationPostP
router.setBeanFactory(this.beanFactory);
String defaultOutputChannelName = annotation.defaultOutputChannel();
if (StringUtils.hasText(defaultOutputChannelName)) {
MessageChannel defaultOutputChannel = this.channelResolver.resolveChannelName(defaultOutputChannelName);
MessageChannel defaultOutputChannel = this.channelResolver.resolveDestination(defaultOutputChannelName);
Assert.notNull(defaultOutputChannel, "unable to resolve defaultOutputChannel '" + defaultOutputChannelName + "'");
router.setDefaultOutputChannel(defaultOutputChannel);
}

View File

@@ -20,13 +20,13 @@ import java.lang.reflect.Method;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.core.MessageHandler;
import org.springframework.messaging.MessageHandler;
import org.springframework.integration.handler.ServiceActivatingHandler;
import org.springframework.util.StringUtils;
/**
* Post-processor for Methods annotated with {@link ServiceActivator @ServiceActivator}.
*
*
* @author Mark Fisher
*/
public class ServiceActivatorAnnotationPostProcessor extends AbstractMethodAnnotationPostProcessor<ServiceActivator> {
@@ -41,7 +41,7 @@ public class ServiceActivatorAnnotationPostProcessor extends AbstractMethodAnnot
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(bean, method);
String outputChannelName = annotation.outputChannel();
if (StringUtils.hasText(outputChannelName)) {
serviceActivator.setOutputChannel(this.channelResolver.resolveChannelName(outputChannelName));
serviceActivator.setOutputChannel(this.channelResolver.resolveDestination(outputChannelName));
}
return serviceActivator;
}

View File

@@ -20,7 +20,7 @@ import java.lang.reflect.Method;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.integration.annotation.Splitter;
import org.springframework.integration.core.MessageHandler;
import org.springframework.messaging.MessageHandler;
import org.springframework.integration.splitter.MethodInvokingSplitter;
import org.springframework.util.StringUtils;
@@ -41,7 +41,7 @@ public class SplitterAnnotationPostProcessor extends AbstractMethodAnnotationPos
MethodInvokingSplitter splitter = new MethodInvokingSplitter(bean, method);
String outputChannelName = annotation.outputChannel();
if (StringUtils.hasText(outputChannelName)) {
splitter.setOutputChannel(this.channelResolver.resolveChannelName(outputChannelName));
splitter.setOutputChannel(this.channelResolver.resolveDestination(outputChannelName));
}
return splitter;
}

View File

@@ -20,7 +20,7 @@ import java.lang.reflect.Method;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.integration.annotation.Transformer;
import org.springframework.integration.core.MessageHandler;
import org.springframework.messaging.MessageHandler;
import org.springframework.integration.transformer.MessageTransformingHandler;
import org.springframework.integration.transformer.MethodInvokingTransformer;
import org.springframework.util.StringUtils;
@@ -43,7 +43,7 @@ public class TransformerAnnotationPostProcessor extends AbstractMethodAnnotation
MessageTransformingHandler handler = new MessageTransformingHandler(transformer);
String outputChannelName = annotation.outputChannel();
if (StringUtils.hasText(outputChannelName)) {
handler.setOutputChannel(this.channelResolver.resolveChannelName(outputChannelName));
handler.setOutputChannel(this.channelResolver.resolveDestination(outputChannelName));
}
return handler;
}

View File

@@ -1,4 +1,4 @@
/**
* Provides classes supporting annotation-based configuration.
*/
package org.springframework.integration.config.annotation;
package org.springframework.integration.config.annotation;

View File

@@ -1,4 +1,4 @@
/**
* Base package for configuration.
*/
package org.springframework.integration.config;
package org.springframework.integration.config;

View File

@@ -33,7 +33,7 @@ import org.springframework.util.StringUtils;
/**
* Base parser for Channel Adapters.
* <p/>
* Includes logic to determine {@link org.springframework.integration.MessageChannel}:
* Includes logic to determine {@link org.springframework.messaging.MessageChannel}:
* if 'channel' attribute is defined - uses its value as 'channelName';
* if 'id' attribute is defined - creates {@link DirectChannel} at runtime and uses id's value as 'channelName';
* if current component is defined as nested element inside any other components e.g. &lt;chain&gt;

View File

@@ -36,7 +36,7 @@ import org.springframework.util.xml.DomUtils;
* If this component is defined as the top-level element in the Spring application context it will produce
* an {@link org.springframework.integration.endpoint.AbstractEndpoint} depending on the channel type.
* If this component is defined as nested element (e.g., inside of the chain) it will produce
* a {@link org.springframework.integration.core.MessageHandler}.
* a {@link org.springframework.messaging.MessageHandler}.
*
* @author Mark Fisher
* @author Gary Russell

View File

@@ -136,4 +136,4 @@ final class ChannelInitializer implements BeanFactoryAware, InitializingBean {
return channelNames;
}
}
}
}

View File

@@ -73,23 +73,26 @@ class DefaultConfiguringBeanFactoryPostProcessor implements BeanFactoryPostProce
}
}
private void registerIdGeneratorConfigurer(BeanDefinitionRegistry registry) {
String listenerClassName = "org.springframework.integration.config.IdGeneratorConfigurer";
private void registerInfrastructureBean(BeanDefinitionRegistry registry, String className) {
String[] definitionNames = registry.getBeanDefinitionNames();
for (String definitionName : definitionNames) {
BeanDefinition definition = registry.getBeanDefinition(definitionName);
if (listenerClassName.equals(definition.getBeanClassName())) {
if (className.equals(definition.getBeanClassName())) {
if (logger.isInfoEnabled()) {
logger.info(listenerClassName + " is already registered and will be used");
logger.info(className + " is already registered and will be used");
}
return;
}
}
RootBeanDefinition beanDefinition = new RootBeanDefinition(listenerClassName);
RootBeanDefinition beanDefinition = new RootBeanDefinition(className);
beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
BeanDefinitionReaderUtils.registerWithGeneratedName(beanDefinition, registry);
}
private void registerIdGeneratorConfigurer(BeanDefinitionRegistry registry) {
registerInfrastructureBean(registry, "org.springframework.integration.config.IdGeneratorConfigurer");
}
/**
* Register a null channel in the given BeanDefinitionRegistry. The bean name is defined by the constant
* {@link IntegrationContextUtils#NULL_CHANNEL_BEAN_NAME}.

View File

@@ -35,7 +35,7 @@ import org.springframework.util.xml.DomUtils;
/**
* Parser for the &lt;publishing-interceptor&gt; element.
*
*
* @author Oleg Zhurakousky
* @author Mark Fisher
* @since 2.0
@@ -52,14 +52,16 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
if (mappings.get("headers") != null) {
spelSourceBuilder.addPropertyValue("headerExpressionMap", mappings.get("headers"));
}
BeanDefinitionBuilder chResolverBuilder = BeanDefinitionBuilder.genericBeanDefinition(
"org.springframework.integration.support.channel.BeanFactoryChannelResolver");
"org.springframework.messaging.core.BeanFactoryMessageChannelDestinationResolver");
if (mappings.get("channels") != null){
spelSourceBuilder.addPropertyValue("channelMap", mappings.get("channels"));
}
String chResolverName =
String chResolverName =
BeanDefinitionReaderUtils.registerWithGeneratedName(chResolverBuilder.getBeanDefinition(), parserContext.getRegistry());
String defaultChannel = StringUtils.hasText(element.getAttribute("default-channel")) ?
String defaultChannel = StringUtils.hasText(element.getAttribute("default-channel")) ?
element.getAttribute("default-channel") : IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME;
rootBuilder.addConstructorArgValue(spelSourceBuilder.getBeanDefinition());
rootBuilder.addPropertyReference("channelResolver", chResolverName);
@@ -74,12 +76,12 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
Map<String, Map<String, String>> headersExpressionMap = new HashMap<String, Map<String, String>>();
Map<String, String> channelMap = new HashMap<String, String>();
ManagedMap<String, Object> resolvableChannelMap = new ManagedMap<String, Object>();
if (mappings != null && mappings.size() > 0) {
if (mappings != null && mappings.size() > 0) {
for (Element mapping : mappings) {
// set payloadMap
String methodPattern = StringUtils.hasText(mapping.getAttribute("pattern")) ?
String methodPattern = StringUtils.hasText(mapping.getAttribute("pattern")) ?
mapping.getAttribute("pattern") : "*";
String payloadExpression = StringUtils.hasText(mapping.getAttribute("payload")) ?
String payloadExpression = StringUtils.hasText(mapping.getAttribute("payload")) ?
mapping.getAttribute("payload") : "#return";
payloadExpressionMap.put(methodPattern, payloadExpression);
@@ -117,7 +119,7 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
channelMap.put(methodPattern, channel);
resolvableChannelMap.put(channel, new RuntimeBeanReference(channel));
}
}
}
if (payloadExpressionMap.size() == 0) {
payloadExpressionMap.put("*", "#return");
}

View File

@@ -20,7 +20,8 @@ import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.EiMessageHeaderAccessor;
import org.springframework.messaging.MessageHeaders;
import org.springframework.util.StringUtils;
/**
@@ -29,7 +30,7 @@ import org.springframework.util.StringUtils;
* configurable {@link MessageHeaders}, such as 'reply-channel', 'priority',
* and 'correlation-id'. It will also accept custom header values (or bean
* references) if provided as 'header' sub-elements.
*
*
* @author Mark Fisher
* @author Oleg Zhurakousky
*/
@@ -38,9 +39,9 @@ public class StandardHeaderEnricherParser extends HeaderEnricherParserSupport {
public StandardHeaderEnricherParser() {
this.addElementToHeaderMapping("reply-channel", MessageHeaders.REPLY_CHANNEL);
this.addElementToHeaderMapping("error-channel", MessageHeaders.ERROR_CHANNEL);
this.addElementToHeaderMapping("correlation-id", MessageHeaders.CORRELATION_ID);
this.addElementToHeaderMapping("expiration-date", MessageHeaders.EXPIRATION_DATE, Long.class);
this.addElementToHeaderMapping("priority", MessageHeaders.PRIORITY, Integer.class);
this.addElementToHeaderMapping("correlation-id", EiMessageHeaderAccessor.CORRELATION_ID);
this.addElementToHeaderMapping("expiration-date", EiMessageHeaderAccessor.EXPIRATION_DATE, Long.class);
this.addElementToHeaderMapping("priority", EiMessageHeaderAccessor.PRIORITY, Integer.class);
}
@Override

View File

@@ -1,4 +1,4 @@
/**
* Provides supporting XML-based configuration - parsers, namespace handlers.
*/
package org.springframework.integration.config.xml;
package org.springframework.integration.config.xml;

View File

@@ -19,8 +19,8 @@ package org.springframework.integration.context;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.core.convert.ConversionService;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.store.metadata.MetadataStore;
import org.springframework.messaging.MessageChannel;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.util.Assert;

View File

@@ -1,4 +1,4 @@
/**
* Provides classes relating to application context configuration.
*/
package org.springframework.integration.context;
package org.springframework.integration.context;

View File

@@ -18,8 +18,10 @@ package org.springframework.integration.core;
import java.util.concurrent.Future;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.core.MessagePostProcessor;
/**
* @author Mark Fisher

View File

@@ -23,15 +23,18 @@ import java.util.concurrent.Future;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.task.support.TaskExecutorAdapter;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.PollableChannel;
import org.springframework.messaging.core.GenericMessagingTemplate;
import org.springframework.messaging.core.MessagePostProcessor;
import org.springframework.util.Assert;
/**
* @author Mark Fisher
* @since 2.0
*/
public class AsyncMessagingTemplate extends MessagingTemplate implements AsyncMessagingOperations {
public class AsyncMessagingTemplate extends GenericMessagingTemplate implements AsyncMessagingOperations {
private volatile AsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();

View File

@@ -1,50 +0,0 @@
/*
* Copyright 2002-2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.core;
import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
/**
* Base interface for any component that handles Messages.
*
* @author Mark Fisher
* @author Iwein Fuld
*/
public interface MessageHandler {
/**
* Handles the message if possible. If the handler cannot deal with the
* message this will result in a <code>MessageRejectedException</code> e.g.
* in case of a Selective Consumer. When a consumer tries to handle a
* message, but fails to do so, a <code>MessageHandlingException</code> is
* thrown. In the last case it is recommended to treat the message as tainted
* and go into an error scenario.
* <p>
* When the handling results in a failure of another message being sent
* (e.g. a "reply" message), that failure will trigger a
* <code>MessageDeliveryException</code>.
*
* @param message the message to be handled
* @throws org.springframework.integration.MessageRejectedException if the handler doesn't accept the message
* @throws org.springframework.integration.MessageHandlingException when something fails during the handling
* @throws org.springframework.integration.MessageDeliveryException when this handler failed to deliver the
* reply related to the handling of the message
*/
void handleMessage(Message<?> message) throws MessagingException;
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.core;
import org.springframework.integration.Message;
/**
* To be used with MessagingTemplate's send method that converts an object to a message.
* It allows for further modification of the message after it has been processed
* by the converter.
*
* <p>This is often implemented as an anonymous class within a method implementation.
*
* @author Mark Fisher
* @since 2.0
* @see MessagingTemplate#convertAndSend(String, Object, MessagePostProcessor)
* @see MessagingTemplate#convertAndSend(org.springframework.integration.MessageChannel, Object, MessagePostProcessor)
* @see org.springframework.integration.support.converter.MessageConverter
*/
public interface MessagePostProcessor {
/**
* Apply a MessagePostProcessor to the message. The returned message is
* typically a modified version of the original.
* @param message the message returned from the MessageConverter
* @return the modified version of the Message
*/
Message<?> postProcessMessage(Message<?> message);
}

View File

@@ -16,7 +16,7 @@
package org.springframework.integration.core;
import org.springframework.integration.MessageChannel;
import org.springframework.messaging.MessageChannel;
/**
* Base interface for any component that is capable of sending

View File

@@ -16,7 +16,7 @@
package org.springframework.integration.core;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
/**
* Strategy interface for message selection.

View File

@@ -16,7 +16,7 @@
package org.springframework.integration.core;
import org.springframework.integration.Message;
import org.springframework.messaging.Message;
/**
* Base interface for any source of {@link Message Messages} that can be polled.

View File

@@ -1,335 +0,0 @@
/*
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.core;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.MessagingException;
import org.springframework.integration.support.channel.ChannelResolutionException;
import org.springframework.integration.support.channel.ChannelResolver;
/**
* Specifies a basic set of messaging operations.
*
* <p>Implemented by {@link MessagingTemplate}. Even though most calling code
* will depend on the template directly (e.g. to access setter methods), this
* interface is a useful option to enhance testability, as it can easily be mocked
* or stubbed.
*
* <p>Defines a variety of methods for sending and receiving {@link Message}s
* across {@link MessageChannel}s including the use of converters where necessary.
* Convenience methods also support sending and receiving based on channel name,
* where the template will delegate to its {@link ChannelResolver} to locate the
* actual {@link MessageChannel} instance.
*
* @author Mark Fisher
* @since 2.0
* @see MessagingTemplate
*/
public interface MessagingOperations {
//-------------------------------------------------------------------------
// Convenience methods for sending messages
//-------------------------------------------------------------------------
/**
* Send a message to the default channel.
* <p>This will only work with a default channel specified!
* @param message the message to send
* @throws MessagingException if an error occurs during message sending
*/
<P> void send(Message<P> message) throws MessagingException;
/**
* Send a message to the specified channel.
* @param channel the channel to which the message will be sent
* @param message the message to send
* @throws MessagingException if an error occurs during message sending
*/
<P> void send(MessageChannel channel, Message<P> message) throws MessagingException;
/**
* Send a message to the specified channel.
* @param channelName the name of the channel to which the message will be sent
* (to be resolved to an actual channel by a ChannelResolver)
* @param message the message to send
* @throws ChannelResolutionException if the channel name cannot be resolved
* @throws MessagingException if an error occurs during message sending
*/
<P> void send(String channelName, Message<P> message) throws MessagingException;
//-------------------------------------------------------------------------
// Convenience methods for sending auto-converted messages
//-------------------------------------------------------------------------
/**
* Send the given object to the default channel, converting the object
* to a message with a configured MessageConverter.
* <p>This will only work with a default channel specified!
* @param message the object to convert to a message
* @throws MessagingException if an error occurs
*/
<T> void convertAndSend(T message) throws MessagingException;
/**
* Send the given object to the specified channel, converting the object
* to a message with a configured MessageConverter.
* @param channel the channel to send this message to
* @param message the object to convert to a message
* @throws MessagingException if an error occurs
*/
<T> void convertAndSend(MessageChannel channel, T message) throws MessagingException;
/**
* Send the given object to the specified channel, converting the object
* to a message with a configured MessageConverter.
* @param channelName the name of the channel to send this message to
* (to be resolved to an actual channel by a ChannelResolver)
* @param message the object to convert to a message
* @throws MessagingException if an error occurs
*/
<T> void convertAndSend(String channelName, T message) throws MessagingException;
/**
* Send the given object to the default channel, converting the object
* to a message with a configured MessageConverter. The MessagePostProcessor
* callback allows for modification of the message after conversion.
* <p>This will only work with a default channel specified!
* @param message the object to convert to a message
* @param postProcessor the callback to modify the message
* @throws MessagingException if an error occurs
*/
<T> void convertAndSend(T message, MessagePostProcessor postProcessor) throws MessagingException;
/**
* Send the given object to the specified channel, converting the object
* to a message with a configured MessageConverter. The MessagePostProcessor
* callback allows for modification of the message after conversion.
* @param channel the channel to which the message will be sent
* @param message the object to convert to a message
* @param postProcessor the callback to modify the message
* @throws MessagingException if an error occurs
*/
<T> void convertAndSend(MessageChannel channel, T message, MessagePostProcessor postProcessor) throws MessagingException;
/**
* Send the given object to the specified channel, converting the object
* to a message with a configured MessageConverter. The MessagePostProcessor
* callback allows for modification of the message after conversion.
* @param channelName the name of the channel to which the message will be sent
* (to be resolved to an actual channel by a ChannelResolver)
* @param message the object to convert to a message
* @param postProcessor the callback to modify the message
* @throws MessagingException if an error occurs
*/
<T> void convertAndSend(String channelName, T message, MessagePostProcessor postProcessor) throws MessagingException;
//-------------------------------------------------------------------------
// Convenience methods for receiving messages
//-------------------------------------------------------------------------
/**
* Receive a message synchronously from the default channel, but only
* wait up to a specified time for delivery.
* <p>This method should be used carefully, since it will block the thread
* until the message becomes available or until the timeout value is exceeded.
* <p>This will only work with a default channel specified!
* @return the message received from the default channel or <code>null</code> if the timeout expires
* @throws MessagingException if an error occurs during message reception
*/
<P> Message<P> receive() throws MessagingException;
/**
* Receive a message synchronously from the specified channel, but only
* wait up to a specified time for delivery.
* <p>This method should be used carefully, since it will block the thread
* until the message becomes available or until the timeout value is exceeded.
* @param channel the channel from which a message should be received
* @return the message received from the channel or <code>null</code> if the timeout expires
* @throws MessagingException if an error occurs during message reception
*/
<P> Message<P> receive(PollableChannel channel) throws MessagingException;
/**
* Receive a message synchronously from the specified channel, but only
* wait up to a specified time for delivery.
* <p>This method should be used carefully, since it will block the thread
* until the message becomes available or until the timeout value is exceeded.
* @param channelName the name of the channel from which a message should be received
* (to be resolved to an actual channel by a ChannelResolver)
* @return the message received from the channel or <code>null</code> if the timeout expires
* @throws ChannelResolutionException if the channel name cannot be resolved
* @throws MessagingException if an error occurs during message reception
*/
<P> Message<P> receive(String channelName) throws MessagingException;
//-------------------------------------------------------------------------
// Convenience methods for receiving auto-converted messages
//-------------------------------------------------------------------------
/**
* Receive a message synchronously from the default channel, but only
* wait up to a specified time for delivery. Convert the message into an
* object with a configured MessageConverter.
* <p>This method should be used carefully, since it will block the thread
* until the message becomes available or until the timeout value is exceeded.
* <p>This will only work with a default channel specified!
* @return the message received from the channel or <code>null</code> if the timeout expires.
* @throws MessagingException if an error occurs during message reception
*/
Object receiveAndConvert() throws MessagingException;
/**
* Receive a message synchronously from the specified channel, but only
* wait up to a specified time for delivery. Convert the message into an
* object with a configured MessageConverter.
* <p>This method should be used carefully, since it will block the thread
* until the message becomes available or until the timeout value is exceeded.
* @param channel the channel from which a message should be received
* @return the message received from the channel or <code>null</code> if the timeout expires.
* @throws MessagingException if an error occurs during message reception
*/
Object receiveAndConvert(PollableChannel channel) throws MessagingException;
/**
* Receive a message synchronously from the specified channel, but only
* wait up to a specified time for delivery. Convert the message into an
* object with a configured MessageConverter.
* <p>This method should be used carefully, since it will block the thread
* until the message becomes available or until the timeout value is exceeded.
* @param channelName the name of the channel from which a message should be received
* (to be resolved to an actual channel by a ChannelResolver)
* @return the message received from the channel or <code>null</code> if the timeout expires.
* @throws MessagingException if an error occurs during message reception
*/
Object receiveAndConvert(String channelName) throws MessagingException;
//-------------------------------------------------------------------------
// Convenience methods for sending request and receiving reply messages
//-------------------------------------------------------------------------
/**
* Send a message to the default channel and receive a reply.
* <p>This will only work with a default channel specified!
* @param requestMessage the message to send
* @return the reply Message if received within the receive timeout.
* @throws MessagingException if an error occurs
*/
Message<?> sendAndReceive(Message<?> requestMessage);
/**
* Send a message to the specified channel and receive a reply.
* @param channel the channel to which the request Message will be sent
* @param requestMessage the message to send
* @return the reply Message if received within the receive timeout.
* @throws MessagingException if an error occurs
*/
Message<?> sendAndReceive(MessageChannel channel, Message<?> requestMessage);
/**
* Send a message to the specified channel and receive a reply.
* @param channelName the name of the channel to which the request Message will be sent
* (to be resolved to an actual channel by a ChannelResolver)
* @param requestMessage the message to send
* @return the reply Message if received within the receive timeout.
* @throws ChannelResolutionException if the channel name cannot be resolved
* @throws MessagingException if an error occurs
*/
Message<?> sendAndReceive(String channelName, Message<?> requestMessage);
/**
* Send the given request object to the default channel, converting the object
* to a message with a configured MessageConverter. If a reply Message is
* received within the receive timeout, it will be converted and returned.
* <p>This will only work with a default channel specified!
* @param request the object to convert to a request message
* @return the result of converting the reply Message
* @throws MessagingException if an error occurs
*/
Object convertSendAndReceive(Object request);
/**
* Send the given request object to the specified channel, converting the object
* to a message with a configured MessageConverter. If a reply Message is
* received within the receive timeout, it will be converted and returned.
* @param channel the channel to which the request message will be sent
* @param request the object to convert to a request message
* @return the result of converting the reply Message
* @throws MessagingException if an error occurs
*/
Object convertSendAndReceive(MessageChannel channel, Object request);
/**
* Send the given request object to the specified channel, converting the object
* to a message with a configured MessageConverter. If a reply Message is
* received within the receive timeout, it will be converted and returned.
* @param channelName the name of the channel to which the request message will be sent
* (to be resolved to an actual channel by a ChannelResolver)
* @param request the object to convert to a request message
* @return the result of converting the reply Message
* @throws MessagingException if an error occurs
*/
Object convertSendAndReceive(String channelName, Object request);
/**
* Send the given request object to the default channel, converting the object
* to a message with a configured MessageConverter. The MessagePostProcessor
* callback allows for modification of the request message after conversion.
* If a reply Message is received within the receive timeout, it will be
* converted and returned.
* <p>This will only work with a default channel specified!
* @param request the object to convert to a request message
* @param requestPostProcessor the callback to modify the request message
* @return the result of converting the reply Message
* @throws MessagingException if an error occurs
*/
Object convertSendAndReceive(Object request, MessagePostProcessor requestPostProcessor);
/**
* Send the given request object to the specified channel, converting the object
* to a message with a configured MessageConverter. The MessagePostProcessor
* callback allows for modification of the request message after conversion.
* If a reply Message is received within the receive timeout, it will be
* converted and returned.
* @param channel the channel to which the request message will be sent
* @param request the object to convert to a request message
* @param requestPostProcessor the callback to modify the request message
* @return the result of converting the reply Message
* @throws MessagingException if an error occurs
*/
Object convertSendAndReceive(MessageChannel channel, Object request, MessagePostProcessor requestPostProcessor);
/**
* Send the given request object to the specified channel, converting the object
* to a message with a configured MessageConverter. The MessagePostProcessor
* callback allows for modification of the request message after conversion.
* If a reply Message is received within the receive timeout, it will be
* converted and returned.
* @param channelName the name of the channel to which the request message will be sent
* (to be resolved to an actual channel by a ChannelResolver)
* @param request the object to convert to a request message
* @param requestPostProcessor the callback to modify the request message
* @return the result of converting the reply Message
* @throws MessagingException if an error occurs
*/
Object convertSendAndReceive(String channelName, Object request, MessagePostProcessor requestPostProcessor);
}

Some files were not shown because too many files have changed in this diff Show More