Moved aggregator and splitter classes into separate packages (instead of 'router').

This commit is contained in:
Mark Fisher
2008-08-12 00:59:15 +00:00
parent c2e6be171d
commit f91ec6f48f
38 changed files with 77 additions and 69 deletions

View File

@@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.util.ArrayList;
import java.util.Collections;
@@ -22,6 +23,7 @@ import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.message.Message;
/**
@@ -51,7 +53,7 @@ public abstract class AbstractMessageBarrier implements MessageBarrier {
return this.timestamp;
}
protected boolean isComplete(){
protected boolean isComplete() {
return this.complete;
}
@@ -68,9 +70,9 @@ public abstract class AbstractMessageBarrier implements MessageBarrier {
}
return null;
}
addMessage(message);
this.complete = hasReceivedAllMessages();
return releaseAvailableMessages();
this.addMessage(message);
this.complete = this.hasReceivedAllMessages();
return this.releaseAvailableMessages();
}
finally {
this.lock.unlock();
@@ -86,14 +88,14 @@ public abstract class AbstractMessageBarrier implements MessageBarrier {
}
/**
* Subclasses will implement this method to indicate if all possible messages that could be received by
* a given barrier have already been received (e.g. all messages from a given sequence)
* Subclasses must implement this method to indicate if all possible messages that could be received by
* a given barrier have already been received (e.g. all messages from a given sequence).
*/
protected abstract boolean hasReceivedAllMessages();
/**
* Subclasses will implement this method to return the messages that can be released by this barrier, after
* Subclasses must implement this method to return the messages that can be released by this barrier after
* the receipt of a given message. It might be possible that a number of messages are released before the barrier
* has ended its work (partial release) and this depends completely on the implementation of the barrier.
* However, once hasReceivedAllMessages() is deemed true, only one call to releaseAvailableMessages() shall

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.util.List;
import java.util.Map;
@@ -28,6 +28,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.handler.MessageHandler;
@@ -39,9 +40,9 @@ import org.springframework.util.CollectionUtils;
/**
* Base class for {@link MessageBarrier}-based MessageHandlers.
* A {@link MessageHandler} implementation that waits for a group of
* {@link Message Messages} to arrive and process them together.
* Uses a {@link MessageBarrier} to store messages and to decide on how
* the messages can be released.
* {@link Message Messages} to arrive and processes them together.
* Uses a {@link MessageBarrier} to store messages and to decide how
* the messages should be released.
* <p>
* Each {@link Message} that is received by this handler will be associated with
* a group based upon the '<code>correlationId</code>' property of its
@@ -53,7 +54,7 @@ import org.springframework.util.CollectionUtils;
* The default value is 1 minute. If the timeout elapses prior to completion,
* then Messages with that timed-out 'correlationId' will be sent to the
* 'discardChannel' if provided.
*
*
* @author Mark Fisher
* @author Marius Bogoevici
*/
@@ -75,8 +76,8 @@ public abstract class AbstractMessageBarrierHandler implements MessageHandler, I
protected volatile long sendTimeout = DEFAULT_SEND_TIMEOUT;
protected final ConcurrentMap<Object, MessageBarrier> barriers
= new ConcurrentHashMap<Object, MessageBarrier>();
protected final ConcurrentMap<Object, MessageBarrier> barriers =
new ConcurrentHashMap<Object, MessageBarrier>();
private volatile long timeout = DEFAULT_TIMEOUT;
@@ -251,6 +252,7 @@ public abstract class AbstractMessageBarrierHandler implements MessageHandler, I
}
}
private class ReaperTask implements Runnable {
public void run() {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.util.List;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.util.List;

View File

@@ -14,11 +14,12 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.lang.reflect.Method;
import java.util.List;
import org.springframework.integration.handler.MessageListMethodAdapter;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router.config;
package org.springframework.integration.aggregator;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
@@ -27,9 +27,6 @@ import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.channel.ChannelRegistry;
import org.springframework.integration.handler.MessageHandler;
import org.springframework.integration.handler.config.AbstractMessageHandlerCreator;
import org.springframework.integration.router.AggregatingMessageHandler;
import org.springframework.integration.router.AggregatorAdapter;
import org.springframework.integration.router.CompletionStrategyAdapter;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.StringUtils;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.util.List;

View File

@@ -14,12 +14,13 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.lang.reflect.Method;
import java.util.List;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.handler.MessageListMethodAdapter;
import org.springframework.integration.message.Message;
/**

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.util.List;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.util.Comparator;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.util.ArrayList;
import java.util.Collections;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.util.List;
import java.util.concurrent.ScheduledExecutorService;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.util.List;

View File

@@ -22,7 +22,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.integration.router.AggregatingMessageHandler;
import org.springframework.integration.aggregator.AggregatingMessageHandler;
/**
* Indicates that a method is capable of aggregating messages.

View File

@@ -21,10 +21,10 @@ import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.integration.aggregator.AggregatingMessageHandler;
import org.springframework.integration.aggregator.AggregatorAdapter;
import org.springframework.integration.aggregator.CompletionStrategyAdapter;
import org.springframework.integration.handler.MessageHandler;
import org.springframework.integration.router.AggregatingMessageHandler;
import org.springframework.integration.router.AggregatorAdapter;
import org.springframework.integration.router.CompletionStrategyAdapter;
import org.springframework.util.StringUtils;
/**

View File

@@ -34,7 +34,6 @@ import org.springframework.integration.channel.config.RendezvousChannelParser;
import org.springframework.integration.channel.config.ThreadLocalChannelParser;
import org.springframework.integration.config.annotation.AnnotationDrivenParser;
import org.springframework.integration.gateway.config.GatewayParser;
import org.springframework.integration.router.config.ResequencerParser;
import org.springframework.util.ClassUtils;
/**

View File

@@ -14,17 +14,16 @@
* limitations under the License.
*/
package org.springframework.integration.router.config;
package org.springframework.integration.config;
import org.w3c.dom.Element;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
import org.springframework.integration.config.IntegrationNamespaceUtils;
import org.springframework.integration.router.ResequencingMessageHandler;
import org.springframework.integration.aggregator.ResequencingMessageHandler;
/**
* Parser for the &lt;resequencer&gt; tag.
* Parser for the &lt;resequencer&gt; element.
*
* @author Marius Bogoevici
*/

View File

@@ -29,6 +29,7 @@ import org.springframework.core.OrderComparator;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.annotation.Order;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.aggregator.AggregatorMessageHandlerCreator;
import org.springframework.integration.annotation.Aggregator;
import org.springframework.integration.annotation.Concurrency;
import org.springframework.integration.annotation.Handler;
@@ -45,10 +46,9 @@ import org.springframework.integration.handler.MessageHandler;
import org.springframework.integration.handler.MessageHandlerChain;
import org.springframework.integration.handler.config.DefaultMessageHandlerCreator;
import org.springframework.integration.handler.config.MessageHandlerCreator;
import org.springframework.integration.router.config.AggregatorMessageHandlerCreator;
import org.springframework.integration.router.config.RouterMessageHandlerCreator;
import org.springframework.integration.router.config.SplitterMessageHandlerCreator;
import org.springframework.integration.router.RouterMessageHandlerCreator;
import org.springframework.integration.scheduling.Schedule;
import org.springframework.integration.splitter.SplitterMessageHandlerCreator;
import org.springframework.integration.transformer.config.TransformerMessageHandlerCreator;
import org.springframework.util.StringUtils;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.handler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007 the original author or authors.
* Copyright 2002-2008 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.
@@ -14,14 +14,13 @@
* limitations under the License.
*/
package org.springframework.integration.router.config;
package org.springframework.integration.router;
import java.lang.reflect.Method;
import java.util.Map;
import org.springframework.integration.handler.MessageHandler;
import org.springframework.integration.handler.config.AbstractMessageHandlerCreator;
import org.springframework.integration.router.RouterMessageHandlerAdapter;
/**
* Creates a {@link MessageHandler} adapter for router methods.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router.config;
package org.springframework.integration.splitter;
import java.lang.reflect.Method;
import java.util.Map;
@@ -25,7 +25,6 @@ import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.handler.AbstractMessageHandlerAdapter;
import org.springframework.integration.handler.MessageHandler;
import org.springframework.integration.handler.config.AbstractMessageHandlerCreator;
import org.springframework.integration.splitter.SplitterMessageHandler;
/**
* Creates a {@link MessageHandler} adapter for splitter methods.

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -25,6 +25,8 @@ import java.util.List;
import org.junit.Test;
import org.springframework.integration.aggregator.AggregationBarrier;
import org.springframework.integration.aggregator.CompletionStrategy;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.StringMessage;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -25,6 +25,8 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.aggregator.Aggregator;
import org.springframework.integration.aggregator.AggregatorAdapter;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.lang.reflect.Method;
import java.util.ArrayList;
@@ -25,6 +25,9 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.springframework.integration.ConfigurationException;
import org.springframework.integration.aggregator.AggregatorAdapter;
import org.springframework.integration.aggregator.CompletionStrategy;
import org.springframework.integration.aggregator.CompletionStrategyAdapter;
import org.springframework.integration.message.GenericMessage;
import org.springframework.integration.message.Message;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import static org.junit.Assert.assertEquals;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -25,6 +25,7 @@ import static org.junit.Assert.assertNull;
import org.junit.Test;
import org.springframework.integration.aggregator.ResequencingMessageHandler;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.message.Message;

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.aggregator;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -24,6 +24,7 @@ import java.util.List;
import org.junit.Test;
import org.springframework.integration.aggregator.SequenceSizeCompletionStrategy;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageBuilder;

View File

@@ -28,14 +28,14 @@ import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.aggregator.AggregatingMessageHandler;
import org.springframework.integration.aggregator.CompletionStrategy;
import org.springframework.integration.aggregator.CompletionStrategyAdapter;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.endpoint.HandlerEndpoint;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageBuilder;
import org.springframework.integration.router.AggregatingMessageHandler;
import org.springframework.integration.router.CompletionStrategy;
import org.springframework.integration.router.CompletionStrategyAdapter;
import org.springframework.integration.util.MethodInvoker;
/**

View File

@@ -26,11 +26,11 @@ import org.junit.Test;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.aggregator.ResequencingMessageHandler;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageBuilder;
import org.springframework.integration.router.ResequencingMessageHandler;
/**
* @author Marius Bogoevici

View File

@@ -22,10 +22,10 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.springframework.integration.aggregator.Aggregator;
import org.springframework.integration.aggregator.MessageSequenceComparator;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.router.Aggregator;
import org.springframework.integration.router.MessageSequenceComparator;
/**
* @author Marius Bogoevici

View File

@@ -18,8 +18,8 @@ package org.springframework.integration.config;
import java.util.List;
import org.springframework.integration.aggregator.CompletionStrategy;
import org.springframework.integration.message.Message;
import org.springframework.integration.router.CompletionStrategy;
/**
* @author Marius Bogoevici

View File

@@ -28,13 +28,13 @@ import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.aggregator.AggregatingMessageHandler;
import org.springframework.integration.aggregator.CompletionStrategyAdapter;
import org.springframework.integration.aggregator.SequenceSizeCompletionStrategy;
import org.springframework.integration.bus.MessageBus;
import org.springframework.integration.config.MessageBusParser;
import org.springframework.integration.endpoint.SimpleEndpoint;
import org.springframework.integration.handler.MessageHandler;
import org.springframework.integration.router.AggregatingMessageHandler;
import org.springframework.integration.router.CompletionStrategyAdapter;
import org.springframework.integration.router.SequenceSizeCompletionStrategy;
/**
* @author Marius Bogoevici

View File

@@ -22,12 +22,12 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.springframework.integration.aggregator.MessageSequenceComparator;
import org.springframework.integration.annotation.Aggregator;
import org.springframework.integration.annotation.CompletionStrategy;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.router.MessageSequenceComparator;
import org.springframework.stereotype.Component;
/**

View File

@@ -22,11 +22,11 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.springframework.integration.aggregator.MessageSequenceComparator;
import org.springframework.integration.annotation.Aggregator;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.router.MessageSequenceComparator;
import org.springframework.stereotype.Component;
/**

View File

@@ -22,11 +22,11 @@ import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.springframework.integration.aggregator.MessageSequenceComparator;
import org.springframework.integration.annotation.Aggregator;
import org.springframework.integration.annotation.MessageEndpoint;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.StringMessage;
import org.springframework.integration.router.MessageSequenceComparator;
import org.springframework.stereotype.Component;
/**

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.router;
package org.springframework.integration.splitter;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;