use of org.springframework.integration.handler.BridgeHandler in project spring-integration by spring-projects.
the class IntegrationFlowDefinition method route.
private <R extends AbstractMessageRouter, S extends AbstractRouterSpec<S, R>> B route(S routerSpec, Consumer<S> routerConfigurer) {
if (routerConfigurer != null) {
routerConfigurer.accept(routerSpec);
}
BridgeHandler bridgeHandler = new BridgeHandler();
boolean registerSubflowBridge = false;
Map<Object, String> componentsToRegister = null;
Map<Object, String> routerComponents = routerSpec.getComponentsToRegister();
if (routerComponents != null) {
componentsToRegister = new LinkedHashMap<>(routerComponents);
routerComponents.clear();
}
register(routerSpec, null);
if (!CollectionUtils.isEmpty(componentsToRegister)) {
for (Map.Entry<Object, String> entry : componentsToRegister.entrySet()) {
Object component = entry.getKey();
if (component instanceof IntegrationFlowDefinition) {
IntegrationFlowDefinition<?> flowBuilder = (IntegrationFlowDefinition<?>) component;
if (flowBuilder.isOutputChannelRequired()) {
registerSubflowBridge = true;
flowBuilder.channel(new FixedSubscriberChannel(bridgeHandler));
}
addComponent(flowBuilder.get());
} else {
this.integrationComponents.put(component, entry.getValue());
}
}
}
if (routerSpec.isDefaultToParentFlow()) {
routerSpec.defaultOutputChannel(new FixedSubscriberChannel(bridgeHandler));
registerSubflowBridge = true;
}
if (registerSubflowBridge) {
this.currentComponent = null;
handle(bridgeHandler);
}
return _this();
}
Aggregations