Polishing AggregateApplication namespace handling
This commit is contained in:
@@ -96,15 +96,12 @@ public class AggregateApplication {
|
||||
Class<?>[] apps, String args[][]) {
|
||||
for (int i = apps.length - 1; i >= 0; i--) {
|
||||
String appClassName = apps[i].getName();
|
||||
embedApp(parentContext, getNamespace(null, appClassName, i), apps[i])
|
||||
embedApp(parentContext, getNamespace(appClassName, i), apps[i])
|
||||
.run(args != null ? args[i] : new String[0]);
|
||||
}
|
||||
}
|
||||
|
||||
protected static String getNamespace(String namespace, String appClassName, int index) {
|
||||
if (namespace != null) {
|
||||
return namespace;
|
||||
}
|
||||
protected static String getNamespace(String appClassName, int index) {
|
||||
return appClassName + "_" + index;
|
||||
}
|
||||
|
||||
@@ -133,19 +130,15 @@ public class AggregateApplication {
|
||||
int i = 0;
|
||||
SubscribableChannel sharedChannel = null;
|
||||
for (Entry<Class<?>, String> appEntry : appsWithNamespace.entrySet()) {
|
||||
Class<?> app = appEntry.getKey();
|
||||
String namespace = appEntry.getValue();
|
||||
String appClassName = app.getName();
|
||||
if (i > 0) {
|
||||
sharedChannelRegistry.register(getNamespace(namespace, appClassName, i)
|
||||
+ "." + INPUT_CHANNEL_NAME, sharedChannel);
|
||||
sharedChannelRegistry.register(namespace + "." + INPUT_CHANNEL_NAME, sharedChannel);
|
||||
}
|
||||
sharedChannel = new DirectChannel();
|
||||
if (i < appsWithNamespace.size() - 1) {
|
||||
sharedChannelRegistry.register(getNamespace(namespace, appClassName, i)
|
||||
+ "." + OUTPUT_CHANNEL_NAME, sharedChannel);
|
||||
sharedChannelRegistry.register(namespace + "." + OUTPUT_CHANNEL_NAME, sharedChannel);
|
||||
}
|
||||
i ++;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,13 +121,15 @@ public class AggregateApplicationBuilder {
|
||||
for (int i = 0; i < apps.size(); i++) {
|
||||
AppConfigurer<?> appConfigurer = apps.get(i);
|
||||
Class<?> appToEmbed = appConfigurer.getApp();
|
||||
// Always update namespace before preparing SharedChannelRegistry
|
||||
if (appConfigurer.namespace == null) {
|
||||
appConfigurer.namespace = AggregateApplication.getNamespace(appConfigurer.getApp().getName(), i);
|
||||
}
|
||||
appsToEmbed.put(appToEmbed, appConfigurer.namespace);
|
||||
}
|
||||
AggregateApplication.prepareSharedChannelRegistry(sharedChannelRegistry, appsToEmbed);
|
||||
for (int i = apps.size() - 1; i >= 0; i--) {
|
||||
AppConfigurer<?> appConfigurer = apps.get(i);
|
||||
appConfigurer.namespace(AggregateApplication
|
||||
.getNamespace(appConfigurer.namespace, appConfigurer.getApp().getName(), i));
|
||||
appConfigurer.embed();
|
||||
}
|
||||
return parentContext;
|
||||
|
||||
Reference in New Issue
Block a user