From e06c0e2927354bfef0f8ab083c6e00b3550e2169 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Thu, 2 Feb 2017 18:18:10 -0500 Subject: [PATCH] Add convenient IntegrationFlowDefinition.bridge() To avoid confusing `.bridge(null)` in the end of flow for replying to the gateway on top introduce simple `.bridge()` with just delegation to the `.bridge(null)` with the same result as before --- .../dsl/IntegrationFlowDefinition.java | 17 +++++++++++++---- .../dsl/flowservices/FlowServiceTests.java | 2 +- .../dsl/manualflow/ManualFlowTests.java | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java index 13b076bc66..83d7891a83 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowDefinition.java @@ -210,7 +210,7 @@ public abstract class IntegrationFlowDefinition B handle(H messageHandler, Consumer> endpointConfigurer) { Assert.notNull(messageHandler, "'messageHandler' must not be null"); - return this.register(new GenericEndpointSpec(messageHandler), endpointConfigurer); + return this.register(new GenericEndpointSpec<>(messageHandler), endpointConfigurer); + } + + /** + * Populate a {@link BridgeHandler} to the current integration flow position. + * @return the current {@link IntegrationFlowDefinition}. + * @see #bridge(Consumer) + */ + public B bridge() { + return bridge(null); } /** @@ -1120,7 +1129,7 @@ public abstract class IntegrationFlowDefinition> endpointConfigurer) { - return this.register(new GenericEndpointSpec(new BridgeHandler()), endpointConfigurer); + return register(new GenericEndpointSpec<>(new BridgeHandler()), endpointConfigurer); } /** @@ -1191,7 +1200,7 @@ public abstract class IntegrationFlowDefinition f.gateway("processChannel", g -> g.replyChannel("replyChannel")) .log() - .bridge(null); + .bridge(); } @Bean diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/manualflow/ManualFlowTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/manualflow/ManualFlowTests.java index 880bef710e..3b979a8725 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dsl/manualflow/ManualFlowTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/manualflow/ManualFlowTests.java @@ -136,7 +136,7 @@ public class ManualFlowTests { @Override public void configure(IntegrationFlowDefinition flow) { - flow.bridge(null); + flow.bridge(); } } @@ -283,7 +283,7 @@ public class ManualFlowTests { @Bean @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE) public IntegrationFlow wrongScopeFlow() { - return flow -> flow.bridge(null); + return IntegrationFlowDefinition::bridge; } }