From 867a8cf108ff60028a303e92af3f95a937f4710c Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Fri, 7 Feb 2020 13:40:39 -0500 Subject: [PATCH] GH-3155: Add support for Java DSL extensions (#3167) * GH-3155: Add support for Java DSL extensions Fixes https://github.com/spring-projects/spring-integration/issues/3155 Provide an `IntegrationFlowExtension` for possible custom EI-operators in the target project use-cases. * * Move `IntegrationFlowExtension` tests ot its own test class * Make all the `IntegrationComponentSpec` ctors as `protected` for possible custom extensions * Make some `BaseIntegrationFlowDefinition` methods and properties as `protected` to get them access from the `IntegrationFlowExtension` implementations * Document the feature * * Fix language and typos in docs * * Add `protected` to one more `GatewayEndpointSpec` ctor * Add JavaDocs to `GatewayEndpointSpec` methods * * Add `protected` to one more `JmsPollableMessageChannelSpec` ctor --- .../integration/dsl/AbstractRouterSpec.java | 6 +- .../integration/dsl/AggregatorSpec.java | 4 +- .../integration/dsl/BarrierSpec.java | 4 +- .../dsl/BaseIntegrationFlowDefinition.java | 67 +++++----- .../integration/dsl/DelayerEndpointSpec.java | 6 +- .../integration/dsl/DirectChannelSpec.java | 5 +- .../integration/dsl/EnricherSpec.java | 8 +- .../integration/dsl/ExecutorChannelSpec.java | 4 +- .../integration/dsl/FilterEndpointSpec.java | 6 +- .../dsl/FluxMessageChannelSpec.java | 4 +- .../integration/dsl/GatewayEndpointSpec.java | 38 +++++- .../integration/dsl/GatewayProxySpec.java | 14 +-- .../integration/dsl/GenericEndpointSpec.java | 6 +- .../integration/dsl/HeaderEnricherSpec.java | 8 +- .../dsl/IntegrationFlowExtension.java | 98 +++++++++++++++ .../integration/dsl/PriorityChannelSpec.java | 4 +- .../integration/dsl/PublishSubscribeSpec.java | 6 +- .../integration/dsl/QueueChannelSpec.java | 10 +- .../dsl/RecipientListRouterSpec.java | 4 +- .../dsl/RendezvousChannelSpec.java | 4 +- .../integration/dsl/ResequencerSpec.java | 4 +- .../integration/dsl/RouterSpec.java | 4 +- .../integration/dsl/ScatterGatherSpec.java | 4 +- .../dsl/SourcePollingChannelAdapterSpec.java | 6 +- .../integration/dsl/SplitterEndpointSpec.java | 6 +- .../IntegrationFlowExtensionTests.java | 117 ++++++++++++++++++ .../feed/dsl/FeedEntryMessageSourceSpec.java | 6 +- .../dsl/FileInboundChannelAdapterSpec.java | 8 +- .../file/dsl/FileSplitterSpec.java | 8 +- .../dsl/FileWritingMessageHandlerSpec.java | 10 +- .../integration/file/dsl/TailAdapterSpec.java | 6 +- .../ftp/dsl/FtpInboundChannelAdapterSpec.java | 4 +- .../ftp/dsl/FtpMessageHandlerSpec.java | 8 +- .../ftp/dsl/FtpOutboundGatewaySpec.java | 4 +- ...FtpStreamingInboundChannelAdapterSpec.java | 11 +- .../http/dsl/BaseHttpInboundEndpointSpec.java | 4 +- .../http/dsl/HttpControllerEndpointSpec.java | 4 +- .../http/dsl/HttpMessageHandlerSpec.java | 8 +- .../dsl/HttpRequestHandlerEndpointSpec.java | 4 +- .../ip/dsl/AbstractConnectionFactorySpec.java | 7 +- ...AbstractUdpOutboundChannelAdapterSpec.java | 7 +- .../dsl/TcpClientConnectionFactorySpec.java | 8 +- .../ip/dsl/TcpInboundChannelAdapterSpec.java | 8 +- .../ip/dsl/TcpInboundGatewaySpec.java | 8 +- .../ip/dsl/TcpOutboundChannelAdapterSpec.java | 8 +- .../ip/dsl/TcpOutboundGatewaySpec.java | 4 +- .../dsl/TcpServerConnectionFactorySpec.java | 8 +- .../ip/dsl/UdpInboundChannelAdapterSpec.java | 7 +- ...dpMulticastOutboundChannelAdapterSpec.java | 10 +- .../UdpUnicastOutboundChannelAdapterSpec.java | 10 +- .../dsl/JmsDefaultListenerContainerSpec.java | 4 +- .../jms/dsl/JmsDestinationAccessorSpec.java | 4 +- .../jms/dsl/JmsInboundChannelAdapterSpec.java | 6 +- .../jms/dsl/JmsInboundGatewaySpec.java | 6 +- .../jms/dsl/JmsListenerContainerSpec.java | 4 +- .../jms/dsl/JmsMessageChannelSpec.java | 4 +- .../JmsMessageDrivenChannelAdapterSpec.java | 6 +- .../dsl/JmsOutboundChannelAdapterSpec.java | 6 +- .../jms/dsl/JmsOutboundGatewaySpec.java | 4 +- .../dsl/JmsPollableMessageChannelSpec.java | 15 +-- ...JmsPublishSubscribeMessageChannelSpec.java | 4 +- .../integration/jms/dsl/JmsTemplateSpec.java | 4 +- .../jpa/dsl/JpaInboundChannelAdapterSpec.java | 6 +- .../dsl/JpaRetrievingOutboundGatewaySpec.java | 4 +- .../dsl/JpaUpdatingOutboundEndpointSpec.java | 6 +- .../mail/dsl/ImapIdleChannelAdapterSpec.java | 10 +- .../ImapMailInboundChannelAdapterSpec.java | 6 +- .../dsl/MailSendingMessageHandlerSpec.java | 6 +- .../Pop3MailInboundChannelAdapterSpec.java | 12 +- .../dsl/MongoDbOutboundGatewaySpec.java | 4 +- .../ReactiveMongoDbMessageHandlerSpec.java | 6 +- .../dsl/ReactiveMongoDbMessageSourceSpec.java | 7 +- .../dsl/RSocketInboundGatewaySpec.java | 4 +- .../dsl/RSocketOutboundGatewaySpec.java | 4 +- .../dsl/SftpInboundChannelAdapterSpec.java | 6 +- .../sftp/dsl/SftpMessageHandlerSpec.java | 14 ++- .../sftp/dsl/SftpOutboundGatewaySpec.java | 5 +- ...ftpStreamingInboundChannelAdapterSpec.java | 7 +- .../dsl/WebFluxInboundEndpointSpec.java | 4 +- .../dsl/WebFluxMessageHandlerSpec.java | 10 +- src/reference/asciidoc/dsl.adoc | 60 +++++++++ src/reference/asciidoc/whats-new.adoc | 17 ++- 82 files changed, 607 insertions(+), 275 deletions(-) create mode 100644 spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowExtension.java create mode 100644 spring-integration-core/src/test/java/org/springframework/integration/dsl/extensions/IntegrationFlowExtensionTests.java diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/AbstractRouterSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/AbstractRouterSpec.java index 44f7b9e857..f3919440ec 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/AbstractRouterSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/AbstractRouterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -34,7 +34,7 @@ public class AbstractRouterSpec, R extends Ab private boolean defaultToParentFlow; - AbstractRouterSpec(R router) { + protected AbstractRouterSpec(R router) { super(router); } @@ -100,7 +100,7 @@ public class AbstractRouterSpec, R extends Ab return _this(); } - boolean isDefaultToParentFlow() { + protected boolean isDefaultToParentFlow() { return this.defaultToParentFlow; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/AggregatorSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/AggregatorSpec.java index 1de4d3c2de..fb8c3a831c 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/AggregatorSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/AggregatorSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -39,7 +39,7 @@ public class AggregatorSpec extends CorrelationHandlerSpec> headersFunction; - AggregatorSpec() { + protected AggregatorSpec() { super(new AggregatingMessageHandler(new DefaultAggregatingMessageGroupProcessor())); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/BarrierSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/BarrierSpec.java index 0c76e81b86..769617d723 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/BarrierSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/BarrierSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -52,7 +52,7 @@ public class BarrierSpec extends ConsumerEndpointSpec REFERENCED_REPLY_PRODUCERS = new HashSet<>(); + protected static final SpelExpressionParser PARSER = new SpelExpressionParser(); //NOSONAR - final + protected final Map integrationComponents = new LinkedHashMap<>(); //NOSONAR - final private MessageChannel currentMessageChannel; @@ -380,7 +380,7 @@ public abstract class BaseIntegrationFlowDefinition headers) { + return enrichHeaders(headers, null); + } + /** * Accept a {@link Map} of values to be used for the * {@link Message} header enrichment. @@ -1908,7 +1920,7 @@ public abstract class BaseIntegrationFlowDefinition(new MethodInvokingRouter(processor)), routerConfigurer); } - private > B route(S routerSpec, + protected > B route(S routerSpec, Consumer routerConfigurer) { if (routerConfigurer != null) { @@ -2825,6 +2837,17 @@ public abstract class BaseIntegrationFlowDefinition the expected {@code payload} type @@ -2858,19 +2881,7 @@ public abstract class BaseIntegrationFlowDefinition(components, publisher); } - /** - * Add a {@value IntegrationContextUtils#NULL_CHANNEL_BEAN_NAME} bean into this flow - * definition as a terminal operator. - * @return The {@link IntegrationFlow} instance based on this definition. - * @since 5.1 - */ - public IntegrationFlow nullChannel() { - return channel(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME) - .get(); - } - - @SuppressWarnings(UNCHECKED) - private > B register(S endpointSpec, + protected > B register(S endpointSpec, Consumer endpointConfigurer) { if (endpointConfigurer != null) { @@ -2906,7 +2917,7 @@ public abstract class BaseIntegrationFlowDefinition headers) { - return enrichHeaders(headers, null); - } - - private static Object extractProxyTarget(Object target) { + protected static Object extractProxyTarget(Object target) { if (!(target instanceof Advised)) { return target; } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/DelayerEndpointSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/DelayerEndpointSpec.java index 616e34ea38..7a27124b46 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/DelayerEndpointSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/DelayerEndpointSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -42,11 +42,11 @@ import org.springframework.util.Assert; * * @since 5.0 */ -public final class DelayerEndpointSpec extends ConsumerEndpointSpec { +public class DelayerEndpointSpec extends ConsumerEndpointSpec { private final List delayedAdvice = new LinkedList<>(); - DelayerEndpointSpec(DelayHandler delayHandler) { + protected DelayerEndpointSpec(DelayHandler delayHandler) { super(delayHandler); Assert.notNull(delayHandler, "'delayHandler' must not be null."); this.handler.setDelayedAdviceChain(this.delayedAdvice); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/DirectChannelSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/DirectChannelSpec.java index 7c2fb599d1..74e956fe24 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/DirectChannelSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/DirectChannelSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -37,7 +37,4 @@ public class DirectChannelSpec extends LoadBalancingChannelSpec { - private final Map propertyExpressions = new HashMap<>(); + protected final Map propertyExpressions = new HashMap<>(); // NOSONAR - final - private final Map> headerExpressions = new HashMap<>(); + protected final Map> headerExpressions = new HashMap<>(); // NOSONAR - final - EnricherSpec() { + protected EnricherSpec() { super(new ContentEnricher()); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/ExecutorChannelSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/ExecutorChannelSpec.java index 69eddf36db..d27a8fe08a 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/ExecutorChannelSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/ExecutorChannelSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -29,7 +29,7 @@ public class ExecutorChannelSpec extends LoadBalancingChannelSpec { +public class FilterEndpointSpec extends ConsumerEndpointSpec { - FilterEndpointSpec(MessageFilter messageFilter) { + protected FilterEndpointSpec(MessageFilter messageFilter) { super(messageFilter); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/FluxMessageChannelSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/FluxMessageChannelSpec.java index 9860b251d7..6d0eb4f728 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/FluxMessageChannelSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/FluxMessageChannelSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2020 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. @@ -26,7 +26,7 @@ import org.springframework.integration.channel.FluxMessageChannel; */ public class FluxMessageChannelSpec extends MessageChannelSpec { - FluxMessageChannelSpec() { + protected FluxMessageChannelSpec() { this.channel = new FluxMessageChannel(); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/GatewayEndpointSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/GatewayEndpointSpec.java index 01452d64b0..64fa3d005e 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/GatewayEndpointSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/GatewayEndpointSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -26,43 +26,73 @@ import org.springframework.messaging.MessageChannel; * * @since 5.0 */ -public final class GatewayEndpointSpec extends ConsumerEndpointSpec { +public class GatewayEndpointSpec extends ConsumerEndpointSpec { - GatewayEndpointSpec(MessageChannel requestChannel) { + protected GatewayEndpointSpec(MessageChannel requestChannel) { super(new GatewayMessageHandler()); this.handler.setRequestChannel(requestChannel); } - GatewayEndpointSpec(String requestChannel) { + protected GatewayEndpointSpec(String requestChannel) { super(new GatewayMessageHandler()); this.handler.setRequestChannelName(requestChannel); } + /** + * Set a reply channel. + * @param replyChannel the reply channel + * @return the spec + */ public GatewayEndpointSpec replyChannel(MessageChannel replyChannel) { this.handler.setReplyChannel(replyChannel); return this; } + /** + * Set a reply channel. + * @param replyChannel the reply channel + * @return the spec + */ public GatewayEndpointSpec replyChannel(String replyChannel) { this.handler.setReplyChannelName(replyChannel); return this; } + /** + * Set an error channel. + * @param errorChannel the error channel + * @return the spec + */ public GatewayEndpointSpec errorChannel(MessageChannel errorChannel) { this.handler.setErrorChannel(errorChannel); return this; } + /** + * Set an error channel. + * @param errorChannel the error channel + * @return the spec + */ public GatewayEndpointSpec errorChannel(String errorChannel) { this.handler.setErrorChannelName(errorChannel); return this; } + /** + * Set a request timeout. + * @param requestTimeout the request timeout + * @return the spec + */ public GatewayEndpointSpec requestTimeout(Long requestTimeout) { this.handler.setRequestTimeout(requestTimeout); return this; } + /** + * Set a reply timeout. + * @param replyTimeout the reply timeout + * @return the spec + */ public GatewayEndpointSpec replyTimeout(Long replyTimeout) { this.handler.setReplyTimeout(replyTimeout); return this; diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/GatewayProxySpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/GatewayProxySpec.java index 2987b201e1..67b7d119e1 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/GatewayProxySpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/GatewayProxySpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2019-2020 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. @@ -45,19 +45,19 @@ import org.springframework.messaging.MessageChannel; */ public class GatewayProxySpec { - private static final SpelExpressionParser PARSER = new SpelExpressionParser(); + protected static final SpelExpressionParser PARSER = new SpelExpressionParser(); // NOSONAR - final - private final MessageChannel gatewayRequestChannel = new DirectChannel(); + protected final MessageChannel gatewayRequestChannel = new DirectChannel(); // NOSONAR - final - private final GatewayProxyFactoryBean gatewayProxyFactoryBean; + protected final GatewayProxyFactoryBean gatewayProxyFactoryBean; // NOSONAR - final - private final GatewayMethodMetadata gatewayMethodMetadata = new GatewayMethodMetadata(); + protected final GatewayMethodMetadata gatewayMethodMetadata = new GatewayMethodMetadata(); // NOSONAR - final - private final Map headerExpressions = new HashMap<>(); + protected final Map headerExpressions = new HashMap<>(); // NOSONAR - final private boolean populateGatewayMethodMetadata; - GatewayProxySpec(Class serviceInterface) { + protected GatewayProxySpec(Class serviceInterface) { this.gatewayProxyFactoryBean = new AnnotationGatewayProxyFactoryBean(serviceInterface); this.gatewayProxyFactoryBean.setDefaultRequestChannel(this.gatewayRequestChannel); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/GenericEndpointSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/GenericEndpointSpec.java index eb6928f903..1a634733ca 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/GenericEndpointSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/GenericEndpointSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -27,10 +27,10 @@ import org.springframework.messaging.MessageHandler; * * @since 5.0 */ -public final class GenericEndpointSpec +public class GenericEndpointSpec extends ConsumerEndpointSpec, H> { - GenericEndpointSpec(H messageHandler) { + protected GenericEndpointSpec(H messageHandler) { super(messageHandler); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/HeaderEnricherSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/HeaderEnricherSpec.java index e3f162c3fa..1b529c93fe 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/HeaderEnricherSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/HeaderEnricherSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -58,11 +58,11 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec> headerToAdd = new HashMap<>(); + protected final Map> headerToAdd = new HashMap<>(); // NOSONAR - final - private final HeaderEnricher headerEnricher = new HeaderEnricher(this.headerToAdd); + protected final HeaderEnricher headerEnricher = new HeaderEnricher(this.headerToAdd); // NOSONAR - final - HeaderEnricherSpec() { + protected HeaderEnricherSpec() { super(null); this.handler = new MessageTransformingHandler(this.headerEnricher); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowExtension.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowExtension.java new file mode 100644 index 0000000000..3bbcf34e2b --- /dev/null +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowExtension.java @@ -0,0 +1,98 @@ +/* + * Copyright 2020 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.dsl; + +import java.util.Map; + +import org.springframework.beans.factory.BeanNameAware; +import org.springframework.integration.channel.DirectChannel; + +/** + * An {@link IntegrationFlowDefinition} extension for custom Java DSL operators + * and reusable solutions. + * For supporting method flow chain an implementation of this class has to return + * an extension class from new methods, e.g.: + *
+ * {@code
+ * 	public class MyIntegrationFlowDefinition
+ * 			extends IntegrationFlowExtension {
+ *
+ * 		public MyIntegrationFlowDefinition upperCaseAfterSplit() {
+ * 			return split()
+ * 					.transform("payload.toUpperCase()");
+ *      }
+ * }
+ * }
+ * 
+ * This way it will be used in the target configuration as natural DSL definition: + *
+ * {@code
+ *  @Bean
+ *  public IntegrationFlow myFlowDefinition() {
+ * 		return
+ * 				new MyIntegrationFlowDefinition()
+ * 			            .log()
+ * 						.upperCaseAfterSplit()
+ * 						.aggregate()
+ * 						.get();
+ *  }
+ * }
+ * 
+ * This {@link IntegrationFlowExtension} can also be used for overriding + * existing operators with extensions to any {@link IntegrationComponentSpec} extensions, + * e.g. adding new options for target component configuration. + * + * @param the {@link IntegrationFlowDefinition} implementation type. + * + * @author Artem Bilan + * + * @since 5.3 + */ +public abstract class IntegrationFlowExtension> + extends IntegrationFlowDefinition { + + private final DirectChannel inputChannel = new DirectChannel(); + + protected IntegrationFlowExtension() { + channel(this.inputChannel); + } + + @Override + public StandardIntegrationFlow get() { + StandardIntegrationFlow targetIntegrationFlow = super.get(); + return new StandardIntegrationFlowExtension(targetIntegrationFlow.getIntegrationComponents(), + this.inputChannel); + } + + private static class StandardIntegrationFlowExtension extends StandardIntegrationFlow + implements BeanNameAware { + + private final DirectChannel inputChannel; + + StandardIntegrationFlowExtension(Map integrationComponents, DirectChannel inputChannel) { + super(integrationComponents); + this.inputChannel = inputChannel; + } + + @Override + public void setBeanName(String name) { + this.inputChannel.setBeanName(name + ".input"); + } + + } + +} diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/PriorityChannelSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/PriorityChannelSpec.java index 84aad87957..ae41ed2b82 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/PriorityChannelSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/PriorityChannelSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -37,7 +37,7 @@ public class PriorityChannelSpec extends MessageChannelSpec> queue) { + protected QueueChannelSpec(Queue> queue) { this.queue = queue; } - QueueChannelSpec(Integer capacity) { + protected QueueChannelSpec(Integer capacity) { this.capacity = capacity; } @@ -71,7 +71,7 @@ public class QueueChannelSpec extends MessageChannelSpec { - RecipientListRouterSpec() { + protected RecipientListRouterSpec() { super(new RecipientListRouter()); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/RendezvousChannelSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/RendezvousChannelSpec.java index 9ea1a763d9..498b4ede6c 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/RendezvousChannelSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/RendezvousChannelSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -25,7 +25,7 @@ import org.springframework.integration.channel.RendezvousChannel; */ public class RendezvousChannelSpec extends MessageChannelSpec { - RendezvousChannelSpec() { + protected RendezvousChannelSpec() { this.channel = new RendezvousChannel(); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/ResequencerSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/ResequencerSpec.java index 3f0bcb00ed..3a991b3d5b 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/ResequencerSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/ResequencerSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -26,7 +26,7 @@ import org.springframework.integration.aggregator.ResequencingMessageHandler; */ public class ResequencerSpec extends CorrelationHandlerSpec { - ResequencerSpec() { + protected ResequencerSpec() { super(new ResequencingMessageHandler(new ResequencingMessageGroupProcessor())); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java index 14f19a532f..f512aa8ed2 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/RouterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -52,7 +52,7 @@ public final class RouterSpec private boolean mappingProviderRegistered; - RouterSpec(R router) { + protected RouterSpec(R router) { super(router); this.mappingProvider = new RouterMappingProvider(this.handler); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/ScatterGatherSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/ScatterGatherSpec.java index f84122d0ef..96e58504cb 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/ScatterGatherSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/ScatterGatherSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -31,7 +31,7 @@ import org.springframework.messaging.MessageChannel; */ public class ScatterGatherSpec extends ConsumerEndpointSpec { - ScatterGatherSpec(ScatterGatherHandler messageHandler) { + protected ScatterGatherSpec(ScatterGatherHandler messageHandler) { super(messageHandler); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/SourcePollingChannelAdapterSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/SourcePollingChannelAdapterSpec.java index ab30ea3352..4cee04531f 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/SourcePollingChannelAdapterSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/SourcePollingChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -25,10 +25,10 @@ import org.springframework.integration.scheduling.PollerMetadata; * * @since 5.0 */ -public final class SourcePollingChannelAdapterSpec extends +public class SourcePollingChannelAdapterSpec extends EndpointSpec> { - SourcePollingChannelAdapterSpec(MessageSource messageSource) { + protected SourcePollingChannelAdapterSpec(MessageSource messageSource) { super(messageSource); this.endpointFactoryBean.setSource(messageSource); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/SplitterEndpointSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/SplitterEndpointSpec.java index 6191bcb6ba..d26695e7b7 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/SplitterEndpointSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/SplitterEndpointSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -29,10 +29,10 @@ import org.springframework.messaging.MessageChannel; * * @since 5.0 */ -public final class SplitterEndpointSpec +public class SplitterEndpointSpec extends ConsumerEndpointSpec, S> { - SplitterEndpointSpec(S splitter) { + protected SplitterEndpointSpec(S splitter) { super(splitter); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/extensions/IntegrationFlowExtensionTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/extensions/IntegrationFlowExtensionTests.java new file mode 100644 index 0000000000..fb136540fa --- /dev/null +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/extensions/IntegrationFlowExtensionTests.java @@ -0,0 +1,117 @@ +/* + * Copyright 2020 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.integration.dsl.extensions; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.Arrays; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.Test; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.integration.channel.QueueChannel; +import org.springframework.integration.config.EnableIntegration; +import org.springframework.integration.dsl.AggregatorSpec; +import org.springframework.integration.dsl.IntegrationFlow; +import org.springframework.integration.dsl.IntegrationFlowExtension; +import org.springframework.integration.support.MessageBuilder; +import org.springframework.messaging.Message; +import org.springframework.messaging.SubscribableChannel; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; + +/** + * @author Artem Bilan + * + * @since 5.3 + */ +@SpringJUnitConfig +@DirtiesContext +public class IntegrationFlowExtensionTests { + + @Autowired + @Qualifier("customFlowDefinition.input") + SubscribableChannel customFlowDefinitionInput; + + @Test + public void testCustomFlowDefinition() { + QueueChannel replyChannel = new QueueChannel(); + Message testMessage = + MessageBuilder.withPayload(Arrays.asList("one", "two", "three")) + .setReplyChannel(replyChannel) + .build(); + this.customFlowDefinitionInput.send(testMessage); + + Message replyMessage = replyChannel.receive(10_000); + + assertThat(replyMessage) + .isNotNull() + .extracting(Message::getPayload) + .isEqualTo("ONE, TWO, THREE"); + } + + @Configuration + @EnableIntegration + public static class ContextConfiguration { + + @Bean + public IntegrationFlow customFlowDefinition() { + return + new CustomIntegrationFlowDefinition() + .log() + .upperCaseAfterSplit() + .channel("innerChannel") + .customAggregate(customAggregatorSpec -> + customAggregatorSpec.expireGroupsUponCompletion(true)) + .logAndReply(); + } + + } + + public static class CustomIntegrationFlowDefinition + extends IntegrationFlowExtension { + + public CustomIntegrationFlowDefinition upperCaseAfterSplit() { + return split() + .transform("payload.toUpperCase()"); + } + + public CustomIntegrationFlowDefinition customAggregate(Consumer aggregator) { + return register(new CustomAggregatorSpec(), aggregator); + } + + } + + public static class CustomAggregatorSpec extends AggregatorSpec { + + CustomAggregatorSpec() { + outputProcessor((group) -> + group.getMessages() + .stream() + .map(Message::getPayload) + .map(String.class::cast) + .collect(Collectors.joining(", "))); + } + + } + +} diff --git a/spring-integration-feed/src/main/java/org/springframework/integration/feed/dsl/FeedEntryMessageSourceSpec.java b/spring-integration-feed/src/main/java/org/springframework/integration/feed/dsl/FeedEntryMessageSourceSpec.java index eba474ca7f..6fd6a5df65 100644 --- a/spring-integration-feed/src/main/java/org/springframework/integration/feed/dsl/FeedEntryMessageSourceSpec.java +++ b/spring-integration-feed/src/main/java/org/springframework/integration/feed/dsl/FeedEntryMessageSourceSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -34,11 +34,11 @@ import com.rometools.rome.io.SyndFeedInput; */ public class FeedEntryMessageSourceSpec extends MessageSourceSpec { - FeedEntryMessageSourceSpec(URL feedUrl, String metadataKey) { + protected FeedEntryMessageSourceSpec(URL feedUrl, String metadataKey) { this.target = new FeedEntryMessageSource(feedUrl, metadataKey); } - FeedEntryMessageSourceSpec(Resource feedResource, String metadataKey) { + protected FeedEntryMessageSourceSpec(Resource feedResource, String metadataKey) { this.target = new FeedEntryMessageSource(feedResource, metadataKey); } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/FileInboundChannelAdapterSpec.java b/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/FileInboundChannelAdapterSpec.java index 0179e59c1e..fceed01f20 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/FileInboundChannelAdapterSpec.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/FileInboundChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -46,7 +46,7 @@ public class FileInboundChannelAdapterSpec extends MessageSourceSpec implements ComponentsRegistration { - private final FileListFilterFactoryBean fileListFilterFactoryBean = new FileListFilterFactoryBean(); + protected final FileListFilterFactoryBean fileListFilterFactoryBean = new FileListFilterFactoryBean(); // NOSONAR private FileLocker locker; @@ -56,11 +56,11 @@ public class FileInboundChannelAdapterSpec private boolean filtersSet; - FileInboundChannelAdapterSpec() { + protected FileInboundChannelAdapterSpec() { this.target = new FileReadingMessageSource(); } - FileInboundChannelAdapterSpec(Comparator receptionOrderComparator) { + protected FileInboundChannelAdapterSpec(Comparator receptionOrderComparator) { this.target = new FileReadingMessageSource(receptionOrderComparator); } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/FileSplitterSpec.java b/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/FileSplitterSpec.java index 617d50b2b1..a7435772c2 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/FileSplitterSpec.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/FileSplitterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -45,15 +45,15 @@ public class FileSplitterSpec extends MessageHandlerSpec FileWritingMessageHandlerSpec(Function, ?> directoryFunction) { + protected

FileWritingMessageHandlerSpec(Function, ?> directoryFunction) { this(new FunctionExpression<>(directoryFunction)); } - FileWritingMessageHandlerSpec(Expression directoryExpression) { + protected FileWritingMessageHandlerSpec(Expression directoryExpression) { this.target = new FileWritingMessageHandler(directoryExpression); } diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/TailAdapterSpec.java b/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/TailAdapterSpec.java index cd2edb739a..12f8d5a036 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/TailAdapterSpec.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/dsl/TailAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -43,12 +43,12 @@ public class TailAdapterSpec extends MessageProducerSpec { - FtpInboundChannelAdapterSpec(SessionFactory sessionFactory, Comparator comparator) { + protected FtpInboundChannelAdapterSpec(SessionFactory sessionFactory, Comparator comparator) { super(new FtpInboundFileSynchronizer(sessionFactory)); this.target = new FtpInboundFileSynchronizingMessageSource(this.synchronizer, comparator); } diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/FtpMessageHandlerSpec.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/FtpMessageHandlerSpec.java index 260ae0d8cb..cc2d953b1b 100644 --- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/FtpMessageHandlerSpec.java +++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/FtpMessageHandlerSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2020 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. @@ -34,15 +34,15 @@ import org.springframework.integration.ftp.outbound.FtpMessageHandler; */ public class FtpMessageHandlerSpec extends FileTransferringMessageHandlerSpec { - FtpMessageHandlerSpec(SessionFactory sessionFactory) { + protected FtpMessageHandlerSpec(SessionFactory sessionFactory) { this.target = new FtpMessageHandler(sessionFactory); } - FtpMessageHandlerSpec(RemoteFileTemplate remoteFileTemplate) { + protected FtpMessageHandlerSpec(RemoteFileTemplate remoteFileTemplate) { this.target = new FtpMessageHandler(remoteFileTemplate.getSessionFactory()); } - FtpMessageHandlerSpec(RemoteFileTemplate remoteFileTemplate, FileExistsMode fileExistsMode) { + protected FtpMessageHandlerSpec(RemoteFileTemplate remoteFileTemplate, FileExistsMode fileExistsMode) { this.target = new FtpMessageHandler(remoteFileTemplate, fileExistsMode); } diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/FtpOutboundGatewaySpec.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/FtpOutboundGatewaySpec.java index 747ae459d0..c15fdce7b3 100644 --- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/FtpOutboundGatewaySpec.java +++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/FtpOutboundGatewaySpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2020 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. @@ -37,7 +37,7 @@ import org.springframework.messaging.Message; */ public class FtpOutboundGatewaySpec extends RemoteFileOutboundGatewaySpec { - FtpOutboundGatewaySpec(FtpOutboundGateway outboundGateway) { + protected FtpOutboundGatewaySpec(FtpOutboundGateway outboundGateway) { super(outboundGateway); } diff --git a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/FtpStreamingInboundChannelAdapterSpec.java b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/FtpStreamingInboundChannelAdapterSpec.java index 355e251941..2309c4a2b9 100644 --- a/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/FtpStreamingInboundChannelAdapterSpec.java +++ b/spring-integration-ftp/src/main/java/org/springframework/integration/ftp/dsl/FtpStreamingInboundChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2020 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. @@ -31,18 +31,20 @@ import org.springframework.integration.ftp.inbound.FtpStreamingMessageSource; import org.springframework.integration.metadata.SimpleMetadataStore; /** - * A {@link RemoteFileStreamingInboundChannelAdapterSpec} for a - * {@link FtpStreamingMessageSource}. + * A {@link RemoteFileStreamingInboundChannelAdapterSpec} for a {@link FtpStreamingMessageSource}. * * @author Gary Russell + * @author Artem Bilan + * * @since 5.0 */ public class FtpStreamingInboundChannelAdapterSpec extends RemoteFileStreamingInboundChannelAdapterSpec { - FtpStreamingInboundChannelAdapterSpec(RemoteFileTemplate remoteFileTemplate, + protected FtpStreamingInboundChannelAdapterSpec(RemoteFileTemplate remoteFileTemplate, Comparator comparator) { + this.target = new FtpStreamingMessageSource(remoteFileTemplate, comparator); } @@ -68,7 +70,6 @@ public class FtpStreamingInboundChannelAdapterSpec return filter(composeFilters(new FtpRegexPatternFileListFilter(regex))); } - @SuppressWarnings("unchecked") private CompositeFileListFilter composeFilters(FileListFilter fileListFilter) { CompositeFileListFilter compositeFileListFilter = new CompositeFileListFilter<>(); compositeFileListFilter.addFilters(fileListFilter, diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/BaseHttpInboundEndpointSpec.java b/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/BaseHttpInboundEndpointSpec.java index d58a648398..451ba31d1b 100644 --- a/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/BaseHttpInboundEndpointSpec.java +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/BaseHttpInboundEndpointSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -38,7 +38,7 @@ public abstract class BaseHttpInboundEndpointSpec extends HttpInboundEndpointSupportSpec { - BaseHttpInboundEndpointSpec(E endpoint, String... path) { + protected BaseHttpInboundEndpointSpec(E endpoint, String... path) { super(endpoint, path); } diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/HttpControllerEndpointSpec.java b/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/HttpControllerEndpointSpec.java index b23cf92a19..6266682a39 100644 --- a/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/HttpControllerEndpointSpec.java +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/HttpControllerEndpointSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -30,7 +30,7 @@ import org.springframework.integration.http.inbound.HttpRequestHandlingControlle public class HttpControllerEndpointSpec extends BaseHttpInboundEndpointSpec { - HttpControllerEndpointSpec(HttpRequestHandlingController controller, String... path) { + protected HttpControllerEndpointSpec(HttpRequestHandlingController controller, String... path) { super(controller, path); } diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/HttpMessageHandlerSpec.java b/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/HttpMessageHandlerSpec.java index bc1861e8e7..e0951deeba 100644 --- a/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/HttpMessageHandlerSpec.java +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/HttpMessageHandlerSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -45,15 +45,15 @@ public class HttpMessageHandlerSpec private final RestTemplate restTemplate; - HttpMessageHandlerSpec(URI uri, RestTemplate restTemplate) { + protected HttpMessageHandlerSpec(URI uri, RestTemplate restTemplate) { this(new ValueExpression<>(uri), restTemplate); } - HttpMessageHandlerSpec(String uri, RestTemplate restTemplate) { + protected HttpMessageHandlerSpec(String uri, RestTemplate restTemplate) { this(new LiteralExpression(uri), restTemplate); } - HttpMessageHandlerSpec(Expression uriExpression, RestTemplate restTemplate) { + protected HttpMessageHandlerSpec(Expression uriExpression, RestTemplate restTemplate) { super(new HttpRequestExecutingMessageHandler(uriExpression, restTemplate)); this.restTemplate = restTemplate; } diff --git a/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/HttpRequestHandlerEndpointSpec.java b/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/HttpRequestHandlerEndpointSpec.java index e94feeb8e2..d038c802cc 100644 --- a/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/HttpRequestHandlerEndpointSpec.java +++ b/spring-integration-http/src/main/java/org/springframework/integration/http/dsl/HttpRequestHandlerEndpointSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -30,7 +30,7 @@ import org.springframework.integration.http.inbound.HttpRequestHandlingMessaging public class HttpRequestHandlerEndpointSpec extends BaseHttpInboundEndpointSpec { - HttpRequestHandlerEndpointSpec(HttpRequestHandlingMessagingGateway endpoint, String... path) { + protected HttpRequestHandlerEndpointSpec(HttpRequestHandlingMessagingGateway endpoint, String... path) { super(endpoint, path); } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/AbstractConnectionFactorySpec.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/AbstractConnectionFactorySpec.java index 65a91f828c..788adcf0bb 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/AbstractConnectionFactorySpec.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/AbstractConnectionFactorySpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -28,10 +28,13 @@ import org.springframework.integration.ip.tcp.connection.TcpSocketSupport; /** * An {@link IntegrationComponentSpec} for {@link AbstractConnectionFactory}s. + * * @param the target {@link AbstractConnectionFactorySpec} implementation type. * @param the target {@link AbstractConnectionFactory} implementation type. * * @author Gary Russell + * @author Artem Bilan + * * @since 5.0 * */ @@ -39,7 +42,7 @@ public abstract class AbstractConnectionFactorySpec , C extends AbstractConnectionFactory> extends IntegrationComponentSpec { - AbstractConnectionFactorySpec(C connectionFactory) { + protected AbstractConnectionFactorySpec(C connectionFactory) { this.target = connectionFactory; } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/AbstractUdpOutboundChannelAdapterSpec.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/AbstractUdpOutboundChannelAdapterSpec.java index e6afdd89c2..e3aa00c6e8 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/AbstractUdpOutboundChannelAdapterSpec.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/AbstractUdpOutboundChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -30,6 +30,7 @@ import org.springframework.messaging.Message; * @param the target {@link AbstractUdpOutboundChannelAdapterSpec} implementation type. * * @author Gary Russell + * @author Artem Bilan * * @since 5.0 * @@ -44,11 +45,11 @@ public abstract class AbstractUdpOutboundChannelAdapterSpec, ?> destinationFunction) { + protected AbstractUdpOutboundChannelAdapterSpec(Function, ?> destinationFunction) { this.target = new UnicastSendingMessageHandler(new FunctionExpression<>(destinationFunction)); } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpClientConnectionFactorySpec.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpClientConnectionFactorySpec.java index 7ac0738555..187190df78 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpClientConnectionFactorySpec.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpClientConnectionFactorySpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -22,7 +22,9 @@ import org.springframework.integration.ip.tcp.connection.TcpNioClientConnectionF /** * An {@link AbstractConnectionFactorySpec} for {@link AbstractClientConnectionFactory}s. + * * @author Gary Russell + * @author Artem Bilan * * @since 5.0 * @@ -30,11 +32,11 @@ import org.springframework.integration.ip.tcp.connection.TcpNioClientConnectionF public class TcpClientConnectionFactorySpec extends AbstractConnectionFactorySpec { - TcpClientConnectionFactorySpec(String host, int port) { + protected TcpClientConnectionFactorySpec(String host, int port) { this(host, port, false); } - TcpClientConnectionFactorySpec(String host, int port, boolean nio) { + protected TcpClientConnectionFactorySpec(String host, int port, boolean nio) { super(nio ? new TcpNioClientConnectionFactory(host, port) : new TcpNetClientConnectionFactory(host, port)); } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpInboundChannelAdapterSpec.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpInboundChannelAdapterSpec.java index 3d645d0e5b..4c3549a639 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpInboundChannelAdapterSpec.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpInboundChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -38,13 +38,13 @@ public class TcpInboundChannelAdapterSpec extends MessageProducerSpec implements ComponentsRegistration { - private final AbstractConnectionFactory connectionFactory; + protected final AbstractConnectionFactory connectionFactory; // NOSONAR - final /** * Construct an instance using an existing spring-managed connection factory. * @param connectionFactoryBean the spring-managed bean. */ - TcpInboundChannelAdapterSpec(AbstractConnectionFactory connectionFactoryBean) { + protected TcpInboundChannelAdapterSpec(AbstractConnectionFactory connectionFactoryBean) { super(new TcpReceivingChannelAdapter()); this.connectionFactory = null; this.target.setConnectionFactory(connectionFactoryBean); @@ -54,7 +54,7 @@ public class TcpInboundChannelAdapterSpec * Construct an instance using the provided connection factory spec. * @param connectionFactorySpec the spec. */ - TcpInboundChannelAdapterSpec(AbstractConnectionFactorySpec connectionFactorySpec) { + protected TcpInboundChannelAdapterSpec(AbstractConnectionFactorySpec connectionFactorySpec) { super(new TcpReceivingChannelAdapter()); this.connectionFactory = connectionFactorySpec.get(); this.target.setConnectionFactory(this.connectionFactory); diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpInboundGatewaySpec.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpInboundGatewaySpec.java index 82af885f01..d24018b193 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpInboundGatewaySpec.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpInboundGatewaySpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -37,13 +37,13 @@ import org.springframework.scheduling.TaskScheduler; public class TcpInboundGatewaySpec extends MessagingGatewaySpec implements ComponentsRegistration { - private final AbstractConnectionFactory connectionFactory; + protected final AbstractConnectionFactory connectionFactory; // NOSONAR - final /** * Construct an instance using an existing spring-managed connection factory. * @param connectionFactoryBean the spring-managed bean. */ - TcpInboundGatewaySpec(AbstractConnectionFactory connectionFactoryBean) { + protected TcpInboundGatewaySpec(AbstractConnectionFactory connectionFactoryBean) { super(new TcpInboundGateway()); this.connectionFactory = null; this.target.setConnectionFactory(connectionFactoryBean); @@ -53,7 +53,7 @@ public class TcpInboundGatewaySpec extends MessagingGatewaySpec connectionFactorySpec) { + protected TcpInboundGatewaySpec(AbstractConnectionFactorySpec connectionFactorySpec) { super(new TcpInboundGateway()); this.connectionFactory = connectionFactorySpec.get(); this.target.setConnectionFactory(this.connectionFactory); diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpOutboundChannelAdapterSpec.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpOutboundChannelAdapterSpec.java index 73776e30e8..211aa47ce0 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpOutboundChannelAdapterSpec.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpOutboundChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -38,13 +38,13 @@ public class TcpOutboundChannelAdapterSpec extends MessageHandlerSpec implements ComponentsRegistration { - private final AbstractConnectionFactory connectionFactory; + protected final AbstractConnectionFactory connectionFactory; // NOSONAR - final /** * Construct an instance using an existing spring-managed connection factory. * @param connectionFactoryBean the spring-managed bean. */ - TcpOutboundChannelAdapterSpec(AbstractConnectionFactory connectionFactoryBean) { + protected TcpOutboundChannelAdapterSpec(AbstractConnectionFactory connectionFactoryBean) { this.target = new TcpSendingMessageHandler(); this.connectionFactory = null; this.target.setConnectionFactory(connectionFactoryBean); @@ -54,7 +54,7 @@ public class TcpOutboundChannelAdapterSpec * Construct an instance using the provided connection factory spec. * @param connectionFactorySpec the spec. */ - TcpOutboundChannelAdapterSpec(AbstractConnectionFactorySpec connectionFactorySpec) { + protected TcpOutboundChannelAdapterSpec(AbstractConnectionFactorySpec connectionFactorySpec) { this.target = new TcpSendingMessageHandler(); this.connectionFactory = connectionFactorySpec.get(); this.target.setConnectionFactory(this.connectionFactory); diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpOutboundGatewaySpec.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpOutboundGatewaySpec.java index 87cbb0b922..9389ccdc2b 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpOutboundGatewaySpec.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpOutboundGatewaySpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -39,7 +39,7 @@ import org.springframework.messaging.Message; public class TcpOutboundGatewaySpec extends MessageHandlerSpec implements ComponentsRegistration { - private final AbstractClientConnectionFactory connectionFactory; + protected final AbstractClientConnectionFactory connectionFactory; // NOSONAR - final /** * Construct an instance using an existing spring-managed connection factory. diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpServerConnectionFactorySpec.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpServerConnectionFactorySpec.java index 1f83077266..2e540cbb08 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpServerConnectionFactorySpec.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/TcpServerConnectionFactorySpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -22,7 +22,9 @@ import org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionF /** * An {@link AbstractConnectionFactorySpec} for {@link AbstractServerConnectionFactory}s. + * * @author Gary Russell + * @author Artem Bilan * * @since 5.0 * @@ -30,11 +32,11 @@ import org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionF public class TcpServerConnectionFactorySpec extends AbstractConnectionFactorySpec { - TcpServerConnectionFactorySpec(int port) { + protected TcpServerConnectionFactorySpec(int port) { this(port, false); } - TcpServerConnectionFactorySpec(int port, boolean nio) { + protected TcpServerConnectionFactorySpec(int port, boolean nio) { super(nio ? new TcpNioServerConnectionFactory(port) : new TcpNetServerConnectionFactory(port)); } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/UdpInboundChannelAdapterSpec.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/UdpInboundChannelAdapterSpec.java index c43781f3bb..009f3926c5 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/UdpInboundChannelAdapterSpec.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/UdpInboundChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -28,17 +28,18 @@ import org.springframework.scheduling.TaskScheduler; * A {@link MessageProducerSpec} for {@link UnicastReceivingChannelAdapter}s. * * @author Gary Russell + * * @since 5.0 * */ public class UdpInboundChannelAdapterSpec extends MessageProducerSpec { - UdpInboundChannelAdapterSpec(int port) { + protected UdpInboundChannelAdapterSpec(int port) { super(new UnicastReceivingChannelAdapter(port)); } - UdpInboundChannelAdapterSpec(int port, String multicastGroup) { + protected UdpInboundChannelAdapterSpec(int port, String multicastGroup) { super(new MulticastReceivingChannelAdapter(multicastGroup, port)); } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/UdpMulticastOutboundChannelAdapterSpec.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/UdpMulticastOutboundChannelAdapterSpec.java index 05b3aab858..58f69d1bdc 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/UdpMulticastOutboundChannelAdapterSpec.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/UdpMulticastOutboundChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -27,21 +27,23 @@ import org.springframework.messaging.Message; * {@link MulticastSendingMessageHandler}s. * * @author Gary Russell + * @author Artem Bilan + * * @since 5.0 * */ public class UdpMulticastOutboundChannelAdapterSpec extends AbstractUdpOutboundChannelAdapterSpec { - UdpMulticastOutboundChannelAdapterSpec(String host, int port) { + protected UdpMulticastOutboundChannelAdapterSpec(String host, int port) { this.target = new MulticastSendingMessageHandler(host, port); } - UdpMulticastOutboundChannelAdapterSpec(String destinationExpression) { + protected UdpMulticastOutboundChannelAdapterSpec(String destinationExpression) { this.target = new MulticastSendingMessageHandler(destinationExpression); } - UdpMulticastOutboundChannelAdapterSpec(Function, ?> destinationFunction) { + protected UdpMulticastOutboundChannelAdapterSpec(Function, ?> destinationFunction) { this.target = new MulticastSendingMessageHandler(new FunctionExpression<>(destinationFunction)); } diff --git a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/UdpUnicastOutboundChannelAdapterSpec.java b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/UdpUnicastOutboundChannelAdapterSpec.java index 81d7a3f699..ed14579d0e 100644 --- a/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/UdpUnicastOutboundChannelAdapterSpec.java +++ b/spring-integration-ip/src/main/java/org/springframework/integration/ip/dsl/UdpUnicastOutboundChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -25,21 +25,23 @@ import org.springframework.messaging.Message; * {@link org.springframework.integration.ip.udp.UnicastSendingMessageHandler}s. * * @author Gary Russell + * @author Artem Bilan + * * @since 5.0 * */ public class UdpUnicastOutboundChannelAdapterSpec extends AbstractUdpOutboundChannelAdapterSpec { - UdpUnicastOutboundChannelAdapterSpec(String host, int port) { + protected UdpUnicastOutboundChannelAdapterSpec(String host, int port) { super(host, port); } - UdpUnicastOutboundChannelAdapterSpec(Function, ?> destinationFunction) { + protected UdpUnicastOutboundChannelAdapterSpec(Function, ?> destinationFunction) { super(destinationFunction); } - UdpUnicastOutboundChannelAdapterSpec(String destinationExpression) { + protected UdpUnicastOutboundChannelAdapterSpec(String destinationExpression) { super(destinationExpression); } diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsDefaultListenerContainerSpec.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsDefaultListenerContainerSpec.java index 97ef6c69db..4139b48e07 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsDefaultListenerContainerSpec.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsDefaultListenerContainerSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -31,7 +31,7 @@ import org.springframework.util.backoff.BackOff; public class JmsDefaultListenerContainerSpec extends JmsListenerContainerSpec { - JmsDefaultListenerContainerSpec() { + protected JmsDefaultListenerContainerSpec() { super(DefaultMessageListenerContainer.class); } diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsDestinationAccessorSpec.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsDestinationAccessorSpec.java index 543e825875..58778b4480 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsDestinationAccessorSpec.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsDestinationAccessorSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -39,7 +39,7 @@ public abstract class JmsDestinationAccessorSpec implements ComponentsRegistration { - JmsInboundChannelSpecTemplateAware(ConnectionFactory connectionFactory) { + protected JmsInboundChannelSpecTemplateAware(ConnectionFactory connectionFactory) { super(connectionFactory); } diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsInboundGatewaySpec.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsInboundGatewaySpec.java index 14cca1d9a0..bf824be77b 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsInboundGatewaySpec.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsInboundGatewaySpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -42,7 +42,7 @@ import org.springframework.util.Assert; public class JmsInboundGatewaySpec> extends MessagingGatewaySpec { - JmsInboundGatewaySpec(AbstractMessageListenerContainer listenerContainer) { + protected JmsInboundGatewaySpec(AbstractMessageListenerContainer listenerContainer) { super(new JmsInboundGateway(listenerContainer, new ChannelPublishingJmsMessageListener())); this.target.getListener().setExpectReply(true); } @@ -202,7 +202,7 @@ public class JmsInboundGatewaySpec> private final S spec; - JmsInboundGatewayListenerContainerSpec(S spec) { + protected JmsInboundGatewayListenerContainerSpec(S spec) { super(spec.get()); this.spec = spec; this.spec.get().setAutoStartup(false); diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsListenerContainerSpec.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsListenerContainerSpec.java index 1ca0bf0267..ccf67919e7 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsListenerContainerSpec.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsListenerContainerSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -37,7 +37,7 @@ import org.springframework.util.ErrorHandler; public class JmsListenerContainerSpec, C extends AbstractMessageListenerContainer> extends JmsDestinationAccessorSpec { - JmsListenerContainerSpec(Class aClass) { + protected JmsListenerContainerSpec(Class aClass) { super(newInstance(aClass)); if (DefaultMessageListenerContainer.class.isAssignableFrom(aClass)) { this.target.setSessionTransacted(true); diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsMessageChannelSpec.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsMessageChannelSpec.java index c32a63752a..6a8af37a0c 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsMessageChannelSpec.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsMessageChannelSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -37,7 +37,7 @@ import org.springframework.util.ErrorHandler; */ public class JmsMessageChannelSpec> extends JmsPollableMessageChannelSpec { - JmsMessageChannelSpec(ConnectionFactory connectionFactory) { + protected JmsMessageChannelSpec(ConnectionFactory connectionFactory) { super(new JmsChannelFactoryBean(true), connectionFactory); } diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsMessageDrivenChannelAdapterSpec.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsMessageDrivenChannelAdapterSpec.java index ce4452bbd6..295b5ac6b9 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsMessageDrivenChannelAdapterSpec.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsMessageDrivenChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -44,7 +44,7 @@ import org.springframework.util.Assert; public class JmsMessageDrivenChannelAdapterSpec> extends MessageProducerSpec { - JmsMessageDrivenChannelAdapterSpec(AbstractMessageListenerContainer listenerContainer) { + protected JmsMessageDrivenChannelAdapterSpec(AbstractMessageListenerContainer listenerContainer) { super(new JmsMessageDrivenEndpoint(listenerContainer, new ChannelPublishingJmsMessageListener())); this.target.getListener().setExpectReply(false); } @@ -105,7 +105,7 @@ public class JmsMessageDrivenChannelAdapterSpec implements ComponentsRegistration { - JmsOutboundChannelSpecTemplateAware(ConnectionFactory connectionFactory) { + protected JmsOutboundChannelSpecTemplateAware(ConnectionFactory connectionFactory) { super(connectionFactory); } diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsOutboundGatewaySpec.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsOutboundGatewaySpec.java index 452c869a41..7df015b72a 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsOutboundGatewaySpec.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsOutboundGatewaySpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -41,7 +41,7 @@ import org.springframework.util.Assert; */ public class JmsOutboundGatewaySpec extends MessageHandlerSpec { - JmsOutboundGatewaySpec(ConnectionFactory connectionFactory) { + protected JmsOutboundGatewaySpec(ConnectionFactory connectionFactory) { this.target = new JmsOutboundGateway(); this.target.setConnectionFactory(connectionFactory); this.target.setRequiresReply(true); diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsPollableMessageChannelSpec.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsPollableMessageChannelSpec.java index e9884ff73a..9b5fb36c81 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsPollableMessageChannelSpec.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsPollableMessageChannelSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -41,13 +41,15 @@ import org.springframework.lang.Nullable; public class JmsPollableMessageChannelSpec> extends MessageChannelSpec { - protected final JmsChannelFactoryBean jmsChannelFactoryBean; // NOSONAR final + protected final JmsChannelFactoryBean jmsChannelFactoryBean; // NOSONAR - final - JmsPollableMessageChannelSpec(ConnectionFactory connectionFactory) { + protected JmsPollableMessageChannelSpec(ConnectionFactory connectionFactory) { this(new JmsChannelFactoryBean(false), connectionFactory); } - JmsPollableMessageChannelSpec(JmsChannelFactoryBean jmsChannelFactoryBean, ConnectionFactory connectionFactory) { + protected JmsPollableMessageChannelSpec(JmsChannelFactoryBean jmsChannelFactoryBean, + ConnectionFactory connectionFactory) { + this.jmsChannelFactoryBean = jmsChannelFactoryBean; this.jmsChannelFactoryBean.setConnectionFactory(connectionFactory); this.jmsChannelFactoryBean.setSingleton(false); @@ -95,9 +97,8 @@ public class JmsPollableMessageChannelSpec { - JmsPublishSubscribeMessageChannelSpec(ConnectionFactory connectionFactory) { + protected JmsPublishSubscribeMessageChannelSpec(ConnectionFactory connectionFactory) { super(connectionFactory); this.jmsChannelFactoryBean.setPubSubDomain(true); } diff --git a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsTemplateSpec.java b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsTemplateSpec.java index 6e5c73353d..026472a317 100644 --- a/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsTemplateSpec.java +++ b/spring-integration-jms/src/main/java/org/springframework/integration/jms/dsl/JmsTemplateSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -27,7 +27,7 @@ import org.springframework.jms.support.converter.MessageConverter; */ public class JmsTemplateSpec extends JmsDestinationAccessorSpec { - JmsTemplateSpec() { + protected JmsTemplateSpec() { super(new DynamicJmsTemplate()); } diff --git a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/dsl/JpaInboundChannelAdapterSpec.java b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/dsl/JpaInboundChannelAdapterSpec.java index 81bdeafbf4..d2592e8697 100644 --- a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/dsl/JpaInboundChannelAdapterSpec.java +++ b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/dsl/JpaInboundChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -38,9 +38,9 @@ public class JpaInboundChannelAdapterSpec extends MessageSourceSpec implements ComponentsRegistration { - private final JpaExecutor jpaExecutor; + protected final JpaExecutor jpaExecutor; // NOSONAR - final - JpaInboundChannelAdapterSpec(JpaExecutor jpaExecutor) { + protected JpaInboundChannelAdapterSpec(JpaExecutor jpaExecutor) { this.jpaExecutor = jpaExecutor; this.target = new JpaPollingChannelAdapter(this.jpaExecutor); } diff --git a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/dsl/JpaRetrievingOutboundGatewaySpec.java b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/dsl/JpaRetrievingOutboundGatewaySpec.java index 02d803db34..c2ce78f5ca 100644 --- a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/dsl/JpaRetrievingOutboundGatewaySpec.java +++ b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/dsl/JpaRetrievingOutboundGatewaySpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -32,7 +32,7 @@ import org.springframework.integration.jpa.support.OutboundGatewayType; */ public class JpaRetrievingOutboundGatewaySpec extends JpaBaseOutboundEndpointSpec { - JpaRetrievingOutboundGatewaySpec(JpaExecutor jpaExecutor) { + protected JpaRetrievingOutboundGatewaySpec(JpaExecutor jpaExecutor) { super(jpaExecutor); this.target.setGatewayType(OutboundGatewayType.RETRIEVING); this.target.setRequiresReply(true); diff --git a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/dsl/JpaUpdatingOutboundEndpointSpec.java b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/dsl/JpaUpdatingOutboundEndpointSpec.java index 784127b751..ef6ce62766 100644 --- a/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/dsl/JpaUpdatingOutboundEndpointSpec.java +++ b/spring-integration-jpa/src/main/java/org/springframework/integration/jpa/dsl/JpaUpdatingOutboundEndpointSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -30,11 +30,11 @@ import org.springframework.integration.jpa.support.PersistMode; */ public class JpaUpdatingOutboundEndpointSpec extends JpaBaseOutboundEndpointSpec { - JpaUpdatingOutboundEndpointSpec(JpaExecutor jpaExecutor) { + protected JpaUpdatingOutboundEndpointSpec(JpaExecutor jpaExecutor) { super(jpaExecutor); } - JpaUpdatingOutboundEndpointSpec producesReply(boolean producesReply) { + protected JpaUpdatingOutboundEndpointSpec producesReply(boolean producesReply) { this.target.setProducesReply(producesReply); if (producesReply) { this.target.setRequiresReply(true); diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/ImapIdleChannelAdapterSpec.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/ImapIdleChannelAdapterSpec.java index d61ceccb5e..eb04fc7667 100644 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/ImapIdleChannelAdapterSpec.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/ImapIdleChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2020 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. @@ -59,9 +59,9 @@ public class ImapIdleChannelAdapterSpec extends MessageProducerSpec implements ComponentsRegistration { - private final ImapMailReceiver receiver; + protected final ImapMailReceiver receiver; // NOSONAR - final - private final Map componentsToRegister = new LinkedHashMap<>(); + protected final Map componentsToRegister = new LinkedHashMap<>(); // NOSONAR - final private final List adviceChain = new LinkedList<>(); @@ -69,11 +69,11 @@ public class ImapIdleChannelAdapterSpec private boolean sessionProvided; - ImapIdleChannelAdapterSpec(ImapMailReceiver receiver) { + protected ImapIdleChannelAdapterSpec(ImapMailReceiver receiver) { this(receiver, false); } - ImapIdleChannelAdapterSpec(ImapMailReceiver receiver, boolean externalReceiver) { + protected ImapIdleChannelAdapterSpec(ImapMailReceiver receiver, boolean externalReceiver) { super(new ImapIdleChannelAdapter(receiver)); this.target.setAdviceChain(this.adviceChain); this.receiver = receiver; diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/ImapMailInboundChannelAdapterSpec.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/ImapMailInboundChannelAdapterSpec.java index a09671d514..177aa307d5 100644 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/ImapMailInboundChannelAdapterSpec.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/ImapMailInboundChannelAdapterSpec.java @@ -30,15 +30,15 @@ import org.springframework.integration.mail.SearchTermStrategy; public class ImapMailInboundChannelAdapterSpec extends MailInboundChannelAdapterSpec { - ImapMailInboundChannelAdapterSpec() { + protected ImapMailInboundChannelAdapterSpec() { super(new ImapMailReceiver()); } - ImapMailInboundChannelAdapterSpec(ImapMailReceiver imapMailReceiver) { + protected ImapMailInboundChannelAdapterSpec(ImapMailReceiver imapMailReceiver) { super(imapMailReceiver, true); } - ImapMailInboundChannelAdapterSpec(String url) { + protected ImapMailInboundChannelAdapterSpec(String url) { super(new ImapMailReceiver(url), false); } diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/MailSendingMessageHandlerSpec.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/MailSendingMessageHandlerSpec.java index eaed04f181..14a2c7d0e9 100644 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/MailSendingMessageHandlerSpec.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/MailSendingMessageHandlerSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2020 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. @@ -36,9 +36,9 @@ import org.springframework.mail.javamail.JavaMailSenderImpl; public class MailSendingMessageHandlerSpec extends MessageHandlerSpec { - private final JavaMailSenderImpl sender = new JavaMailSenderImpl(); + protected final JavaMailSenderImpl sender = new JavaMailSenderImpl(); // NOSONAR - final - MailSendingMessageHandlerSpec(@Nullable String host) { + protected MailSendingMessageHandlerSpec(@Nullable String host) { this.sender.setHost(host); this.target = new MailSendingMessageHandler(this.sender); } diff --git a/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/Pop3MailInboundChannelAdapterSpec.java b/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/Pop3MailInboundChannelAdapterSpec.java index 70daf6348d..c0eadcf4a5 100644 --- a/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/Pop3MailInboundChannelAdapterSpec.java +++ b/spring-integration-mail/src/main/java/org/springframework/integration/mail/dsl/Pop3MailInboundChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2020 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. @@ -28,23 +28,23 @@ import org.springframework.integration.mail.Pop3MailReceiver; public class Pop3MailInboundChannelAdapterSpec extends MailInboundChannelAdapterSpec { - Pop3MailInboundChannelAdapterSpec() { + protected Pop3MailInboundChannelAdapterSpec() { super(new Pop3MailReceiver()); } - Pop3MailInboundChannelAdapterSpec(Pop3MailReceiver receiver) { + protected Pop3MailInboundChannelAdapterSpec(Pop3MailReceiver receiver) { super(receiver, true); } - Pop3MailInboundChannelAdapterSpec(String url) { + protected Pop3MailInboundChannelAdapterSpec(String url) { super(new Pop3MailReceiver(url)); } - Pop3MailInboundChannelAdapterSpec(String host, String username, String password) { + protected Pop3MailInboundChannelAdapterSpec(String host, String username, String password) { super(new Pop3MailReceiver(host, username, password)); } - Pop3MailInboundChannelAdapterSpec(String host, int port, String username, String password) { + protected Pop3MailInboundChannelAdapterSpec(String host, int port, String username, String password) { super(new Pop3MailReceiver(host, port, username, password)); } diff --git a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/dsl/MongoDbOutboundGatewaySpec.java b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/dsl/MongoDbOutboundGatewaySpec.java index 4658f53673..ff59898a34 100644 --- a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/dsl/MongoDbOutboundGatewaySpec.java +++ b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/dsl/MongoDbOutboundGatewaySpec.java @@ -40,12 +40,12 @@ import org.springframework.messaging.Message; public class MongoDbOutboundGatewaySpec extends MessageHandlerSpec { - MongoDbOutboundGatewaySpec(MongoDatabaseFactory mongoDbFactory, MongoConverter mongoConverter) { + protected MongoDbOutboundGatewaySpec(MongoDatabaseFactory mongoDbFactory, MongoConverter mongoConverter) { this.target = new MongoDbOutboundGateway(mongoDbFactory, mongoConverter); this.target.setRequiresReply(true); } - MongoDbOutboundGatewaySpec(MongoOperations mongoTemplate) { + protected MongoDbOutboundGatewaySpec(MongoOperations mongoTemplate) { this.target = new MongoDbOutboundGateway(mongoTemplate); this.target.setRequiresReply(true); } diff --git a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/dsl/ReactiveMongoDbMessageHandlerSpec.java b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/dsl/ReactiveMongoDbMessageHandlerSpec.java index f5fbb5dda8..f4ab5e64db 100644 --- a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/dsl/ReactiveMongoDbMessageHandlerSpec.java +++ b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/dsl/ReactiveMongoDbMessageHandlerSpec.java @@ -44,13 +44,13 @@ public class ReactiveMongoDbMessageHandlerSpec extends MessageHandlerSpec implements ComponentsRegistration { - private final ReactiveMongoDbStoringMessageHandler messageHandler; + protected final ReactiveMongoDbStoringMessageHandler messageHandler; // NOSONAR - final - ReactiveMongoDbMessageHandlerSpec(ReactiveMongoDatabaseFactory mongoDbFactory) { + protected ReactiveMongoDbMessageHandlerSpec(ReactiveMongoDatabaseFactory mongoDbFactory) { this(new ReactiveMongoDbStoringMessageHandler(mongoDbFactory)); } - ReactiveMongoDbMessageHandlerSpec(ReactiveMongoOperations reactiveMongoOperations) { + protected ReactiveMongoDbMessageHandlerSpec(ReactiveMongoOperations reactiveMongoOperations) { this(new ReactiveMongoDbStoringMessageHandler(reactiveMongoOperations)); } diff --git a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/dsl/ReactiveMongoDbMessageSourceSpec.java b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/dsl/ReactiveMongoDbMessageSourceSpec.java index 59eb8c3718..174686fc56 100644 --- a/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/dsl/ReactiveMongoDbMessageSourceSpec.java +++ b/spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/dsl/ReactiveMongoDbMessageSourceSpec.java @@ -37,12 +37,15 @@ import org.springframework.integration.mongodb.inbound.ReactiveMongoDbMessageSou public class ReactiveMongoDbMessageSourceSpec extends MessageSourceSpec { - ReactiveMongoDbMessageSourceSpec(ReactiveMongoDatabaseFactory reactiveMongoDatabaseFactory, + protected ReactiveMongoDbMessageSourceSpec(ReactiveMongoDatabaseFactory reactiveMongoDatabaseFactory, Expression queryExpression) { + this.target = new ReactiveMongoDbMessageSource(reactiveMongoDatabaseFactory, queryExpression); } - ReactiveMongoDbMessageSourceSpec(ReactiveMongoOperations reactiveMongoTemplate, Expression queryExpression) { + protected ReactiveMongoDbMessageSourceSpec(ReactiveMongoOperations reactiveMongoTemplate, + Expression queryExpression) { + this.target = new ReactiveMongoDbMessageSource(reactiveMongoTemplate, queryExpression); } diff --git a/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/dsl/RSocketInboundGatewaySpec.java b/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/dsl/RSocketInboundGatewaySpec.java index b0a5d9566e..0c7cd14909 100644 --- a/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/dsl/RSocketInboundGatewaySpec.java +++ b/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/dsl/RSocketInboundGatewaySpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2019-2020 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. @@ -32,7 +32,7 @@ import org.springframework.messaging.rsocket.RSocketStrategies; */ public class RSocketInboundGatewaySpec extends MessagingGatewaySpec { - RSocketInboundGatewaySpec(String... path) { + protected RSocketInboundGatewaySpec(String... path) { super(new RSocketInboundGateway(path)); } diff --git a/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/dsl/RSocketOutboundGatewaySpec.java b/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/dsl/RSocketOutboundGatewaySpec.java index 4ad7b968b2..48bf76437c 100644 --- a/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/dsl/RSocketOutboundGatewaySpec.java +++ b/spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/dsl/RSocketOutboundGatewaySpec.java @@ -38,11 +38,11 @@ import org.springframework.util.MimeType; */ public class RSocketOutboundGatewaySpec extends MessageHandlerSpec { - RSocketOutboundGatewaySpec(String route, Object... routeVariables) { + protected RSocketOutboundGatewaySpec(String route, Object... routeVariables) { this.target = new RSocketOutboundGateway(route, routeVariables); } - RSocketOutboundGatewaySpec(Expression routeExpression) { + protected RSocketOutboundGatewaySpec(Expression routeExpression) { this.target = new RSocketOutboundGateway(routeExpression); } diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpInboundChannelAdapterSpec.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpInboundChannelAdapterSpec.java index d7077fa155..38bf43647c 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpInboundChannelAdapterSpec.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpInboundChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2020 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. @@ -42,7 +42,9 @@ public class SftpInboundChannelAdapterSpec extends RemoteFileInboundChannelAdapterSpec { - SftpInboundChannelAdapterSpec(SessionFactory sessionFactory, Comparator comparator) { + protected SftpInboundChannelAdapterSpec(SessionFactory sessionFactory, + Comparator comparator) { + super(new SftpInboundFileSynchronizer(sessionFactory)); this.target = new SftpInboundFileSynchronizingMessageSource(this.synchronizer, comparator); } diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpMessageHandlerSpec.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpMessageHandlerSpec.java index e0d150fbfc..715b040b66 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpMessageHandlerSpec.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpMessageHandlerSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2020 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. @@ -34,16 +34,20 @@ import com.jcraft.jsch.ChannelSftp; public class SftpMessageHandlerSpec extends FileTransferringMessageHandlerSpec { - SftpMessageHandlerSpec(SessionFactory sessionFactory) { + protected SftpMessageHandlerSpec(SessionFactory sessionFactory) { this.target = new SftpMessageHandler(sessionFactory); } - SftpMessageHandlerSpec(RemoteFileTemplate remoteFileTemplate) { + protected SftpMessageHandlerSpec(RemoteFileTemplate remoteFileTemplate) { this.target = new SftpMessageHandler(remoteFileTemplate.getSessionFactory()); } - SftpMessageHandlerSpec(RemoteFileTemplate remoteFileTemplate, FileExistsMode fileExistsMode) { - this.target = new SftpMessageHandler(new SftpRemoteFileTemplate(remoteFileTemplate.getSessionFactory()), fileExistsMode); + protected SftpMessageHandlerSpec(RemoteFileTemplate remoteFileTemplate, + FileExistsMode fileExistsMode) { + + this.target = + new SftpMessageHandler(new SftpRemoteFileTemplate(remoteFileTemplate.getSessionFactory()), + fileExistsMode); } } diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpOutboundGatewaySpec.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpOutboundGatewaySpec.java index e76ba25833..02df28e1f4 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpOutboundGatewaySpec.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpOutboundGatewaySpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2019 the original author or authors. + * Copyright 2014-2020 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. @@ -26,13 +26,14 @@ import com.jcraft.jsch.ChannelSftp; /** * @author Artem Bilan * @author Gary Russell + * * @since 5.0 */ public class SftpOutboundGatewaySpec extends RemoteFileOutboundGatewaySpec { - SftpOutboundGatewaySpec(AbstractRemoteFileOutboundGateway outboundGateway) { + protected SftpOutboundGatewaySpec(AbstractRemoteFileOutboundGateway outboundGateway) { super(outboundGateway); } diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpStreamingInboundChannelAdapterSpec.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpStreamingInboundChannelAdapterSpec.java index 49856e4853..c12c71ca97 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpStreamingInboundChannelAdapterSpec.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/dsl/SftpStreamingInboundChannelAdapterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2020 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. @@ -32,6 +32,7 @@ import com.jcraft.jsch.ChannelSftp.LsEntry; /** * @author Gary Russell + * * @since 5.0 * */ @@ -39,8 +40,9 @@ public class SftpStreamingInboundChannelAdapterSpec extends RemoteFileStreamingInboundChannelAdapterSpec { - SftpStreamingInboundChannelAdapterSpec(RemoteFileTemplate remoteFileTemplate, + protected SftpStreamingInboundChannelAdapterSpec(RemoteFileTemplate remoteFileTemplate, Comparator comparator) { + this.target = new SftpStreamingMessageSource(remoteFileTemplate, comparator); } @@ -66,7 +68,6 @@ public class SftpStreamingInboundChannelAdapterSpec return filter(composeFilters(new SftpRegexPatternFileListFilter(regex))); } - @SuppressWarnings("unchecked") private CompositeFileListFilter composeFilters(FileListFilter fileListFilter) { CompositeFileListFilter compositeFileListFilter = new CompositeFileListFilter<>(); compositeFileListFilter.addFilters(fileListFilter, diff --git a/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/dsl/WebFluxInboundEndpointSpec.java b/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/dsl/WebFluxInboundEndpointSpec.java index 9f017eeb01..6f66ca74c7 100644 --- a/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/dsl/WebFluxInboundEndpointSpec.java +++ b/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/dsl/WebFluxInboundEndpointSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2020 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. @@ -32,7 +32,7 @@ import org.springframework.web.reactive.accept.RequestedContentTypeResolver; public class WebFluxInboundEndpointSpec extends HttpInboundEndpointSupportSpec { - WebFluxInboundEndpointSpec(WebFluxInboundEndpoint gateway, String... path) { + protected WebFluxInboundEndpointSpec(WebFluxInboundEndpoint gateway, String... path) { super(gateway, path); } diff --git a/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/dsl/WebFluxMessageHandlerSpec.java b/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/dsl/WebFluxMessageHandlerSpec.java index 38725ea378..431851d942 100644 --- a/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/dsl/WebFluxMessageHandlerSpec.java +++ b/spring-integration-webflux/src/main/java/org/springframework/integration/webflux/dsl/WebFluxMessageHandlerSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2020 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. @@ -46,17 +46,17 @@ import org.springframework.web.reactive.function.client.WebClient; public class WebFluxMessageHandlerSpec extends BaseHttpMessageHandlerSpec { - private final WebClient webClient; + protected final WebClient webClient; // NOSONAR - final - WebFluxMessageHandlerSpec(URI uri, WebClient webClient) { + protected WebFluxMessageHandlerSpec(URI uri, WebClient webClient) { this(new ValueExpression<>(uri), webClient); } - WebFluxMessageHandlerSpec(String uri, WebClient webClient) { + protected WebFluxMessageHandlerSpec(String uri, WebClient webClient) { this(new LiteralExpression(uri), webClient); } - WebFluxMessageHandlerSpec(Expression uriExpression, WebClient webClient) { + protected WebFluxMessageHandlerSpec(Expression uriExpression, WebClient webClient) { super(new WebFluxRequestExecutingMessageHandler(uriExpression, webClient)); this.webClient = webClient; } diff --git a/src/reference/asciidoc/dsl.adoc b/src/reference/asciidoc/dsl.adoc index 909c554d4c..4efa05459e 100644 --- a/src/reference/asciidoc/dsl.adoc +++ b/src/reference/asciidoc/dsl.adoc @@ -1202,3 +1202,63 @@ That `errorRecovererFlow` can be used as follows: private Function errorRecovererFlowGateway; ---- ==== + +[[java-dsl-extensions]] +=== DSL Extensions + +Starting with version 5.3, an `IntegrationFlowExtension` has been introduced to allow extension of the existing Java DSL with custom or composed EIP-operators. +All that is needed is an extension of this class that provides methods which can be used in the `IntegrationFlow` bean definitions. +The extension class can also be used for custom `IntegrationComponentSpec` configuration; for example, missed or default options can be implemented in the existing `IntegrationComponentSpec` extension. +The sample below demonstrates a composite custom operator and usage of an `AggregatorSpec` extension for a default custom `outputProcessor`: + +==== +[source,java] +---- +public class CustomIntegrationFlowDefinition + extends IntegrationFlowExtension { + + public CustomIntegrationFlowDefinition upperCaseAfterSplit() { + return split() + .transform("payload.toUpperCase()"); + } + + public CustomIntegrationFlowDefinition customAggregate(Consumer aggregator) { + return register(new CustomAggregatorSpec(), aggregator); + } + +} + +public class CustomAggregatorSpec extends AggregatorSpec { + + CustomAggregatorSpec() { + outputProcessor(group -> + group.getMessages() + .stream() + .map(Message::getPayload) + .map(String.class::cast) + .collect(Collectors.joining(", "))); + } + +} +---- +==== + +For a method chain flow the new DSL operator in these extensions must return the extension class. +This way a target `IntegrationFlow` definition will work with new and existing DSL operators: + +==== +[source,java] +---- +@Bean +public IntegrationFlow customFlowDefinition() { + return + new CustomIntegrationFlowDefinition() + .log() + .upperCaseAfterSplit() + .channel("innerChannel") + .customAggregate(customAggregatorSpec -> + customAggregatorSpec.expireGroupsUponCompletion(true)) + .logAndReply(); +} +---- +==== diff --git a/src/reference/asciidoc/whats-new.adoc b/src/reference/asciidoc/whats-new.adoc index b6c3a8f5cd..be8a4600f6 100644 --- a/src/reference/asciidoc/whats-new.adoc +++ b/src/reference/asciidoc/whats-new.adoc @@ -27,18 +27,20 @@ See its JavaDocs and <<./graph.adoc#integration-graph,Integration Graph>> for mo The `ReactiveMessageHandler` is now natively supported in the framework. See <<./reactive-streams.adoc/reactive-message-handler,ReactiveMessageHandler>> for more information. +[[x5.3-java-dsl-extensions]] +==== Java DSL Extensions + +A new `IntegrationFlowExtension` API has been introduced to allow extension of the existing Java DSL with custom or composed EIP-operators. +This also can be used to introduce customizers for any out-of-the-box `IntegrationComponentSpec` extensions. +See <<./dsl.adoc/java-dsl-extensions,DSL Extensions>> for more information. + + [[x5.3-mongodb-reactive-channel-adapters]] ==== MongoDB Reactive Channel Adapters `spring-integration-mongodb` module now provides channel adapter implementations for Reactive MongoDB driver support in Spring Data. See <<./mongodb.adoc#mongodb-reactive-channel-adapters,MongoDB Reactive Channel Adapters>> for more information. -[[x5.3-AbstractCorrelatingMessageHandler]] -==== Aggregator Changes - -If the `MessageGroupProcessor` returns a `Message`, the `MessageBuilder.popSequenceDetails()` is performed on the output message if the `sequenceDetails` matches with first message of group. -See <<./aggregator.adoc#aggregator-api,Aggregator Programming Model>> for more information. - [[x5.3-general]] === General Changes @@ -48,6 +50,9 @@ See <<./gateway.adoc/gateway-calling-default-methods,Invoking `default` Methods> Internal components (such as `_org.springframework.integration.errorLogger`) now have a shortened name when they are represented in the integration graph. See <<./graph.adoc#integration-graph,Integration Graph>> for more information. +In the aggregator, when the `MessageGroupProcessor` returns a `Message`, the `MessageBuilder.popSequenceDetails()` is performed on the output message if the `sequenceDetails` matches the header in the first message of the group. +See <<./aggregator.adoc#aggregator-api,Aggregator Programming Model>> for more information. + [[x5.3-amqp]] === AMQP Changes