diff --git a/org.springframework.integration/src/main/java/org/springframework/integration/bus/DefaultMessageBus.java b/org.springframework.integration/src/main/java/org/springframework/integration/bus/DefaultMessageBus.java index 93b16d04ac..2c9558fa0d 100644 --- a/org.springframework.integration/src/main/java/org/springframework/integration/bus/DefaultMessageBus.java +++ b/org.springframework.integration/src/main/java/org/springframework/integration/bus/DefaultMessageBus.java @@ -35,6 +35,7 @@ import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationListener; import org.springframework.context.Lifecycle; import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.integration.channel.ChannelRegistry; import org.springframework.integration.channel.ChannelRegistryAware; import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.channel.MessagePublishingErrorHandler; @@ -118,10 +119,6 @@ public class DefaultMessageBus implements MessageBus, ApplicationContextAware, A } } - public MessageChannel getErrorChannel() { - return this.lookupChannel(ERROR_CHANNEL_NAME); - } - public MessageChannel lookupChannel(String channelName) { Assert.notNull(this.applicationContext, "ApplicationContext must not be null"); if (this.applicationContext.containsBean(channelName)) { @@ -239,7 +236,8 @@ public class DefaultMessageBus implements MessageBus, ApplicationContextAware, A gateway.start(); } if (this.taskScheduler instanceof SimpleTaskScheduler) { - ((SimpleTaskScheduler) this.taskScheduler).setErrorHandler(new MessagePublishingErrorHandler(this.getErrorChannel())); + ((SimpleTaskScheduler) this.taskScheduler).setErrorHandler( + new MessagePublishingErrorHandler(this.lookupChannel(ChannelRegistry.ERROR_CHANNEL_NAME))); } this.taskScheduler.start(); } 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 156f16044a..5ac77995ba 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 @@ -18,7 +18,6 @@ package org.springframework.integration.bus; import org.springframework.context.Lifecycle; import org.springframework.integration.channel.ChannelRegistry; -import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.endpoint.MessageEndpoint; /** @@ -28,8 +27,6 @@ import org.springframework.integration.endpoint.MessageEndpoint; */ public interface MessageBus extends ChannelRegistry, Lifecycle { - MessageChannel getErrorChannel(); - void registerEndpoint(MessageEndpoint endpoint); } diff --git a/org.springframework.integration/src/test/java/org/springframework/integration/config/MessageBusParserTests.java b/org.springframework.integration/src/test/java/org/springframework/integration/config/MessageBusParserTests.java index 0211c0b741..4f9efe0e80 100644 --- a/org.springframework.integration/src/test/java/org/springframework/integration/config/MessageBusParserTests.java +++ b/org.springframework.integration/src/test/java/org/springframework/integration/config/MessageBusParserTests.java @@ -36,6 +36,8 @@ import org.springframework.integration.bus.MessageBusInterceptorTests; import org.springframework.integration.bus.TestMessageBusAwareImpl; import org.springframework.integration.bus.TestMessageBusStartInterceptor; import org.springframework.integration.bus.TestMessageBusStopInterceptor; +import org.springframework.integration.channel.ChannelRegistry; +import org.springframework.integration.channel.MessageChannel; import org.springframework.integration.config.xml.MessageBusParser; import org.springframework.integration.scheduling.TaskScheduler; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; @@ -52,7 +54,8 @@ public class MessageBusParserTests { "messageBusWithErrorChannel.xml", this.getClass()); DefaultMessageBus bus = (DefaultMessageBus) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME); bus.initialize(); - assertEquals(context.getBean("errorChannel"), bus.getErrorChannel()); + MessageChannel channel = bus.lookupChannel(ChannelRegistry.ERROR_CHANNEL_NAME); + assertEquals(context.getBean("errorChannel"), channel); } @Test @@ -61,7 +64,8 @@ public class MessageBusParserTests { "messageBusWithDefaults.xml", this.getClass()); DefaultMessageBus bus = (DefaultMessageBus) context.getBean(MessageBusParser.MESSAGE_BUS_BEAN_NAME); bus.initialize(); - assertNotNull("parser should have created a default error channel", bus.getErrorChannel()); + assertNotNull("parser should have created a default error channel", + bus.lookupChannel(ChannelRegistry.ERROR_CHANNEL_NAME)); } @Test