MessageBus now does a second pass to pick up any MessageChannel that has been provided between the setApplicationContext callback and the ContextRefreshedEvent (INT-270).

This commit is contained in:
Mark Fisher
2008-07-05 22:26:11 +00:00
parent 248209bf00
commit 9b787a0d5a

View File

@@ -173,7 +173,15 @@ public class MessageBus implements ChannelRegistry, EndpointRegistry,
Map<String, MessageChannel> channelBeans = (Map<String, MessageChannel>) context
.getBeansOfType(MessageChannel.class);
for (Map.Entry<String, MessageChannel> entry : channelBeans.entrySet()) {
this.registerChannel(entry.getKey(), entry.getValue());
String channelName = entry.getKey();
MessageChannel previousChannel = this.lookupChannel(channelName);
if (previousChannel == null) {
this.registerChannel(channelName, entry.getValue());
}
else if (!previousChannel.equals(entry.getValue())) {
throw new ConfigurationException("A different channel instance has already "
+ "been registered with the name '" + channelName + "'.");
}
}
}
@@ -455,6 +463,7 @@ public class MessageBus implements ChannelRegistry, EndpointRegistry,
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ContextRefreshedEvent) {
ApplicationContext context = ((ContextRefreshedEvent) event).getApplicationContext();
this.registerChannels(context);
this.registerEndpoints(context);
this.registerGateways(context);
if (this.configureAsyncEventMulticaster) {