From 0194945ec3de8b20893dc17152db83c09cd9b8df Mon Sep 17 00:00:00 2001 From: Mark Fisher Date: Mon, 7 Jul 2008 00:59:20 +0000 Subject: [PATCH] ConcurrencyInterceptor implements ChannelRegistryAware instead of MessageBusAware (removes a tangle). --- .../integration/bus/MessageBus.java | 3 --- .../integration/channel/ChannelRegistry.java | 3 +++ .../interceptor/ConcurrencyInterceptor.java | 15 ++++++++------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/bus/MessageBus.java b/org.springframework.integration/src/main/java/org/springframework/integration/bus/MessageBus.java index 483c1501f4..de72ee50c7 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/bus/MessageBus.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/bus/MessageBus.java @@ -33,9 +33,6 @@ import org.springframework.integration.scheduling.Schedule; */ public interface MessageBus extends ChannelRegistry, EndpointRegistry, Lifecycle, DisposableBean { - static final String ERROR_CHANNEL_NAME = "errorChannel"; - - MessageChannel getErrorChannel(); ChannelFactory getChannelFactory(); diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/channel/ChannelRegistry.java b/org.springframework.integration/src/main/java/org/springframework/integration/channel/ChannelRegistry.java index c5424f00c5..914d1166e7 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/channel/ChannelRegistry.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/channel/ChannelRegistry.java @@ -23,6 +23,9 @@ package org.springframework.integration.channel; */ public interface ChannelRegistry { + static final String ERROR_CHANNEL_NAME = "errorChannel"; + + void registerChannel(String name, MessageChannel channel); MessageChannel unregisterChannel(String name); diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/interceptor/ConcurrencyInterceptor.java b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/interceptor/ConcurrencyInterceptor.java index bcbbfb9fab..2e635d7050 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/interceptor/ConcurrencyInterceptor.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/endpoint/interceptor/ConcurrencyInterceptor.java @@ -31,8 +31,8 @@ import org.springframework.beans.factory.DisposableBean; import org.springframework.beans.factory.InitializingBean; import org.springframework.context.Lifecycle; import org.springframework.core.task.TaskExecutor; -import org.springframework.integration.bus.MessageBus; -import org.springframework.integration.bus.MessageBusAware; +import org.springframework.integration.channel.ChannelRegistry; +import org.springframework.integration.channel.ChannelRegistryAware; import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.endpoint.ConcurrencyPolicy; import org.springframework.integration.endpoint.EndpointInterceptor; @@ -52,7 +52,7 @@ import org.springframework.util.Assert; * @author Mark Fisher */ public class ConcurrencyInterceptor extends EndpointInterceptorAdapter - implements DisposableBean, InitializingBean, MessageBusAware { + implements DisposableBean, InitializingBean, ChannelRegistryAware { private final Log logger = LogFactory.getLog(this.getClass()); @@ -60,7 +60,7 @@ public class ConcurrencyInterceptor extends EndpointInterceptorAdapter private volatile ErrorHandler errorHandler; - private volatile MessageBus messageBus; + private volatile ChannelRegistry channelRegistry; public ConcurrencyInterceptor(TaskExecutor executor) { @@ -87,13 +87,14 @@ public class ConcurrencyInterceptor extends EndpointInterceptorAdapter this.errorHandler = errorHandler; } - public void setMessageBus(MessageBus messageBus) { - this.messageBus = messageBus; + public void setChannelRegistry(ChannelRegistry channelRegistry) { + this.channelRegistry = channelRegistry; } public void afterPropertiesSet() throws Exception { if (this.errorHandler == null) { - MessageChannel errorChannel = this.messageBus.getErrorChannel(); + MessageChannel errorChannel = this.channelRegistry.lookupChannel( + ChannelRegistry.ERROR_CHANNEL_NAME); if (errorChannel != null) { this.errorHandler = new MessagePublishingErrorHandler(errorChannel); }