From 3cb0b360caba5b14a6aebca9a8e2463c988d9411 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Tue, 9 Mar 2010 20:59:36 +0000 Subject: [PATCH] INT-975 CorrelatingMessageHandler now implements the MessageProducer interface. --- .../aggregator/CorrelatingMessageHandler.java | 14 +++++++++----- .../integration/handler/MessageHandlerChain.java | 3 +-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/CorrelatingMessageHandler.java b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/CorrelatingMessageHandler.java index 63eb5936b9..35da7a8f0b 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/CorrelatingMessageHandler.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/aggregator/CorrelatingMessageHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2009 the original author or authors. + * 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. @@ -28,6 +28,7 @@ import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.core.Message; import org.springframework.integration.core.MessageChannel; import org.springframework.integration.core.MessageHeaders; +import org.springframework.integration.core.MessageProducer; import org.springframework.integration.handler.AbstractMessageHandler; import org.springframework.integration.message.MessageBuilder; import org.springframework.integration.store.MessageStore; @@ -45,16 +46,19 @@ import java.util.concurrent.locks.ReentrantLock; * groups of messages that can be completed in batches. It is useful for aggregating, resequencing, or custom * implementations requiring correlation. *

- * To customize this handler inject {@link org.springframework.integration.aggregator.CorrelationStrategy}, {@link - * org.springframework.integration.aggregator.CompletionStrategy} and {@link org.springframework.integration.aggregator.MessageGroupProcessor} - * implementations as you require. + * To customize this handler inject {@link org.springframework.integration.aggregator.CorrelationStrategy}, + * {@link org.springframework.integration.aggregator.CompletionStrategy}, and + * {@link org.springframework.integration.aggregator.MessageGroupProcessor} implementations as you require. *

* By default the CorrelationStrategy will be a HeaderAttributeCorrelationStrategy and the CompletionStrategy will be a * SequenceSizeCompletionStrategy. * * @author Iwein Fuld + * @since 2.0 */ -public class CorrelatingMessageHandler extends AbstractMessageHandler implements Lifecycle, BeanFactoryAware { +public class CorrelatingMessageHandler extends AbstractMessageHandler + implements MessageProducer, Lifecycle, BeanFactoryAware { + private static final Log logger = LogFactory.getLog(CorrelatingMessageHandler.class); public static final String COMPONENT_TYPE_LABEL = "aggregator"; diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageHandlerChain.java b/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageHandlerChain.java index 4c8b5be27c..9d68eed546 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageHandlerChain.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/handler/MessageHandlerChain.java @@ -133,9 +133,8 @@ public class MessageHandlerChain implements MessageHandler, MessageProducer, Ord private void configureChain() { List handlers = this.handlers; for (int i = 0; i < handlers.size(); i++) { - boolean last = (i == handlers.size() - 1); MessageHandler handler = handlers.get(i); - if (!last) { + if (i < handlers.size() - 1) { // not the last handler Assert.isTrue(handler instanceof MessageProducer, "All handlers except for " + "the last one in the chain must implement the MessageProducer interface."); final MessageHandler nextHandler = handlers.get(i + 1);