formatting only

This commit is contained in:
Mark Fisher
2009-04-17 21:30:12 +00:00
parent bde9178a1f
commit f31564dacb

View File

@@ -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<MessageHandler> 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);
}
}
}