From f31564dacb35e538cbc204b1af9e1f0fa99206e4 Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Fri, 17 Apr 2009 21:30:12 +0000 Subject: [PATCH] formatting only --- .../handler/MessageHandlerChain.java | 43 +++++++------------ 1 file changed, 16 insertions(+), 27 deletions(-) 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 9370a6e980..81ed6116d4 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 @@ -62,8 +62,7 @@ import org.springframework.util.Assert; * @author Mark Fisher * @author Iwein Fuld */ -public class MessageHandlerChain extends IntegrationObjectSupport implements - MessageHandler { +public class MessageHandlerChain extends IntegrationObjectSupport implements MessageHandler { private static final String OUTPUT_CHANNEL_PROPERTY = "outputChannel"; @@ -75,6 +74,7 @@ public class MessageHandlerChain extends IntegrationObjectSupport implements private final Object initializationMonitor = new Object(); + public void setHandlers(List handlers) { this.handlers = handlers; } @@ -86,9 +86,7 @@ public class MessageHandlerChain extends IntegrationObjectSupport implements public final void afterPropertiesSet() { synchronized (this.initializationMonitor) { if (!this.initialized) { - Assert - .notEmpty(this.handlers, - "handler list must not be empty"); + Assert.notEmpty(this.handlers, "handler list must not be empty"); this.configureChain(); this.initialized = true; } @@ -111,37 +109,31 @@ public class MessageHandlerChain extends IntegrationObjectSupport implements MessageHandler handler = handlers.get(i); PropertyAccessor accessor = new BeanWrapperImpl(handler); if (!first) { - EventDrivenConsumer consumer = new EventDrivenConsumer(channel, - handler); + EventDrivenConsumer consumer = new EventDrivenConsumer(channel, handler); consumer.start(); } if (!last) { channel = new DirectChannel(); channel.setBeanName("_" + this + ".channel#" + i); - Assert.notNull(accessor - .getPropertyType(OUTPUT_CHANNEL_PROPERTY), + Assert.notNull(accessor.getPropertyType(OUTPUT_CHANNEL_PROPERTY), "All handlers except for the last one in the chain must implement property '" - + OUTPUT_CHANNEL_PROPERTY - + "' of type 'MessageChannel'"); + + OUTPUT_CHANNEL_PROPERTY + "' of type 'MessageChannel'"); accessor.setPropertyValue(OUTPUT_CHANNEL_PROPERTY, channel); } else if (accessor.getPropertyType(OUTPUT_CHANNEL_PROPERTY) != null) { MessageChannel replyChannel = (this.outputChannel != null) ? this.outputChannel : new ReplyForwardingMessageChannel(); - accessor - .setPropertyValue(OUTPUT_CHANNEL_PROPERTY, replyChannel); + accessor.setPropertyValue(OUTPUT_CHANNEL_PROPERTY, replyChannel); } else { - Assert - .isNull( - this.outputChannel, - "An output channel was provided, but the final handler in the chain does not implement property '" - + OUTPUT_CHANNEL_PROPERTY - + "' of type 'MessageChannel'"); + Assert.isNull(this.outputChannel, + "An output channel was provided, but the final handler in the chain does not implement property '" + + OUTPUT_CHANNEL_PROPERTY + "' of type 'MessageChannel'"); } } } + private class ReplyForwardingMessageChannel implements MessageChannel { public String getName() { @@ -155,26 +147,23 @@ public class MessageHandlerChain extends IntegrationObjectSupport implements public boolean send(Message message, long timeout) { Object replyChannelHeader = message.getHeaders().getReplyChannel(); if (replyChannelHeader == null) { - throw new MessageHandlingException(message, - "no replyChannel header available"); + throw new MessageHandlingException(message, "no replyChannel header available"); } MessageChannel replyChannel = null; if (replyChannelHeader instanceof MessageChannel) { replyChannel = (MessageChannel) replyChannelHeader; } else if (replyChannelHeader instanceof String) { - Assert.notNull(getChannelResolver(), - "ChannelResolver is required"); - replyChannel = getChannelResolver().resolveChannelName( - (String) replyChannelHeader); + Assert.notNull(getChannelResolver(), "ChannelResolver is required"); + replyChannel = getChannelResolver().resolveChannelName((String) replyChannelHeader); } else { throw new MessageHandlingException(message, - "invalid replyChannel type [" - + replyChannelHeader.getClass() + "]"); + "invalid replyChannel type [" + replyChannelHeader.getClass() + "]"); } return (timeout >= 0) ? replyChannel.send(message, timeout) : replyChannel.send(message); } } + }