From 6eeec50b4afe749f7d06cb1a7e25ec0ca70eefb9 Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Tue, 8 Jan 2019 14:38:43 -0500 Subject: [PATCH] INT-4572: Add MessageProducer.setOutputChannelName JIRA: https://jira.spring.io/browse/INT-4572 * Add `setOutputChannelName()` contract into the `MessageProducer` to avoid proxy unwrapping and casting to the `MessageProducerSupport` --- .../integration/core/MessageProducer.java | 18 +++++++--- .../dsl/IntegrationFlowDefinition.java | 33 +++++-------------- .../endpoint/MessageProducerSupport.java | 1 + .../AbstractMessageProducingHandler.java | 1 + 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/core/MessageProducer.java b/spring-integration-core/src/main/java/org/springframework/integration/core/MessageProducer.java index dcb9ea59be..f39d6eff55 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/core/MessageProducer.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/core/MessageProducer.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,20 +20,30 @@ import org.springframework.messaging.MessageChannel; /** * Base interface for any component that is capable of sending - * Messages to a {@link MessageChannel}. + * messages to a {@link MessageChannel}. * * @author Mark Fisher + * @author Artem Bilan + * * @since 2.0 */ public interface MessageProducer { /** - * Specify the MessageChannel to which produced Messages should be sent. - * + * Specify the {@link MessageChannel} to which produced Messages should be sent. * @param outputChannel The output channel. */ void setOutputChannel(MessageChannel outputChannel); + /** + * Specify the bean name of the {@link MessageChannel} to which produced Messages should be sent. + * @param outputChannel The output channel bean name. + * @since 5.1.2 + */ + default void setOutputChannelName(String outputChannel) { + throw new UnsupportedOperationException("This MessageProducer does not support setting the channel by name."); + } + /** * Return the the output channel. * @return the channel. 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 8ae48da457..1e16886211 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 @@ -1,5 +1,5 @@ /* - * Copyright 2016-2018 the original author or authors. + * Copyright 2016-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -118,7 +118,7 @@ public abstract class IntegrationFlowDefinition REFERENCED_REPLY_PRODUCERS = new HashSet<>(); - protected final Map integrationComponents = new LinkedHashMap<>(); + protected final Map integrationComponents = new LinkedHashMap<>(); //NOSONAR - final private MessageChannel currentMessageChannel; @@ -3062,36 +3062,19 @@ public abstract class IntegrationFlowDefinition