ConcurrencyInterceptor implements ChannelRegistryAware instead of MessageBusAware (removes a tangle).

This commit is contained in:
Mark Fisher
2008-07-07 00:59:20 +00:00
parent 2c6f496ca7
commit 0194945ec3
3 changed files with 11 additions and 10 deletions

View File

@@ -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();

View File

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

View File

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