From f64fb54b34b7a5087aafa70641d861acba8b9d50 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Tue, 27 Jul 2010 13:30:38 +0000 Subject: [PATCH] reordered ctor args, handler comes first since handleMessage() is still the primary responsibility --- .../config/ConsumerEndpointFactoryBean.java | 15 +++++++-------- .../MessageHistoryAwareMessageHandler.java | 10 +++++----- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java b/spring-integration-core/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java index 7f3a4adc25..2de62c29f9 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/config/ConsumerEndpointFactoryBean.java @@ -101,15 +101,14 @@ public class ConsumerEndpointFactoryBean } public void afterPropertiesSet() throws Exception { - /* - * Will check if this.handler needs to be wrapped in MessageHistoryAwareMessageHandler. - * Such wrapping is only required if this.beanFactory contains bean of type MessageHistoryWriter.class - */ - Map historyWriters = BeanFactoryUtils.beansOfTypeIncludingAncestors((ListableBeanFactory)this.beanFactory, MessageHistoryWriter.class); - if (historyWriters.size() == 1){ + // Will check if this.handler needs to be wrapped in a MessageHistoryAwareMessageHandler. + // Such wrapping is only required if this.beanFactory contains a bean of type MessageHistoryWriter. + Map historyWriters = BeanFactoryUtils.beansOfTypeIncludingAncestors( + (ListableBeanFactory) this.beanFactory, MessageHistoryWriter.class); + if (historyWriters.size() == 1) { MessageHistoryWriter writer = historyWriters.values().iterator().next(); - if (!beanName.startsWith("org.springframework") && this.handler instanceof IntegrationObjectSupport){ - this.handler = new MessageHistoryAwareMessageHandler(writer, this.beanName, this.handler); + if (!this.beanName.startsWith("org.springframework") && this.handler instanceof IntegrationObjectSupport) { + this.handler = new MessageHistoryAwareMessageHandler(this.handler, writer, this.beanName); } } this.initializeEndpoint(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistoryAwareMessageHandler.java b/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistoryAwareMessageHandler.java index 4607734b2f..624b29cad1 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistoryAwareMessageHandler.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/history/MessageHistoryAwareMessageHandler.java @@ -33,11 +33,11 @@ import org.springframework.util.Assert; */ public class MessageHistoryAwareMessageHandler implements NamedComponent, MessageHandler, Ordered { - private MessageHandler targetHandler; + private final MessageHandler targetHandler; - private String componentName; + private final MessageHistoryWriter historyWriter; - private MessageHistoryWriter historyWriter; + private final String componentName; /** @@ -45,12 +45,12 @@ public class MessageHistoryAwareMessageHandler implements NamedComponent, Messag * @param endpointName * @param targetHandler */ - public MessageHistoryAwareMessageHandler(MessageHistoryWriter historyWriter, String endpointName, MessageHandler targetHandler) { + public MessageHistoryAwareMessageHandler(MessageHandler targetHandler, MessageHistoryWriter historyWriter, String endpointName) { Assert.notNull(targetHandler, "targetHandler must not be null"); Assert.notNull(historyWriter, "historyWriter must not be null"); + this.targetHandler = targetHandler; this.historyWriter = historyWriter; this.componentName = endpointName; - this.targetHandler = targetHandler; }