Removed the registerChannels() method that was being invoked after receiving the ApplicationContext refresh event. Channels are retrieved on demand from the ApplicationContext.

This commit is contained in:
Mark Fisher
2008-10-09 15:19:27 +00:00
parent d60e648684
commit b8e03f05c0

View File

@@ -104,23 +104,6 @@ public class DefaultMessageBus implements MessageBus, ApplicationContextAware, A
this.autoStartup = autoStartup;
}
@SuppressWarnings("unchecked")
private void registerChannels(ApplicationContext context) {
Map<String, MessageChannel> channelBeans = (Map<String, MessageChannel>) context
.getBeansOfType(MessageChannel.class);
for (Map.Entry<String, MessageChannel> entry : channelBeans.entrySet()) {
String channelName = entry.getKey();
MessageChannel previousChannel = this.lookupChannel(channelName);
if (previousChannel == null) {
this.registerChannel(entry.getValue());
}
else if (!previousChannel.equals(entry.getValue())) {
throw new ConfigurationException("A different channel instance has already "
+ "been registered with the name '" + channelName + "'.");
}
}
}
@SuppressWarnings("unchecked")
private void registerGateways(ApplicationContext context) {
Map<String, MessagingGateway> gatewayBeans = (Map<String, MessagingGateway>) context
@@ -318,7 +301,6 @@ public class DefaultMessageBus implements MessageBus, ApplicationContextAware, A
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ContextRefreshedEvent) {
ApplicationContext context = ((ContextRefreshedEvent) event).getApplicationContext();
this.registerChannels(context);
this.registerGateways(context);
if (this.autoStartup) {
this.start();