diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/dsl/AmqpTests.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/dsl/AmqpTests.java index 8109278375..816acd3fe4 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/dsl/AmqpTests.java +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/dsl/AmqpTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2020 the original author or authors. + * Copyright 2014-2022 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,7 +59,6 @@ import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; import org.springframework.integration.dsl.IntegrationFlowBuilder; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.Transformers; import org.springframework.integration.dsl.context.IntegrationFlowContext; import org.springframework.integration.support.MessageBuilder; @@ -161,7 +160,7 @@ public class AmqpTests { @Test public void testTemplateChannelTransacted() { - IntegrationFlowBuilder flow = IntegrationFlows.from(Amqp.channel("testTemplateChannelTransacted", + IntegrationFlowBuilder flow = IntegrationFlow.from(Amqp.channel("testTemplateChannelTransacted", this.rabbitConnectionFactory) .autoStartup(false) .templateChannelTransacted(true)); @@ -235,7 +234,7 @@ public class AmqpTests { @Test void testContentTypeOverrideWithReplyHeadersMappedLast() { IntegrationFlow testFlow = - IntegrationFlows + IntegrationFlow .from(Amqp.inboundGateway(this.rabbitConnectionFactory, this.amqpQueue2) .replyHeadersMappedLast(true)) .transform(Transformers.fromJson()) @@ -300,7 +299,7 @@ public class AmqpTests { @Bean public IntegrationFlow amqpFlow(ConnectionFactory rabbitConnectionFactory, AmqpTemplate amqpTemplate) { - return IntegrationFlows + return IntegrationFlow .from(Amqp.inboundGateway(rabbitConnectionFactory, amqpTemplate, queue()) .id("amqpInboundGateway") .configureContainer(c -> c @@ -315,7 +314,7 @@ public class AmqpTests { // syntax only public IntegrationFlow amqpDMLCFlow(ConnectionFactory rabbitConnectionFactory, AmqpTemplate amqpTemplate) { - return IntegrationFlows + return IntegrationFlow .from(Amqp.inboundGateway(new DirectMessageListenerContainer()) .id("amqpInboundGateway") .configureContainer(c -> c @@ -329,7 +328,7 @@ public class AmqpTests { @Bean public IntegrationFlow amqpOutboundFlow(ConnectionFactory rabbitConnectionFactory, AmqpTemplate amqpTemplate) { - return IntegrationFlows.from(Amqp.channel("amqpOutboundInput", rabbitConnectionFactory)) + return IntegrationFlow.from(Amqp.channel("amqpOutboundInput", rabbitConnectionFactory)) .handle(Amqp.outboundAdapter(amqpTemplate).routingKeyExpression("headers.routingKey")) .get(); } @@ -346,7 +345,7 @@ public class AmqpTests { @Bean public IntegrationFlow amqpInboundFlow(ConnectionFactory rabbitConnectionFactory) { - return IntegrationFlows.from(Amqp.inboundAdapter(rabbitConnectionFactory, fooQueue()) + return IntegrationFlow.from(Amqp.inboundAdapter(rabbitConnectionFactory, fooQueue()) .configureContainer(container -> container.consumerBatchEnabled(true) .batchSize(2)) .batchMode(BatchMode.EXTRACT_PAYLOADS) @@ -384,7 +383,7 @@ public class AmqpTests { @Bean public IntegrationFlow inboundWithExceptionFlow(ConnectionFactory cf) { - return IntegrationFlows.from(Amqp.inboundAdapter(cf, exQueue()) + return IntegrationFlow.from(Amqp.inboundAdapter(cf, exQueue()) .configureContainer(c -> c.defaultRequeueRejected(false)) .errorChannel("errors.input")) .handle(m -> { @@ -421,7 +420,7 @@ public class AmqpTests { @Bean public IntegrationFlow inboundWithConvExceptionFlow(ConnectionFactory cf) { - return IntegrationFlows.from(Amqp.inboundAdapter(cf, exConvQueue()) + return IntegrationFlow.from(Amqp.inboundAdapter(cf, exConvQueue()) .configureContainer(c -> c.defaultRequeueRejected(false)) .messageConverter(new SimpleMessageConverter() { diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/inbound/AmqpMessageSourceIntegrationTests.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/inbound/AmqpMessageSourceIntegrationTests.java index 4ab3471b34..b59ef85fba 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/inbound/AmqpMessageSourceIntegrationTests.java +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/inbound/AmqpMessageSourceIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2022 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. @@ -54,7 +54,6 @@ import org.springframework.integration.annotation.ServiceActivator; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.core.MessageSource; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.Pollers; import org.springframework.integration.support.AbstractIntegrationMessageBuilder; import org.springframework.messaging.handler.annotation.Header; @@ -198,7 +197,7 @@ public class AmqpMessageSourceIntegrationTests { @Bean public IntegrationFlow flow() { - return IntegrationFlows.from(Amqp.inboundPolledAdapter(connectionFactory(), DSL_QUEUE), + return IntegrationFlow.from(Amqp.inboundPolledAdapter(connectionFactory(), DSL_QUEUE), e -> e.poller(Pollers.fixedDelay(100)).autoStartup(false)) .handle(p -> { this.fromDsl = p.getPayload(); @@ -209,7 +208,7 @@ public class AmqpMessageSourceIntegrationTests { @Bean public IntegrationFlow messageSourceChannelFlow() { - return IntegrationFlows.from(interceptedSource(), + return IntegrationFlow.from(interceptedSource(), e -> e.poller(Pollers.fixedDelay(100)).autoStartup(false)) .handle(p -> { this.fromInterceptedSource = p.getPayload(); diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/support/BoundRabbitChannelAdviceIntegrationTests.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/support/BoundRabbitChannelAdviceIntegrationTests.java index 574b5f8fda..90704b5c86 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/support/BoundRabbitChannelAdviceIntegrationTests.java +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/support/BoundRabbitChannelAdviceIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2022 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,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.integration.amqp.dsl.Amqp; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.test.util.TestUtils; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; @@ -108,7 +107,7 @@ public class BoundRabbitChannelAdviceIntegrationTests { @Bean public IntegrationFlow flow(RabbitTemplate template, BoundRabbitChannelAdvice advice) { - return IntegrationFlows.from(Gate.class) + return IntegrationFlow.from(Gate.class) .split(s -> s.delimiters(",") .advice(advice)) .transform(String::toUpperCase) @@ -118,7 +117,7 @@ public class BoundRabbitChannelAdviceIntegrationTests { @Bean public IntegrationFlow listener(CachingConnectionFactory ccf) { - return IntegrationFlows.from(Amqp.inboundAdapter(ccf, QUEUE)) + return IntegrationFlow.from(Amqp.inboundAdapter(ccf, QUEUE)) .handle(m -> { received.add((String) m.getPayload()); this.latch.countDown(); diff --git a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/support/BoundRabbitChannelAdviceTests.java b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/support/BoundRabbitChannelAdviceTests.java index 079ac13122..c96e3fd4e6 100644 --- a/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/support/BoundRabbitChannelAdviceTests.java +++ b/spring-integration-amqp/src/test/java/org/springframework/integration/amqp/support/BoundRabbitChannelAdviceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2019 the original author or authors. + * Copyright 2018-2022 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,7 +43,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.integration.amqp.dsl.Amqp; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; import com.rabbitmq.client.Channel; @@ -121,7 +120,7 @@ public class BoundRabbitChannelAdviceTests { @Bean public IntegrationFlow flow(RabbitTemplate template) { - return IntegrationFlows.from(Gate.class) + return IntegrationFlow.from(Gate.class) .split(s -> s.delimiters(",") .advice(new BoundRabbitChannelAdvice(template, Duration.ofSeconds(10)))) .transform(String::toUpperCase) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/BaseIntegrationFlowDefinition.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/BaseIntegrationFlowDefinition.java index 121e1bcfb3..0a8c49ff7d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/BaseIntegrationFlowDefinition.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/BaseIntegrationFlowDefinition.java @@ -426,7 +426,7 @@ public abstract class BaseIntegrationFlowDefinition flowBuilder = IntegrationFlows.from(messageChannel); + IntegrationFlowDefinition flowBuilder = IntegrationFlow.from(messageChannel); flow.configure(flowBuilder); addComponent(flowBuilder.get()); } @@ -457,7 +457,7 @@ public abstract class BaseIntegrationFlowDefinition wireTapConfigurer) { DirectChannel internalWireTapChannel = new DirectChannel(); - addComponent(IntegrationFlows.from(internalWireTapChannel).channel(wireTapChannel).get()); + addComponent(IntegrationFlow.from(internalWireTapChannel).channel(wireTapChannel).get()); return wireTap(internalWireTapChannel, wireTapConfigurer); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/BroadcastPublishSubscribeSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/BroadcastPublishSubscribeSpec.java index eceff70477..d56f17b9c5 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/BroadcastPublishSubscribeSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/BroadcastPublishSubscribeSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 the original author or authors. + * Copyright 2020-2022 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,7 +58,7 @@ public class BroadcastPublishSubscribeSpec Assert.notNull(subFlow, "'subFlow' must not be null"); IntegrationFlowBuilder flowBuilder = - IntegrationFlows.from(this.target) + IntegrationFlow.from(this.target) .bridge(consumer -> consumer.order(this.order++)); MessageChannel subFlowInput = subFlow.getInputChannel(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/EndpointSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/EndpointSpec.java index 0b4a53aa5b..cd6ef54d7d 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/EndpointSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/EndpointSpec.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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. @@ -163,7 +163,7 @@ public abstract class EndpointSpec, F extends Be MessageChannel messageChannel = subFlow.getInputChannel(); if (messageChannel == null) { messageChannel = new DirectChannel(); - IntegrationFlowDefinition flowBuilder = IntegrationFlows.from(messageChannel); + IntegrationFlowDefinition flowBuilder = IntegrationFlow.from(messageChannel); subFlow.configure(flowBuilder); this.componentsToRegister.put(evaluateInternalBuilder ? flowBuilder.get() : flowBuilder, null); } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlow.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlow.java index 8c7085a3e6..7b9a9a5191 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlow.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlow.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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. @@ -17,8 +17,29 @@ package org.springframework.integration.dsl; import java.util.Map; +import java.util.function.Consumer; +import java.util.function.Supplier; +import org.reactivestreams.Publisher; + +import org.springframework.aop.framework.Advised; +import org.springframework.beans.factory.BeanCreationException; +import org.springframework.integration.channel.DirectChannel; +import org.springframework.integration.channel.FluxMessageChannel; +import org.springframework.integration.channel.PublishSubscribeChannel; +import org.springframework.integration.config.ConsumerEndpointFactoryBean; +import org.springframework.integration.core.MessageSource; +import org.springframework.integration.dsl.support.FixedSubscriberChannelPrototype; +import org.springframework.integration.dsl.support.MessageChannelReference; +import org.springframework.integration.endpoint.AbstractMessageSource; +import org.springframework.integration.endpoint.MessageProducerSupport; +import org.springframework.integration.gateway.MessagingGatewaySupport; +import org.springframework.integration.handler.AbstractMessageProducingHandler; +import org.springframework.lang.Nullable; +import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; +import org.springframework.messaging.MessageHandler; +import org.springframework.util.Assert; /** * The main Integration DSL abstraction. @@ -29,7 +50,7 @@ import org.springframework.messaging.MessageChannel; *
  *  @Bean
  *  public IntegrationFlow fileReadingFlow() {
- *      return IntegrationFlows
+ *      return IntegrationFlow
  *             .from(Files.inboundAdapter(tmpDir.getRoot()), e -> e.poller(Pollers.fixedDelay(100)))
  *             .transform(Files.fileToString())
  *             .channel(MessageChannels.queue("fileReadingResultChannel"))
@@ -67,6 +88,9 @@ import org.springframework.messaging.MessageChannel;
  * 
* * @author Artem Bilan + * @author Gary Russell + * @author Oleg Zhurakousky + * @author Artem Vozhdayenko * * @since 5.0 * @@ -103,4 +127,386 @@ public interface IntegrationFlow { return null; } + /** + * Populate the {@link MessageChannel} name to the new {@link IntegrationFlowBuilder} chain. + * The {@link IntegrationFlow} {@code inputChannel}. + * @param messageChannelName the name of existing {@link MessageChannel} bean. + * The new {@link DirectChannel} bean will be created on context startup + * if there is no bean with this name. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + */ + static IntegrationFlowBuilder from(String messageChannelName) { + return from(new MessageChannelReference(messageChannelName)); + } + + /** + * Populate the {@link MessageChannel} object to the + * {@link IntegrationFlowBuilder} chain using the fluent API from {@link MessageChannelSpec}. + * The {@link IntegrationFlow} {@code inputChannel}. + * @param messageChannelSpec the MessageChannelSpec to populate {@link MessageChannel} instance. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + * @see MessageChannels + */ + static IntegrationFlowBuilder from(MessageChannelSpec messageChannelSpec) { + Assert.notNull(messageChannelSpec, "'messageChannelSpec' must not be null"); + return from(messageChannelSpec.get()); + } + + /** + * Populate the {@link MessageChannel} name to the new {@link IntegrationFlowBuilder} chain. + * Typically for the {@link org.springframework.integration.channel.FixedSubscriberChannel} together + * with {@code fixedSubscriber = true}. + * The {@link IntegrationFlow} {@code inputChannel}. + * @param messageChannelName the name for {@link DirectChannel} or + * {@link org.springframework.integration.channel.FixedSubscriberChannel} + * to be created on context startup, not reference. + * The {@link MessageChannel} depends on the {@code fixedSubscriber} boolean argument. + * @param fixedSubscriber the boolean flag to determine if result {@link MessageChannel} should + * be {@link DirectChannel}, if {@code false} or + * {@link org.springframework.integration.channel.FixedSubscriberChannel}, if {@code true}. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + * @see DirectChannel + * @see org.springframework.integration.channel.FixedSubscriberChannel + */ + static IntegrationFlowBuilder from(String messageChannelName, boolean fixedSubscriber) { + return fixedSubscriber + ? from(new FixedSubscriberChannelPrototype(messageChannelName)) + : from(messageChannelName); + } + + /** + * Populate the provided {@link MessageChannel} object to the {@link IntegrationFlowBuilder} chain. + * The {@link IntegrationFlow} {@code inputChannel}. + * @param messageChannel the {@link MessageChannel} to populate. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + */ + static IntegrationFlowBuilder from(MessageChannel messageChannel) { + return new IntegrationFlowBuilder().channel(messageChannel); + } + + /** + * Populate the {@link MessageSource} object to the {@link IntegrationFlowBuilder} chain + * using the fluent API from the provided {@link MessageSourceSpec}. + * The {@link IntegrationFlow} {@code startMessageSource}. + * @param messageSourceSpec the {@link MessageSourceSpec} to use. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + * @see MessageSourceSpec and its implementations. + */ + static IntegrationFlowBuilder from(MessageSourceSpec> messageSourceSpec) { + return from(messageSourceSpec, null); + } + + /** + * Populate the {@link MessageSource} object to the {@link IntegrationFlowBuilder} chain + * using the fluent API from the provided {@link MessageSourceSpec}. + * The {@link IntegrationFlow} {@code startMessageSource}. + * @param messageSourceSpec the {@link MessageSourceSpec} to use. + * @param endpointConfigurer the {@link Consumer} to provide more options for the + * {@link org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean}. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + * @see MessageSourceSpec + * @see SourcePollingChannelAdapterSpec + */ + static IntegrationFlowBuilder from(MessageSourceSpec> messageSourceSpec, + Consumer endpointConfigurer) { + Assert.notNull(messageSourceSpec, "'messageSourceSpec' must not be null"); + return from(messageSourceSpec.get(), endpointConfigurer, registerComponents(messageSourceSpec)); + } + + /** + * Provides {@link Supplier} as source of messages to the integration flow which will + * be triggered by the application context's default poller (which must be declared). + * @param messageSource the {@link Supplier} to populate. + * @param the supplier type. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + * @see Supplier + */ + static IntegrationFlowBuilder fromSupplier(Supplier messageSource) { + return fromSupplier(messageSource, null); + } + + /** + * Provides {@link Supplier} as source of messages to the integration flow. + * which will be triggered by a provided + * {@link org.springframework.integration.endpoint.SourcePollingChannelAdapter}. + * @param messageSource the {@link Supplier} to populate. + * @param endpointConfigurer the {@link Consumer} to provide more options for the + * {@link org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean}. + * @param the supplier type. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + * @see Supplier + */ + static IntegrationFlowBuilder fromSupplier(Supplier messageSource, + Consumer endpointConfigurer) { + + Assert.notNull(messageSource, "'messageSource' must not be null"); + return from(new AbstractMessageSource() { + + @Override + protected Object doReceive() { + return messageSource.get(); + } + + @Override + public String getComponentType() { + return "inbound-channel-adapter"; + } + + }, endpointConfigurer); + } + + /** + * Populate the provided {@link MessageSource} object to the {@link IntegrationFlowBuilder} chain. + * The {@link IntegrationFlow} {@code startMessageSource}. + * @param messageSource the {@link MessageSource} to populate. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + * @see MessageSource + */ + static IntegrationFlowBuilder from(MessageSource messageSource) { + return from(messageSource, null); + } + + /** + * Populate the provided {@link MessageSource} object to the {@link IntegrationFlowBuilder} chain. + * The {@link IntegrationFlow} {@code startMessageSource}. + * In addition use {@link SourcePollingChannelAdapterSpec} to provide options for the underlying + * {@link org.springframework.integration.endpoint.SourcePollingChannelAdapter} endpoint. + * @param messageSource the {@link MessageSource} to populate. + * @param endpointConfigurer the {@link Consumer} to provide more options for the + * {@link org.springframework.integration.config.SourcePollingChannelAdapterFactoryBean}. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + * @see MessageSource + * @see SourcePollingChannelAdapterSpec + */ + static IntegrationFlowBuilder from(MessageSource messageSource, + @Nullable Consumer endpointConfigurer) { + + return from(messageSource, endpointConfigurer, null); + } + + private static IntegrationFlowBuilder from(MessageSource messageSource, + @Nullable Consumer endpointConfigurer, + @Nullable IntegrationFlowBuilder integrationFlowBuilderArg) { + + IntegrationFlowBuilder integrationFlowBuilder = integrationFlowBuilderArg; + SourcePollingChannelAdapterSpec spec = new SourcePollingChannelAdapterSpec(messageSource); + if (endpointConfigurer != null) { + endpointConfigurer.accept(spec); + } + if (integrationFlowBuilder == null) { + integrationFlowBuilder = new IntegrationFlowBuilder(); + } + return integrationFlowBuilder.addComponent(spec) + .currentComponent(spec); + } + + /** + * Populate the {@link MessageProducerSupport} object to the {@link IntegrationFlowBuilder} chain + * using the fluent API from the {@link MessageProducerSpec}. + * The {@link IntegrationFlow} {@code startMessageProducer}. + * @param messageProducerSpec the {@link MessageProducerSpec} to use. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + * @see MessageProducerSpec + */ + static IntegrationFlowBuilder from(MessageProducerSpec messageProducerSpec) { + return from(messageProducerSpec.get(), registerComponents(messageProducerSpec)); + } + + /** + * Populate the provided {@link MessageProducerSupport} object to the {@link IntegrationFlowBuilder} chain. + * The {@link IntegrationFlow} {@code startMessageProducer}. + * @param messageProducer the {@link MessageProducerSupport} to populate. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + */ + static IntegrationFlowBuilder from(MessageProducerSupport messageProducer) { + return from(messageProducer, null); + } + + private static IntegrationFlowBuilder from(MessageProducerSupport messageProducer, + @Nullable IntegrationFlowBuilder integrationFlowBuilderArg) { + + IntegrationFlowBuilder integrationFlowBuilder = integrationFlowBuilderArg; + MessageChannel outputChannel = messageProducer.getOutputChannel(); + if (outputChannel == null) { + outputChannel = new DirectChannel(); + messageProducer.setOutputChannel(outputChannel); + } + if (integrationFlowBuilder == null) { + integrationFlowBuilder = from(outputChannel); + } + else { + integrationFlowBuilder.channel(outputChannel); + } + return integrationFlowBuilder.addComponent(messageProducer); + } + + /** + * Populate the {@link MessagingGatewaySupport} object to the {@link IntegrationFlowBuilder} chain + * using the fluent API from the {@link MessagingGatewaySpec}. + * The {@link IntegrationFlow} {@code startMessagingGateway}. + * @param inboundGatewaySpec the {@link MessagingGatewaySpec} to use. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + */ + static IntegrationFlowBuilder from(MessagingGatewaySpec inboundGatewaySpec) { + return from(inboundGatewaySpec.get(), registerComponents(inboundGatewaySpec)); + } + + /** + * Populate the provided {@link MessagingGatewaySupport} object to the {@link IntegrationFlowBuilder} chain. + * The {@link IntegrationFlow} {@code startMessageProducer}. + * @param inboundGateway the {@link MessagingGatewaySupport} to populate. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + */ + static IntegrationFlowBuilder from(MessagingGatewaySupport inboundGateway) { + return from(inboundGateway, null); + } + + /** + * Populate the {@link MessageChannel} to the new {@link IntegrationFlowBuilder} + * chain, which becomes as a {@code requestChannel} for the Messaging Gateway(s) built + * on the provided service interface. + *

A gateway proxy bean for provided service interface is registered under a name + * from the + * {@link org.springframework.integration.annotation.MessagingGateway#name()} if present + * or from the {@link IntegrationFlow} bean name plus {@code .gateway} suffix. + * @param serviceInterface the service interface class with an optional + * {@link org.springframework.integration.annotation.MessagingGateway} annotation. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + */ + static IntegrationFlowBuilder from(Class serviceInterface) { + return from(serviceInterface, null); + } + + /** + * Populate the {@link MessageChannel} to the new {@link IntegrationFlowBuilder} + * chain, which becomes as a {@code requestChannel} for the Messaging Gateway(s) built + * on the provided service interface. + *

A gateway proxy bean for provided service interface is based on the options + * configured via provided {@link Consumer}. + * @param serviceInterface the service interface class with an optional + * {@link org.springframework.integration.annotation.MessagingGateway} annotation. + * @param endpointConfigurer the {@link Consumer} to configure proxy bean for gateway. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + */ + static IntegrationFlowBuilder from(Class serviceInterface, + @Nullable Consumer endpointConfigurer) { + + GatewayProxySpec gatewayProxySpec = new GatewayProxySpec(serviceInterface); + if (endpointConfigurer != null) { + endpointConfigurer.accept(gatewayProxySpec); + } + + return from(gatewayProxySpec.getGatewayRequestChannel()) + .addComponent(gatewayProxySpec.getGatewayProxyFactoryBean()); + } + + /** + * Populate a {@link FluxMessageChannel} to the {@link IntegrationFlowBuilder} chain + * and subscribe it to the provided {@link Publisher}. + * @param publisher the {@link Publisher} to subscribe to. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + */ + @SuppressWarnings("overloads") + static IntegrationFlowBuilder from(Publisher> publisher) { + FluxMessageChannel reactiveChannel = new FluxMessageChannel(); + reactiveChannel.subscribeTo(publisher); + return from((MessageChannel) reactiveChannel); + } + + /** + * Start the flow with a composition from the {@link IntegrationFlow}. + * @param other the {@link IntegrationFlow} from which to compose. + * @return new {@link IntegrationFlowBuilder}. + * @since 6.0 + */ + @SuppressWarnings("overloads") + static IntegrationFlowBuilder from(IntegrationFlow other) { + Map integrationComponents = other.getIntegrationComponents(); + Assert.notNull(integrationComponents, () -> + "The provided integration flow to compose from '" + other + + "' must be declared as a bean in the application context"); + Object lastIntegrationComponentFromOther = + integrationComponents.keySet().stream().reduce((prev, next) -> next).orElse(null); + if (lastIntegrationComponentFromOther instanceof MessageChannel) { + return from((MessageChannel) lastIntegrationComponentFromOther); + } + else if (lastIntegrationComponentFromOther instanceof ConsumerEndpointFactoryBean) { + MessageHandler handler = ((ConsumerEndpointFactoryBean) lastIntegrationComponentFromOther).getHandler(); + handler = extractProxyTarget(handler); + if (handler instanceof AbstractMessageProducingHandler) { + return buildFlowFromOutputChannel((AbstractMessageProducingHandler) handler); + } + lastIntegrationComponentFromOther = handler; // for the exception message below + } + throw new BeanCreationException("The 'IntegrationFlow' to start from must end with " + + "a 'MessageChannel' or reply-producing endpoint to let the result from that flow to be " + + "processed in this instance. The provided flow ends with: " + lastIntegrationComponentFromOther); + } + + private static IntegrationFlowBuilder buildFlowFromOutputChannel(AbstractMessageProducingHandler handler) { + MessageChannel outputChannel = handler.getOutputChannel(); + if (outputChannel == null) { + outputChannel = new PublishSubscribeChannel(); + handler.setOutputChannel(outputChannel); + } + return from(outputChannel); + } + + private static IntegrationFlowBuilder from(MessagingGatewaySupport inboundGateway, + @Nullable IntegrationFlowBuilder integrationFlowBuilderArg) { + + IntegrationFlowBuilder integrationFlowBuilder = integrationFlowBuilderArg; + MessageChannel outputChannel = inboundGateway.getRequestChannel(); + if (outputChannel == null) { + outputChannel = new DirectChannel(); + inboundGateway.setRequestChannel(outputChannel); + } + if (integrationFlowBuilder == null) { + integrationFlowBuilder = from(outputChannel); + } + else { + integrationFlowBuilder.channel(outputChannel); + } + return integrationFlowBuilder.addComponent(inboundGateway); + } + + private static IntegrationFlowBuilder registerComponents(Object spec) { + if (spec instanceof ComponentsRegistration) { + return new IntegrationFlowBuilder() + .addComponents(((ComponentsRegistration) spec).getComponentsToRegister()); + } + return null; + } + + @SuppressWarnings("unchecked") + private static T extractProxyTarget(T target) { + if (!(target instanceof Advised)) { + return target; + } + Advised advised = (Advised) target; + try { + return (T) extractProxyTarget(advised.getTargetSource().getTarget()); + } + catch (Exception e) { + throw new BeanCreationException("Could not extract target", e); + } + } + } diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowAdapter.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowAdapter.java index 6e46d18ce4..3c107d3008 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowAdapter.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlowAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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. @@ -133,69 +133,69 @@ public abstract class IntegrationFlowAdapter implements IntegrationFlow, Managea } protected IntegrationFlowDefinition from(String messageChannelName) { - return IntegrationFlows.from(messageChannelName); + return IntegrationFlow.from(messageChannelName); } protected IntegrationFlowDefinition from(MessageChannel messageChannel) { - return IntegrationFlows.from(messageChannel); + return IntegrationFlow.from(messageChannel); } protected IntegrationFlowDefinition from(String messageChannelName, boolean fixedSubscriber) { - return IntegrationFlows.from(messageChannelName, fixedSubscriber); + return IntegrationFlow.from(messageChannelName, fixedSubscriber); } protected IntegrationFlowDefinition from(MessageSourceSpec> messageSourceSpec, Consumer endpointConfigurer) { - return IntegrationFlows.from(messageSourceSpec, endpointConfigurer); + return IntegrationFlow.from(messageSourceSpec, endpointConfigurer); } protected IntegrationFlowDefinition from(MessageSource messageSource, Consumer endpointConfigurer) { - return IntegrationFlows.from(messageSource, endpointConfigurer); + return IntegrationFlow.from(messageSource, endpointConfigurer); } protected IntegrationFlowDefinition from(MessageProducerSupport messageProducer) { - return IntegrationFlows.from(messageProducer); + return IntegrationFlow.from(messageProducer); } protected IntegrationFlowDefinition from(MessageSource messageSource) { - return IntegrationFlows.from(messageSource); + return IntegrationFlow.from(messageSource); } protected IntegrationFlowDefinition from(MessagingGatewaySupport inboundGateway) { - return IntegrationFlows.from(inboundGateway); + return IntegrationFlow.from(inboundGateway); } protected IntegrationFlowDefinition from(MessageChannelSpec messageChannelSpec) { - return IntegrationFlows.from(messageChannelSpec); + return IntegrationFlow.from(messageChannelSpec); } protected IntegrationFlowDefinition from(MessageProducerSpec messageProducerSpec) { - return IntegrationFlows.from(messageProducerSpec); + return IntegrationFlow.from(messageProducerSpec); } protected IntegrationFlowDefinition from(MessageSourceSpec> messageSourceSpec) { - return IntegrationFlows.from(messageSourceSpec); + return IntegrationFlow.from(messageSourceSpec); } protected IntegrationFlowDefinition from(MessagingGatewaySpec inboundGatewaySpec) { - return IntegrationFlows.from(inboundGatewaySpec); + return IntegrationFlow.from(inboundGatewaySpec); } protected IntegrationFlowBuilder fromSupplier(Supplier messageSource) { - return IntegrationFlows.fromSupplier(messageSource); + return IntegrationFlow.fromSupplier(messageSource); } protected IntegrationFlowBuilder fromSupplier(Supplier messageSource, Consumer endpointConfigurer) { - return IntegrationFlows.fromSupplier(messageSource, endpointConfigurer); + return IntegrationFlow.fromSupplier(messageSource, endpointConfigurer); } protected IntegrationFlowBuilder from(Class serviceInterface) { - return IntegrationFlows.from(serviceInterface); + return IntegrationFlow.from(serviceInterface); } /** @@ -208,11 +208,11 @@ public abstract class IntegrationFlowAdapter implements IntegrationFlow, Managea protected IntegrationFlowBuilder from(Class serviceInterface, @Nullable Consumer endpointConfigurer) { - return IntegrationFlows.from(serviceInterface, endpointConfigurer); + return IntegrationFlow.from(serviceInterface, endpointConfigurer); } protected IntegrationFlowBuilder from(Publisher> publisher) { - return IntegrationFlows.from(publisher); + return IntegrationFlow.from(publisher); } protected abstract IntegrationFlowDefinition buildFlow(); diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlows.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlows.java index ccf59eb92d..56393baf14 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlows.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/IntegrationFlows.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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. @@ -16,30 +16,19 @@ package org.springframework.integration.dsl; -import java.util.Map; import java.util.function.Consumer; import java.util.function.Supplier; import org.reactivestreams.Publisher; -import org.springframework.aop.framework.Advised; -import org.springframework.beans.factory.BeanCreationException; import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.channel.FluxMessageChannel; -import org.springframework.integration.channel.PublishSubscribeChannel; -import org.springframework.integration.config.ConsumerEndpointFactoryBean; import org.springframework.integration.core.MessageSource; -import org.springframework.integration.dsl.support.FixedSubscriberChannelPrototype; -import org.springframework.integration.dsl.support.MessageChannelReference; -import org.springframework.integration.endpoint.AbstractMessageSource; import org.springframework.integration.endpoint.MessageProducerSupport; import org.springframework.integration.gateway.MessagingGatewaySupport; -import org.springframework.integration.handler.AbstractMessageProducingHandler; import org.springframework.lang.Nullable; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; -import org.springframework.messaging.MessageHandler; -import org.springframework.util.Assert; /** * The central factory for fluent {@link IntegrationFlowBuilder} API. @@ -51,7 +40,10 @@ import org.springframework.util.Assert; * @since 5.0 * * @see org.springframework.integration.dsl.context.IntegrationFlowBeanPostProcessor + * + * @deprecated Since version 6.0, this factory is not recommended to use as it shall be removed in the following versions. Use fluent API methods straight from {@link IntegrationFlow} interface. */ +@Deprecated(since = "6.0", forRemoval = true) public final class IntegrationFlows { /** @@ -63,7 +55,7 @@ public final class IntegrationFlows { * @return new {@link IntegrationFlowBuilder}. */ public static IntegrationFlowBuilder from(String messageChannelName) { - return from(new MessageChannelReference(messageChannelName)); + return IntegrationFlow.from(messageChannelName); } /** @@ -83,9 +75,7 @@ public final class IntegrationFlows { * @see org.springframework.integration.channel.FixedSubscriberChannel */ public static IntegrationFlowBuilder from(String messageChannelName, boolean fixedSubscriber) { - return fixedSubscriber - ? from(new FixedSubscriberChannelPrototype(messageChannelName)) - : from(messageChannelName); + return IntegrationFlow.from(messageChannelName, fixedSubscriber); } /** @@ -97,8 +87,7 @@ public final class IntegrationFlows { * @see org.springframework.integration.dsl.MessageChannels */ public static IntegrationFlowBuilder from(MessageChannelSpec messageChannelSpec) { - Assert.notNull(messageChannelSpec, "'messageChannelSpec' must not be null"); - return from(messageChannelSpec.get()); + return IntegrationFlow.from(messageChannelSpec); } /** @@ -108,7 +97,7 @@ public final class IntegrationFlows { * @return new {@link IntegrationFlowBuilder}. */ public static IntegrationFlowBuilder from(MessageChannel messageChannel) { - return new IntegrationFlowBuilder().channel(messageChannel); + return IntegrationFlow.from(messageChannel); } /** @@ -120,7 +109,7 @@ public final class IntegrationFlows { * @see MessageSourceSpec and its implementations. */ public static IntegrationFlowBuilder from(MessageSourceSpec> messageSourceSpec) { - return from(messageSourceSpec, null); + return IntegrationFlow.from(messageSourceSpec); } /** @@ -136,8 +125,7 @@ public final class IntegrationFlows { */ public static IntegrationFlowBuilder from(MessageSourceSpec> messageSourceSpec, Consumer endpointConfigurer) { - Assert.notNull(messageSourceSpec, "'messageSourceSpec' must not be null"); - return from(messageSourceSpec.get(), endpointConfigurer, registerComponents(messageSourceSpec)); + return IntegrationFlow.from(messageSourceSpec, endpointConfigurer); } /** @@ -149,7 +137,7 @@ public final class IntegrationFlows { * @see Supplier */ public static IntegrationFlowBuilder fromSupplier(Supplier messageSource) { - return fromSupplier(messageSource, null); + return IntegrationFlow.fromSupplier(messageSource); } /** @@ -165,21 +153,7 @@ public final class IntegrationFlows { */ public static IntegrationFlowBuilder fromSupplier(Supplier messageSource, Consumer endpointConfigurer) { - - Assert.notNull(messageSource, "'messageSource' must not be null"); - return from(new AbstractMessageSource() { - - @Override - protected Object doReceive() { - return messageSource.get(); - } - - @Override - public String getComponentType() { - return "inbound-channel-adapter"; - } - - }, endpointConfigurer); + return IntegrationFlow.fromSupplier(messageSource, endpointConfigurer); } /** @@ -190,7 +164,7 @@ public final class IntegrationFlows { * @see MessageSource */ public static IntegrationFlowBuilder from(MessageSource messageSource) { - return from(messageSource, null); + return IntegrationFlow.from(messageSource); } /** @@ -207,24 +181,7 @@ public final class IntegrationFlows { */ public static IntegrationFlowBuilder from(MessageSource messageSource, @Nullable Consumer endpointConfigurer) { - - return from(messageSource, endpointConfigurer, null); - } - - private static IntegrationFlowBuilder from(MessageSource messageSource, - @Nullable Consumer endpointConfigurer, - @Nullable IntegrationFlowBuilder integrationFlowBuilderArg) { - - IntegrationFlowBuilder integrationFlowBuilder = integrationFlowBuilderArg; - SourcePollingChannelAdapterSpec spec = new SourcePollingChannelAdapterSpec(messageSource); - if (endpointConfigurer != null) { - endpointConfigurer.accept(spec); - } - if (integrationFlowBuilder == null) { - integrationFlowBuilder = new IntegrationFlowBuilder(); - } - return integrationFlowBuilder.addComponent(spec) - .currentComponent(spec); + return IntegrationFlow.from(messageSource, endpointConfigurer); } /** @@ -236,7 +193,7 @@ public final class IntegrationFlows { * @see MessageProducerSpec */ public static IntegrationFlowBuilder from(MessageProducerSpec messageProducerSpec) { - return from(messageProducerSpec.get(), registerComponents(messageProducerSpec)); + return IntegrationFlow.from(messageProducerSpec); } /** @@ -246,25 +203,7 @@ public final class IntegrationFlows { * @return new {@link IntegrationFlowBuilder}. */ public static IntegrationFlowBuilder from(MessageProducerSupport messageProducer) { - return from(messageProducer, null); - } - - private static IntegrationFlowBuilder from(MessageProducerSupport messageProducer, - @Nullable IntegrationFlowBuilder integrationFlowBuilderArg) { - - IntegrationFlowBuilder integrationFlowBuilder = integrationFlowBuilderArg; - MessageChannel outputChannel = messageProducer.getOutputChannel(); - if (outputChannel == null) { - outputChannel = new DirectChannel(); - messageProducer.setOutputChannel(outputChannel); - } - if (integrationFlowBuilder == null) { - integrationFlowBuilder = from(outputChannel); - } - else { - integrationFlowBuilder.channel(outputChannel); - } - return integrationFlowBuilder.addComponent(messageProducer); + return IntegrationFlow.from(messageProducer); } /** @@ -275,7 +214,7 @@ public final class IntegrationFlows { * @return new {@link IntegrationFlowBuilder}. */ public static IntegrationFlowBuilder from(MessagingGatewaySpec inboundGatewaySpec) { - return from(inboundGatewaySpec.get(), registerComponents(inboundGatewaySpec)); + return IntegrationFlow.from(inboundGatewaySpec); } /** @@ -285,7 +224,7 @@ public final class IntegrationFlows { * @return new {@link IntegrationFlowBuilder}. */ public static IntegrationFlowBuilder from(MessagingGatewaySupport inboundGateway) { - return from(inboundGateway, null); + return IntegrationFlow.from(inboundGateway); } /** @@ -301,7 +240,7 @@ public final class IntegrationFlows { * @return new {@link IntegrationFlowBuilder}. */ public static IntegrationFlowBuilder from(Class serviceInterface) { - return from(serviceInterface, null); + return IntegrationFlow.from(serviceInterface); } /** @@ -318,14 +257,7 @@ public final class IntegrationFlows { */ public static IntegrationFlowBuilder from(Class serviceInterface, @Nullable Consumer endpointConfigurer) { - - GatewayProxySpec gatewayProxySpec = new GatewayProxySpec(serviceInterface); - if (endpointConfigurer != null) { - endpointConfigurer.accept(gatewayProxySpec); - } - - return from(gatewayProxySpec.getGatewayRequestChannel()) - .addComponent(gatewayProxySpec.getGatewayProxyFactoryBean()); + return IntegrationFlow.from(serviceInterface, endpointConfigurer); } @@ -337,9 +269,7 @@ public final class IntegrationFlows { */ @SuppressWarnings("overloads") public static IntegrationFlowBuilder from(Publisher> publisher) { - FluxMessageChannel reactiveChannel = new FluxMessageChannel(); - reactiveChannel.subscribeTo(publisher); - return from((MessageChannel) reactiveChannel); + return IntegrationFlow.from(publisher); } /** @@ -350,75 +280,7 @@ public final class IntegrationFlows { */ @SuppressWarnings("overloads") public static IntegrationFlowBuilder from(IntegrationFlow other) { - Map integrationComponents = other.getIntegrationComponents(); - Assert.notNull(integrationComponents, () -> - "The provided integration flow to compose from '" + other + - "' must be declared as a bean in the application context"); - Object lastIntegrationComponentFromOther = - integrationComponents.keySet().stream().reduce((prev, next) -> next).orElse(null); - if (lastIntegrationComponentFromOther instanceof MessageChannel) { - return from((MessageChannel) lastIntegrationComponentFromOther); - } - else if (lastIntegrationComponentFromOther instanceof ConsumerEndpointFactoryBean) { - MessageHandler handler = ((ConsumerEndpointFactoryBean) lastIntegrationComponentFromOther).getHandler(); - handler = extractProxyTarget(handler); - if (handler instanceof AbstractMessageProducingHandler) { - return buildFlowFromOutputChannel((AbstractMessageProducingHandler) handler); - } - lastIntegrationComponentFromOther = handler; // for the exception message below - } - throw new BeanCreationException("The 'IntegrationFlow' to start from must end with " + - "a 'MessageChannel' or reply-producing endpoint to let the result from that flow to be " + - "processed in this instance. The provided flow ends with: " + lastIntegrationComponentFromOther); - } - - private static IntegrationFlowBuilder buildFlowFromOutputChannel(AbstractMessageProducingHandler handler) { - MessageChannel outputChannel = handler.getOutputChannel(); - if (outputChannel == null) { - outputChannel = new PublishSubscribeChannel(); - handler.setOutputChannel(outputChannel); - } - return from(outputChannel); - } - - private static IntegrationFlowBuilder from(MessagingGatewaySupport inboundGateway, - @Nullable IntegrationFlowBuilder integrationFlowBuilderArg) { - - IntegrationFlowBuilder integrationFlowBuilder = integrationFlowBuilderArg; - MessageChannel outputChannel = inboundGateway.getRequestChannel(); - if (outputChannel == null) { - outputChannel = new DirectChannel(); - inboundGateway.setRequestChannel(outputChannel); - } - if (integrationFlowBuilder == null) { - integrationFlowBuilder = from(outputChannel); - } - else { - integrationFlowBuilder.channel(outputChannel); - } - return integrationFlowBuilder.addComponent(inboundGateway); - } - - private static IntegrationFlowBuilder registerComponents(Object spec) { - if (spec instanceof ComponentsRegistration) { - return new IntegrationFlowBuilder() - .addComponents(((ComponentsRegistration) spec).getComponentsToRegister()); - } - return null; - } - - @SuppressWarnings("unchecked") - private static T extractProxyTarget(T target) { - if (!(target instanceof Advised)) { - return target; - } - Advised advised = (Advised) target; - try { - return (T) extractProxyTarget(advised.getTargetSource().getTarget()); - } - catch (Exception e) { - throw new BeanCreationException("Could not extract target", e); - } + return IntegrationFlow.from(other); } private IntegrationFlows() { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/StandardIntegrationFlow.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/StandardIntegrationFlow.java index 4838326b68..7b1fdb69fe 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/StandardIntegrationFlow.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/StandardIntegrationFlow.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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. @@ -62,7 +62,7 @@ import org.springframework.messaging.MessageChannel; * * @since 5.0 * - * @see IntegrationFlows + * @see IntegrationFlow * @see org.springframework.integration.dsl.context.IntegrationFlowBeanPostProcessor * @see org.springframework.integration.dsl.context.IntegrationFlowContext * @see SmartLifecycle diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/context/IntegrationFlowBeanPostProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/context/IntegrationFlowBeanPostProcessor.java index b341d4031c..a712752fe8 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/context/IntegrationFlowBeanPostProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/context/IntegrationFlowBeanPostProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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. @@ -65,7 +65,6 @@ import org.springframework.integration.dsl.IntegrationComponentSpec; import org.springframework.integration.dsl.IntegrationFlow; import org.springframework.integration.dsl.IntegrationFlowAdapter; import org.springframework.integration.dsl.IntegrationFlowBuilder; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.SourcePollingChannelAdapterSpec; import org.springframework.integration.dsl.StandardIntegrationFlow; import org.springframework.integration.dsl.support.MessageChannelReference; @@ -309,7 +308,7 @@ public class IntegrationFlowBeanPostProcessor * see its javadocs for more information. */ private Object processIntegrationFlowImpl(IntegrationFlow flow, String beanName) { - IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(beanName + ".input"); + IntegrationFlowBuilder flowBuilder = IntegrationFlow.from(beanName + ".input"); flow.configure(flowBuilder); diff --git a/spring-integration-core/src/main/kotlin/org/springframework/integration/dsl/IntegrationFlowDsl.kt b/spring-integration-core/src/main/kotlin/org/springframework/integration/dsl/IntegrationFlowDsl.kt index 9085803a95..17d500410b 100644 --- a/spring-integration-core/src/main/kotlin/org/springframework/integration/dsl/IntegrationFlowDsl.kt +++ b/spring-integration-core/src/main/kotlin/org/springframework/integration/dsl/IntegrationFlowDsl.kt @@ -38,8 +38,8 @@ fun integrationFlow(flow: KotlinIntegrationFlowDefinition.() -> Unit) = } /** - * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] - - * `IntegrationFlows.from(Class, Consumer)` factory method. + * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] - + * `IntegrationFlow.from(Class, Consumer)` factory method. * * @author Artem Bilan */ @@ -47,121 +47,121 @@ inline fun integrationFlow( crossinline gateway: GatewayProxySpec.() -> Unit = {}, flow: KotlinIntegrationFlowDefinition.() -> Unit): IntegrationFlow { - val flowBuilder = IntegrationFlows.from(T::class.java) { gateway(it) } + val flowBuilder = IntegrationFlow.from(T::class.java) { gateway(it) } KotlinIntegrationFlowDefinition(flowBuilder).flow() return flowBuilder.get() } /** - * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] - - * `IntegrationFlows.from(String, Boolean)` factory method. + * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] - + * `IntegrationFlow.from(String, Boolean)` factory method. * * @author Artem Bilan */ fun integrationFlow(channelName: String, fixedSubscriber: Boolean = false, flow: KotlinIntegrationFlowDefinition.() -> Unit) = - buildIntegrationFlow(IntegrationFlows.from(channelName, fixedSubscriber), flow) + buildIntegrationFlow(IntegrationFlow.from(channelName, fixedSubscriber), flow) /** - * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] - - * `IntegrationFlows.from(MessageChannel)` factory method. + * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] - + * `IntegrationFlow.from(MessageChannel)` factory method. * * @author Artem Bilan */ fun integrationFlow(channel: MessageChannel, flow: KotlinIntegrationFlowDefinition.() -> Unit) = - buildIntegrationFlow(IntegrationFlows.from(channel), flow) + buildIntegrationFlow(IntegrationFlow.from(channel), flow) /** - * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] - - * `IntegrationFlows.from(MessageSource<*>, Consumer)` factory method. + * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] - + * `IntegrationFlow.from(MessageSource<*>, Consumer)` factory method. * * @author Artem Bilan */ fun integrationFlow(messageSource: MessageSource<*>, options: SourcePollingChannelAdapterSpec.() -> Unit = {}, flow: KotlinIntegrationFlowDefinition.() -> Unit) = - buildIntegrationFlow(IntegrationFlows.from(messageSource) { options(it) }, flow) + buildIntegrationFlow(IntegrationFlow.from(messageSource) { options(it) }, flow) /** - * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] - - * `IntegrationFlows.from(MessageSourceSpec<*>, Consumer)` factory method. + * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] - + * `IntegrationFlow.from(MessageSourceSpec<*>, Consumer)` factory method. * * @author Artem Bilan */ fun integrationFlow(messageSource: MessageSourceSpec<*, out MessageSource<*>>, options: SourcePollingChannelAdapterSpec.() -> Unit = {}, flow: KotlinIntegrationFlowDefinition.() -> Unit) = - buildIntegrationFlow(IntegrationFlows.from(messageSource, options), flow) + buildIntegrationFlow(IntegrationFlow.from(messageSource, options), flow) /** - * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] - - * `IntegrationFlows.from(Supplier<*>, Consumer)` factory method. + * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] - + * `IntegrationFlow.from(Supplier<*>, Consumer)` factory method. * * @author Artem Bilan */ fun integrationFlow(source: () -> Any, options: SourcePollingChannelAdapterSpec.() -> Unit = {}, flow: KotlinIntegrationFlowDefinition.() -> Unit) = - buildIntegrationFlow(IntegrationFlows.fromSupplier(source, options), flow) + buildIntegrationFlow(IntegrationFlow.fromSupplier(source, options), flow) /** - * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] - - * `IntegrationFlows.from(Publisher>)` factory method. + * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] - + * `IntegrationFlow.from(Publisher>)` factory method. * * @author Artem Bilan */ fun integrationFlow(publisher: Publisher>, flow: KotlinIntegrationFlowDefinition.() -> Unit) = - buildIntegrationFlow(IntegrationFlows.from(publisher), flow) + buildIntegrationFlow(IntegrationFlow.from(publisher), flow) /** - * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] - - * `IntegrationFlows.from(MessagingGatewaySupport)` factory method. + * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] - + * `IntegrationFlow.from(MessagingGatewaySupport)` factory method. * * @author Artem Bilan */ fun integrationFlow(gateway: MessagingGatewaySupport, flow: KotlinIntegrationFlowDefinition.() -> Unit) = - buildIntegrationFlow(IntegrationFlows.from(gateway), flow) + buildIntegrationFlow(IntegrationFlow.from(gateway), flow) /** - * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] - - * `IntegrationFlows.from(MessagingGatewaySpec<*, *>)` factory method. + * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] - + * `IntegrationFlow.from(MessagingGatewaySpec<*, *>)` factory method. * * @author Artem Bilan */ fun integrationFlow(gatewaySpec: MessagingGatewaySpec<*, *>, flow: KotlinIntegrationFlowDefinition.() -> Unit) = - buildIntegrationFlow(IntegrationFlows.from(gatewaySpec), flow) + buildIntegrationFlow(IntegrationFlow.from(gatewaySpec), flow) /** - * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] - - * `IntegrationFlows.from(MessageProducerSupport)` factory method. + * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] - + * `IntegrationFlow.from(MessageProducerSupport)` factory method. * * @author Artem Bilan */ fun integrationFlow(producer: MessageProducerSupport, flow: KotlinIntegrationFlowDefinition.() -> Unit) = - buildIntegrationFlow(IntegrationFlows.from(producer), flow) + buildIntegrationFlow(IntegrationFlow.from(producer), flow) /** - * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] - - * `IntegrationFlows.from(MessageProducerSpec<*, *>)` factory method. + * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] - + * `IntegrationFlow.from(MessageProducerSpec<*, *>)` factory method. * * @author Artem Bilan */ fun integrationFlow(producerSpec: MessageProducerSpec<*, *>, flow: KotlinIntegrationFlowDefinition.() -> Unit) = - buildIntegrationFlow(IntegrationFlows.from(producerSpec), flow) + buildIntegrationFlow(IntegrationFlow.from(producerSpec), flow) /** - * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlows.from] - - * `IntegrationFlows.from(IntegrationFlow)` factory method. + * Functional [IntegrationFlow] definition in Kotlin DSL for [IntegrationFlow.from] - + * `IntegrationFlow.from(IntegrationFlow)` factory method. * * @author Artem Bilan * * @since 5.5.8 */ fun integrationFlow(sourceFlow: IntegrationFlow, flow: KotlinIntegrationFlowDefinition.() -> Unit) = - buildIntegrationFlow(IntegrationFlows.from(sourceFlow), flow) + buildIntegrationFlow(IntegrationFlow.from(sourceFlow), flow) diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/composition/IntegrationFlowCompositionTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/composition/IntegrationFlowCompositionTests.java index a120688993..37a9a3af26 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dsl/composition/IntegrationFlowCompositionTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/composition/IntegrationFlowCompositionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2021 the original author or authors. + * Copyright 2021-2022 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,6 @@ import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.Pollers; import org.springframework.integration.dsl.context.IntegrationFlowContext; import org.springframework.integration.scheduling.PollerMetadata; @@ -124,14 +123,14 @@ public class IntegrationFlowCompositionTests { IntegrationFlow startFlow = f -> f.handle(m -> { }); assertThatIllegalArgumentException() - .isThrownBy(() -> IntegrationFlows.from(startFlow)) + .isThrownBy(() -> IntegrationFlow.from(startFlow)) .withMessageContaining("must be declared as a bean in the application context"); IntegrationFlowContext.IntegrationFlowRegistration startRegistration = this.integrationFlowContext.registration(startFlow).register(); assertThatExceptionOfType(BeanCreationException.class) - .isThrownBy(() -> IntegrationFlows.from(startRegistration.getIntegrationFlow())) + .isThrownBy(() -> IntegrationFlow.from(startRegistration.getIntegrationFlow())) .withMessageContaining("The 'IntegrationFlow' to start from must end with " + "a 'MessageChannel' or reply-producing endpoint"); @@ -175,14 +174,14 @@ public class IntegrationFlowCompositionTests { @Bean IntegrationFlow templateSourceFlow() { - return IntegrationFlows.fromSupplier(() -> "test data") + return IntegrationFlow.fromSupplier(() -> "test data") .channel("sourceChannel") .get(); } @Bean IntegrationFlow compositionMainFlow(IntegrationFlow templateSourceFlow) { - return IntegrationFlows.from(templateSourceFlow) + return IntegrationFlow.from(templateSourceFlow) .transform(String::toUpperCase) .channel(c -> c.queue("compositionMainFlowResult")) .get(); @@ -196,7 +195,7 @@ public class IntegrationFlowCompositionTests { @Bean IntegrationFlow middleFlow(IntegrationFlow firstFlow, IntegrationFlow lastFlow) { - return IntegrationFlows.from(firstFlow) + return IntegrationFlow.from(firstFlow) .transform(p -> p + ", and middle flow") .to(lastFlow); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/correlation/CorrelationHandlerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/correlation/CorrelationHandlerTests.java index f2c12c5656..b786d79ed9 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dsl/correlation/CorrelationHandlerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/correlation/CorrelationHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2022 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,6 @@ import org.springframework.integration.aggregator.HeaderAttributeCorrelationStra import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannelSpec; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.dsl.Transformers; @@ -249,7 +248,7 @@ public class CorrelationHandlerTests { @Bean public IntegrationFlow splitAggregateFlow() { - return IntegrationFlows.from("splitAggregateInput", true) + return IntegrationFlow.from("splitAggregateInput", true) .transform(Transformers.toJson(ObjectToJsonTransformer.ResultType.NODE)) .split((splitter) -> splitter .discardFlow((subFlow) -> subFlow.channel((c) -> c.queue("discardChannel")))) @@ -312,7 +311,7 @@ public class CorrelationHandlerTests { @Bean public IntegrationFlow releaseBarrierFlow(MessageTriggerAction barrierTriggerAction) { - return IntegrationFlows.from(releaseChannel()) + return IntegrationFlow.from(releaseChannel()) .trigger(barrierTriggerAction, e -> e.poller(p -> p.fixedDelay(100))) .get(); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/flows/IntegrationFlowTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/flows/IntegrationFlowTests.java index a427242a50..6d2580f420 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dsl/flows/IntegrationFlowTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/flows/IntegrationFlowTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 the original author or authors. + * Copyright 2016-2022 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. @@ -60,7 +60,6 @@ import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.context.IntegrationContextUtils; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.dsl.Pollers; import org.springframework.integration.dsl.Transformers; @@ -570,7 +569,7 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow supplierFlow() { - return IntegrationFlows.fromSupplier(stringSupplier(), c -> c.id("stringSupplierEndpoint")) + return IntegrationFlow.fromSupplier(stringSupplier(), c -> c.id("stringSupplierEndpoint")) .transform(toUpperCaseFunction()) .channel("suppliedChannel") .get(); @@ -602,7 +601,7 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow supplierFlow2() { - return IntegrationFlows.fromSupplier(() -> "foo", + return IntegrationFlow.fromSupplier(() -> "foo", c -> c.poller(Pollers.fixedDelay(100).maxMessagesPerPoll(1))) .transform(String::toUpperCase) .channel("suppliedChannel2") @@ -622,7 +621,7 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow controlBusFlow() { - return IntegrationFlows.from(ControlBusGateway.class, (gateway) -> gateway.beanName("controlBusGateway")) + return IntegrationFlow.from(ControlBusGateway.class, (gateway) -> gateway.beanName("controlBusGateway")) .controlBus((endpoint) -> endpoint.id("controlBus")) .get(); } @@ -661,7 +660,7 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow flow2() { - return IntegrationFlows.from(this.inputChannel) + return IntegrationFlow.from(this.inputChannel) .filter(p -> p instanceof String, e -> e .id("filter") .discardFlow(df -> df @@ -715,7 +714,7 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow wireTapFlow1() { - return IntegrationFlows.from("tappedChannel1") + return IntegrationFlow.from("tappedChannel1") .wireTap("tapChannel", wt -> wt.selector(m -> m.getPayload().equals("foo"))) .handle(new ReactiveMessageHandlerAdapter((message) -> Mono.just(message).log().then())) .get(); @@ -738,7 +737,7 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow wireTapFlow4() { - return IntegrationFlows.from("tappedChannel4") + return IntegrationFlow.from("tappedChannel4") .wireTap(tapChannel()) .channel("nullChannel") .get(); @@ -792,14 +791,14 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow bridgeFlow() { - return IntegrationFlows.from(MessageChannels.queue("bridgeFlowInput")) + return IntegrationFlow.from(MessageChannels.queue("bridgeFlowInput")) .channel(MessageChannels.queue("bridgeFlowOutput")) .get(); } @Bean public IntegrationFlow bridgeFlow2() { - return IntegrationFlows.from("bridgeFlow2Input") + return IntegrationFlow.from("bridgeFlow2Input") .bridge(c -> c.autoStartup(false).id("bridge")) .fixedSubscriberChannel() .delay("delayer", d -> d @@ -817,7 +816,7 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow claimCheckFlow() { - return IntegrationFlows.from("claimCheckInput") + return IntegrationFlow.from("claimCheckInput") .claimCheckIn(this.messageStore()) .claimCheckOut(this.messageStore()) .get(); @@ -851,14 +850,14 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow methodInvokingFlow() { - return IntegrationFlows.from("methodInvokingInput") + return IntegrationFlow.from("methodInvokingInput") .handle(this.greetingService) .get(); } @Bean public IntegrationFlow lambdasFlow() { - return IntegrationFlows.from("lambdasInput") + return IntegrationFlow.from("lambdasInput") .filter(String.class, "World"::equals) .transform(String.class, "Hello "::concat) .get(); @@ -866,7 +865,7 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow errorRecovererFlow() { - return IntegrationFlows.from(Function.class, (gateway) -> gateway.beanName("errorRecovererFunction")) + return IntegrationFlow.from(Function.class, (gateway) -> gateway.beanName("errorRecovererFunction")) .handle((p, h) -> { throw new RuntimeException("intentional"); }, @@ -888,7 +887,7 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow recoveryFlow() { - return IntegrationFlows.from(recoveryChannel()) + return IntegrationFlow.from(recoveryChannel()) .>transform(MessagingException::getFailedMessage) .get(); @@ -896,7 +895,7 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow dedicatedPollingThreadFlow() { - return IntegrationFlows.from(MessageChannels.queue("dedicatedQueueChannel")) + return IntegrationFlow.from(MessageChannels.queue("dedicatedQueueChannel")) .bridge(e -> e .poller(Pollers.fixedDelay(0).receiveTimeout(-1)) .taskScheduler(dedicatedTaskScheduler())) @@ -912,7 +911,7 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow flowWithNullChannel() { - return IntegrationFlows.from("flowWithNullChannelInput") + return IntegrationFlow.from("flowWithNullChannelInput") .nullChannel(); } @@ -948,7 +947,7 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow globalErrorChannelResolutionFlow(@Qualifier("taskScheduler") TaskExecutor taskExecutor) { - return IntegrationFlows.from(Consumer.class, + return IntegrationFlow.from(Consumer.class, (gateway) -> gateway.beanName("globalErrorChannelResolutionFunction")) .channel(c -> c.executor(taskExecutor)) .handle((p, h) -> { @@ -969,7 +968,7 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow interceptorFlow(List outputStringList) { - return IntegrationFlows.from("interceptorChannelIn") + return IntegrationFlow.from("interceptorChannelIn") .intercept(new ChannelInterceptor() { @Override @@ -1029,7 +1028,7 @@ public class IntegrationFlowTests { @Bean public IntegrationFlow wrongLastComponent() { - return IntegrationFlows.from(MessageChannels.direct()) + return IntegrationFlow.from(MessageChannels.direct()) .fixedSubscriberChannel() .get(); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/flowservices/FlowServiceTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/flowservices/FlowServiceTests.java index 5cb727138e..c3ee4a3d75 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dsl/flowservices/FlowServiceTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/flowservices/FlowServiceTests.java @@ -48,7 +48,6 @@ import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; import org.springframework.integration.dsl.IntegrationFlowAdapter; import org.springframework.integration.dsl.IntegrationFlowDefinition; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.handler.LoggingHandler; import org.springframework.integration.support.MessageBuilder; @@ -132,7 +131,7 @@ public class FlowServiceTests { @Bean public IntegrationFlow subFlow() { - return IntegrationFlows + return IntegrationFlow .from("processChannel") .transform(String::toUpperCase) .channel("replyChannel") diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/gateway/GatewayDslTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/gateway/GatewayDslTests.java index e6adb7b943..255db9a2ac 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dsl/gateway/GatewayDslTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/gateway/GatewayDslTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2020 the original author or authors. + * Copyright 2019-2022 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,6 @@ import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.core.MessagingTemplate; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.gateway.GatewayProxyFactoryBean; import org.springframework.integration.gateway.MessagingGatewaySupport; @@ -174,7 +173,7 @@ public class GatewayDslTests { @Bean public IntegrationFlow gatewayFlow() { - return IntegrationFlows.from("gatewayInput") + return IntegrationFlow.from("gatewayInput") .gateway("gatewayRequest", g -> g.errorChannel("gatewayError").replyTimeout(10L)) .gateway((f) -> f.transform("From Gateway SubFlow: "::concat)) .get(); @@ -182,7 +181,7 @@ public class GatewayDslTests { @Bean public IntegrationFlow gatewayRequestFlow() { - return IntegrationFlows.from("gatewayRequest") + return IntegrationFlow.from("gatewayRequest") .filter("foo"::equals, (f) -> f.throwExceptionOnRejection(true)) .transform(String::toUpperCase) .get(); @@ -207,7 +206,7 @@ public class GatewayDslTests { @Bean public IntegrationFlow functionGateway() { - return IntegrationFlows.from(MessageFunction.class, + return IntegrationFlow.from(MessageFunction.class, (gateway) -> gateway .header("gatewayMethod", MethodArgsHolder::getMethod) .header("gatewayArgs", MethodArgsHolder::getArgs) @@ -219,7 +218,7 @@ public class GatewayDslTests { @Bean public IntegrationFlow routingGatewayFlow() { - return IntegrationFlows.from(RoutingGateway.class, + return IntegrationFlow.from(RoutingGateway.class, (gateway) -> gateway.beanName("routingGateway").header("gatewayMethod", MethodArgsHolder::getMethod)) .route(Message.class, (message) -> message.getHeaders().get("gatewayMethod", Method.class).getName(), diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/manualflow/ManualFlowTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/manualflow/ManualFlowTests.java index b42a72ca56..3ae58e2448 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dsl/manualflow/ManualFlowTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/manualflow/ManualFlowTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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. @@ -62,7 +62,6 @@ import org.springframework.integration.dsl.IntegrationFlow; import org.springframework.integration.dsl.IntegrationFlowAdapter; import org.springframework.integration.dsl.IntegrationFlowBuilder; import org.springframework.integration.dsl.IntegrationFlowDefinition; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.dsl.MessageProducerSpec; import org.springframework.integration.dsl.StandardIntegrationFlow; @@ -131,7 +130,7 @@ public class ManualFlowTests { }; QueueChannel channel = new QueueChannel(); channel.setBeanName("channel"); - IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(producer); + IntegrationFlowBuilder flowBuilder = IntegrationFlow.from(producer); BridgeHandler bridgeHandler = new BridgeHandler(); bridgeHandler.setBeanName("bridge"); @@ -175,7 +174,7 @@ public class ManualFlowTests { } MyProducerSpec spec = new MyProducerSpec(new MyProducer()); QueueChannel channel = new QueueChannel(); - IntegrationFlow flow = IntegrationFlows.from(spec.id("fooChannel")) + IntegrationFlow flow = IntegrationFlow.from(spec.id("fooChannel")) .channel(channel) .get(); IntegrationFlowRegistration flowRegistration = this.integrationFlowContext.registration(flow).register(); @@ -396,7 +395,7 @@ public class ManualFlowTests { QueueChannel resultChannel = new QueueChannel(); - IntegrationFlow integrationFlow = IntegrationFlows + IntegrationFlow integrationFlow = IntegrationFlow .from(messageFlux) .route(p -> p % 2 == 0, m -> m .subFlowMapping(true, sf -> sf.transform(em -> "even:" + em)) @@ -426,7 +425,7 @@ public class ManualFlowTests { String testId = "testId"; StandardIntegrationFlow testFlow = - IntegrationFlows.from(Supplier.class) + IntegrationFlow.from(Supplier.class) .get(); IntegrationFlowRegistration flowRegistration = diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/reactivestreams/ReactiveStreamsTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/reactivestreams/ReactiveStreamsTests.java index 72f2d80b4a..a6b59a24e8 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dsl/reactivestreams/ReactiveStreamsTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/reactivestreams/ReactiveStreamsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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,7 +43,6 @@ import org.springframework.integration.IntegrationMessageHeaderAccessor; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.dsl.context.IntegrationFlowContext; import org.springframework.integration.endpoint.AbstractEndpoint; @@ -173,7 +172,7 @@ public class ReactiveStreamsTests { QueueChannel resultChannel = new QueueChannel(); IntegrationFlow integrationFlow = - IntegrationFlows.from(messageFlux) + IntegrationFlow.from(messageFlux) .transform(p -> p * 2) .channel(resultChannel) .get(); @@ -250,7 +249,7 @@ public class ReactiveStreamsTests { @Bean public Publisher> reactiveFlow() { - return IntegrationFlows + return IntegrationFlow .from(() -> new GenericMessage<>("a,b,c,d,e,f"), e -> e.poller(p -> p.trigger(ctx -> this.invoked.getAndSet(true) ? null : new Date())) .id("reactiveStreamsMessageSource")) @@ -261,7 +260,7 @@ public class ReactiveStreamsTests { @Bean public Publisher> pollableReactiveFlow() { - return IntegrationFlows + return IntegrationFlow .from("inputChannel") .split(s -> s.delimiters(",")) .transform(Integer::parseInt, @@ -273,7 +272,7 @@ public class ReactiveStreamsTests { @Bean public Publisher> singleChannelFlow() { - return IntegrationFlows + return IntegrationFlow .from(MessageChannels.direct("singleChannel")) .log() .toReactivePublisher(); @@ -281,7 +280,7 @@ public class ReactiveStreamsTests { @Bean public Publisher> fixedSubscriberChannelFlow() { - return IntegrationFlows + return IntegrationFlow .from("fixedSubscriberChannel", true) .log() .toReactivePublisher(); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/routers/RouterTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/routers/RouterTests.java index e7f9a616c1..1c8f3b4caf 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dsl/routers/RouterTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/routers/RouterTests.java @@ -44,7 +44,6 @@ import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.config.EnableMessageHistory; import org.springframework.integration.dsl.IntegrationFlow; import org.springframework.integration.dsl.IntegrationFlowDefinition; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.expression.FunctionExpression; import org.springframework.integration.store.MessageGroup; @@ -639,7 +638,7 @@ public class RouterTests { @Bean public IntegrationFlow routeFlow() { - return IntegrationFlows.from("routerInput") + return IntegrationFlow.from("routerInput") .route(p -> p % 2 == 0, m -> m.channelMapping(true, evenChannel()) .subFlowMapping(false, f -> @@ -702,7 +701,7 @@ public class RouterTests { @Bean public IntegrationFlow recipientListFlow() { - return IntegrationFlows.from("recipientListInput") + return IntegrationFlow.from("recipientListInput") .transform(p -> p.replaceFirst("Payload", "")) .routeToRecipients(r -> r .recipient("foo-channel", "'foo' == payload") @@ -729,14 +728,14 @@ public class RouterTests { @Bean public IntegrationFlow routeMethodInvocationFlow() { - return IntegrationFlows.from("routerMethodInput") + return IntegrationFlow.from("routerMethodInput") .route("routingTestBean", "routeMessage") .get(); } @Bean public IntegrationFlow routeMethodInvocationFlow2() { - return IntegrationFlows.from("routerMethod2Input") + return IntegrationFlow.from("routerMethod2Input") .route(new RoutingTestBean()) .get(); } @@ -748,7 +747,7 @@ public class RouterTests { @Bean public IntegrationFlow routeMultiMethodInvocationFlow() { - return IntegrationFlows.from("routerMultiInput") + return IntegrationFlow.from("routerMultiInput") .route(String.class, p -> p.equals("foo") || p.equals("bar") ? new String[]{ "foo", "bar" } : null, @@ -918,7 +917,7 @@ public class RouterTests { @Bean public IntegrationFlow propagateErrorFromGatherer(TaskExecutor taskExecutor) { - return IntegrationFlows.from(Function.class) + return IntegrationFlow.from(Function.class) .scatterGather(s -> s .recipientFlow(subFlow -> subFlow .channel(c -> c.executor(taskExecutor)) diff --git a/spring-integration-core/src/test/java/org/springframework/integration/dsl/transformers/TransformerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/dsl/transformers/TransformerTests.java index 722041621b..89ad74564e 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/dsl/transformers/TransformerTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/dsl/transformers/TransformerTests.java @@ -38,7 +38,6 @@ import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.codec.Codec; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.dsl.Transformers; import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice; @@ -288,7 +287,7 @@ public class TransformerTests { @Bean public IntegrationFlow enricherFlow() { - return IntegrationFlows.from("enricherInput", true) + return IntegrationFlow.from("enricherInput", true) .enrich(e -> e.requestChannel("enrichChannel") .errorChannel(enricherErrorChannel()) .requestPayloadExpression("payload") @@ -303,7 +302,7 @@ public class TransformerTests { @Bean public IntegrationFlow enricherFlow2() { - return IntegrationFlows.from("enricherInput2", true) + return IntegrationFlow.from("enricherInput2", true) .enrich(e -> e.requestChannel("enrichChannel") .requestPayloadExpression("payload") .shouldClonePayload(false) @@ -315,7 +314,7 @@ public class TransformerTests { @Bean public IntegrationFlow enricherFlow3() { - return IntegrationFlows.from("enricherInput3", true) + return IntegrationFlow.from("enricherInput3", true) .enrich(e -> e.requestChannel("enrichChannel") .requestPayload(Message::getPayload) .shouldClonePayload(false) @@ -325,7 +324,7 @@ public class TransformerTests { @Bean public IntegrationFlow enrichFlow() { - return IntegrationFlows.from("enrichChannel") + return IntegrationFlow.from("enrichChannel") .>transform(p -> { if ("junk".equals(p.getName())) { throw new RuntimeException("intentional"); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/json/ContentTypeConversionTests.java b/spring-integration-core/src/test/java/org/springframework/integration/json/ContentTypeConversionTests.java index 51637da4e5..9c4e772a9c 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/json/ContentTypeConversionTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/json/ContentTypeConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2019 the original author or authors. + * Copyright 2017-2022 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. @@ -35,7 +35,6 @@ import org.springframework.integration.annotation.MessagingGateway; import org.springframework.integration.annotation.ServiceActivator; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; @@ -108,7 +107,7 @@ public class ContentTypeConversionTests { @Bean public IntegrationFlow serviceFlow() { - return IntegrationFlows.from(ServiceGateway.class) + return IntegrationFlow.from(ServiceGateway.class) .channel("serviceChannel") .handle(this) .get(); diff --git a/spring-integration-core/src/test/java/org/springframework/integration/support/management/micrometer/MicrometerMetricsTests.java b/spring-integration-core/src/test/java/org/springframework/integration/support/management/micrometer/MicrometerMetricsTests.java index f87ff03545..5e65d3620e 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/support/management/micrometer/MicrometerMetricsTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/support/management/micrometer/MicrometerMetricsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2020 the original author or authors. + * Copyright 2018-2022 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,6 @@ import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.config.EnableIntegrationManagement; import org.springframework.integration.core.MessageSource; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.endpoint.AbstractMessageSource; import org.springframework.integration.gateway.GatewayProxyFactoryBean; import org.springframework.integration.gateway.MessagingGatewaySupport; @@ -355,7 +354,7 @@ public class MicrometerMetricsTests { @Bean IntegrationFlow gatesFlow() { - return IntegrationFlows.from(Gate.class) + return IntegrationFlow.from(Gate.class) .nullChannel(); } diff --git a/spring-integration-core/src/test/java/org/springframework/integration/transformer/AvroTests.java b/spring-integration-core/src/test/java/org/springframework/integration/transformer/AvroTests.java index be17afbca2..3370f6793b 100644 --- a/spring-integration-core/src/test/java/org/springframework/integration/transformer/AvroTests.java +++ b/spring-integration-core/src/test/java/org/springframework/integration/transformer/AvroTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2020 the original author or authors. + * Copyright 2019-2022 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. @@ -33,7 +33,6 @@ import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.test.condition.LogLevels; import org.springframework.integration.test.util.TestUtils; import org.springframework.integration.transformer.support.AvroHeaders; @@ -166,7 +165,7 @@ public class AvroTests { @Bean public IntegrationFlow flow1() { - return IntegrationFlows.from(in1()) + return IntegrationFlow.from(in1()) .transform(new SimpleToAvroTransformer()) .wireTap(tapped()) .transform(fromTransformer()) @@ -177,7 +176,7 @@ public class AvroTests { @Bean public IntegrationFlow flow2() { - return IntegrationFlows.from(in2()) + return IntegrationFlow.from(in2()) .transform(new SimpleToAvroTransformer()) .wireTap(tapped()) .enrichHeaders(h -> h.header(AvroHeaders.TYPE, AvroTestClass2.class, true)) @@ -189,7 +188,7 @@ public class AvroTests { @Bean public IntegrationFlow flow3() { - return IntegrationFlows.from(in3()) + return IntegrationFlow.from(in3()) .transform(new SimpleToAvroTransformer()) .wireTap(tapped()) .enrichHeaders(h -> h.header(AvroHeaders.TYPE, AvroTestClass2.class.getName(), true)) @@ -201,7 +200,7 @@ public class AvroTests { @Bean public IntegrationFlow flow4() { - return IntegrationFlows.from(in4()) + return IntegrationFlow.from(in4()) .transform(new SimpleToAvroTransformer()) .wireTap(tapped()) .enrichHeaders(h -> h.header(AvroHeaders.TYPE, null, true) @@ -214,7 +213,7 @@ public class AvroTests { @Bean public IntegrationFlow flow5() { - return IntegrationFlows.from(in5()) + return IntegrationFlow.from(in5()) .transform(new SimpleToAvroTransformer().typeExpression("'avroTest'")) .wireTap(tapped()) .transform(new SimpleFromAvroTransformer(AvroTestClass1.class) @@ -227,7 +226,7 @@ public class AvroTests { @Bean public IntegrationFlow flow6() { - return IntegrationFlows.from(in6()) + return IntegrationFlow.from(in6()) .transform(new SimpleToAvroTransformer().typeExpression("'wontFindThisHeader'")) .wireTap(tapped()) .transform(new SimpleFromAvroTransformer(AvroTestClass1.class) diff --git a/spring-integration-event/src/test/java/org/springframework/integration/event/dsl/IntegrationFlowEventsTests.java b/spring-integration-event/src/test/java/org/springframework/integration/event/dsl/IntegrationFlowEventsTests.java index 9517a43b07..c7dc197c01 100644 --- a/spring-integration-event/src/test/java/org/springframework/integration/event/dsl/IntegrationFlowEventsTests.java +++ b/spring-integration-event/src/test/java/org/springframework/integration/event/dsl/IntegrationFlowEventsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2019 the original author or authors. + * Copyright 2016-2022 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,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.event.core.MessagingEvent; import org.springframework.integration.event.inbound.ApplicationEventListeningMessageProducer; @@ -132,7 +131,7 @@ public class IntegrationFlowEventsTests { @Bean public IntegrationFlow flow3() { - return IntegrationFlows.from("flow3Input") + return IntegrationFlow.from("flow3Input") .handle(Integer.class, new GenericHandler() { @SuppressWarnings("unused") @@ -172,7 +171,7 @@ public class IntegrationFlowEventsTests { ApplicationEventListeningMessageProducer producer = new ApplicationEventListeningMessageProducer(); producer.setEventTypes(TestApplicationEvent2.class); - return IntegrationFlows.from(producer) + return IntegrationFlow.from(producer) .channel(resultsChannel()) .get(); } diff --git a/spring-integration-feed/src/test/java/org/springframework/integration/feed/dsl/FeedDslTests.java b/spring-integration-feed/src/test/java/org/springframework/integration/feed/dsl/FeedDslTests.java index 238f092d3a..0884e7a5af 100644 --- a/spring-integration-feed/src/test/java/org/springframework/integration/feed/dsl/FeedDslTests.java +++ b/spring-integration-feed/src/test/java/org/springframework/integration/feed/dsl/FeedDslTests.java @@ -32,7 +32,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.io.Resource; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.metadata.MetadataStore; import org.springframework.integration.metadata.PropertiesPersistingMetadataStore; import org.springframework.messaging.Message; @@ -105,7 +104,7 @@ public class FeedDslTests { @Bean public IntegrationFlow feedFlow() { - return IntegrationFlows + return IntegrationFlow .from(Feed.inboundAdapter(this.feedResource, "feedTest") .metadataStore(metadataStore()) .preserveWireFeed(true), diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/dsl/FileTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/dsl/FileTests.java index 04f05dcd63..be35092676 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/dsl/FileTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/dsl/FileTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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. @@ -53,7 +53,6 @@ import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; import org.springframework.integration.dsl.IntegrationFlowDefinition; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.dsl.Pollers; import org.springframework.integration.dsl.StandardIntegrationFlow; @@ -248,7 +247,7 @@ public class FileTests { @Test public void testFileSplitterFlow() throws Exception { FileOutputStream file = new FileOutputStream(new File(tmpDir, "foo.tmp")); - file.write(("HelloWorld\näöüß").getBytes(Charset.defaultCharset())); + file.write(("HelloWorld\näöüß").getBytes(Charset.defaultCharset())); file.flush(); file.close(); @@ -259,7 +258,7 @@ public class FileTests { receive = this.fileSplittingResultChannel.receive(10000); assertThat(receive).isNotNull(); //HelloWorld receive = this.fileSplittingResultChannel.receive(10000); - assertThat(receive).isNotNull(); //äöüß + assertThat(receive).isNotNull(); //äöüß receive = this.fileSplittingResultChannel.receive(10000); assertThat(receive).isNotNull(); assertThat(receive.getPayload()).isInstanceOf(FileSplitter.FileMarker.class); // FileMarker.Mark.END @@ -337,7 +336,7 @@ public class FileTests { @Bean public IntegrationFlow fileFlow1() { - return IntegrationFlows.from("fileFlow1Input") + return IntegrationFlow.from("fileFlow1Input") .handle(Files.outboundAdapter("'file://" + tmpDir.getAbsolutePath() + '\'') .fileNameGenerator(message -> null) .fileExistsMode(FileExistsMode.APPEND_NO_FLUSH) @@ -353,7 +352,7 @@ public class FileTests { @Bean public IntegrationFlow tailFlow() { - return IntegrationFlows + return IntegrationFlow .from(Files.tailAdapter(new File(tmpDir, "TailTest")) .delay(500) .end(false) @@ -366,7 +365,7 @@ public class FileTests { @Bean public IntegrationFlow fileReadingFlow() { - return IntegrationFlows + return IntegrationFlow .from(Files.inboundAdapter(tmpDir) .patternFilter("*.sitest") .useWatchService(true) @@ -390,7 +389,7 @@ public class FileTests { @Bean public IntegrationFlow fileWritingFlow() { - return IntegrationFlows.from("fileWritingInput") + return IntegrationFlow.from("fileWritingInput") .enrichHeaders(h -> h.header(FileHeaders.FILENAME, "foo.write") .header("directory", new File(tmpDir, "fileWritingFlow"))) .handle(Files.outboundGateway(m -> m.getHeaders().get("directory")) @@ -407,7 +406,7 @@ public class FileTests { new ExpressionFileListFilter<>(new FunctionExpression(f -> "foo.tmp".equals(f.getName()))); fileExpressionFileListFilter.setBeanFactory(beanFactory); - return IntegrationFlows + return IntegrationFlow .from(Files.inboundAdapter(tmpDir) .filter(new ChainFileListFilter() .addFilter(new AcceptOnceFileListFilter<>()) @@ -441,7 +440,7 @@ public class FileTests { void pollDirectories(File... directories) { for (File directory : directories) { - StandardIntegrationFlow integrationFlow = IntegrationFlows + StandardIntegrationFlow integrationFlow = IntegrationFlow .from(Files.inboundAdapter(directory).recursive(true), e -> e.poller(p -> p.fixedDelay(1000)) .id(directory.getName() + ".adapter")) diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/dsl/FtpTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/dsl/FtpTests.java index d3f5b76621..cfd0ddf69a 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/dsl/FtpTests.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/dsl/FtpTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2020 the original author or authors. + * Copyright 2014-2022 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,7 +43,6 @@ import org.springframework.integration.config.EnableIntegrationManagement; import org.springframework.integration.config.IntegrationManagementConfigurer; import org.springframework.integration.core.MessageSource; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.Pollers; import org.springframework.integration.dsl.StandardIntegrationFlow; import org.springframework.integration.dsl.context.IntegrationFlowContext; @@ -91,7 +90,7 @@ public class FtpTests extends FtpTestSupport { public void testFtpInboundFlow() throws IOException { QueueChannel out = new QueueChannel(); DirectoryScanner scanner = new DefaultDirectoryScanner(); - IntegrationFlow flow = IntegrationFlows.from(Ftp.inboundAdapter(sessionFactory()) + IntegrationFlow flow = IntegrationFlow.from(Ftp.inboundAdapter(sessionFactory()) .preserveTimestamp(true) .remoteDirectory("ftpSource") .maxFetchSize(10) @@ -150,7 +149,7 @@ public class FtpTests extends FtpTestSupport { @Test public void testFtpInboundStreamFlow() throws Exception { QueueChannel out = new QueueChannel(); - StandardIntegrationFlow flow = IntegrationFlows.from( + StandardIntegrationFlow flow = IntegrationFlow.from( Ftp.inboundStreamingAdapter(new FtpRemoteFileTemplate(sessionFactory())) .remoteDirectory("ftpSource") .maxFetchSize(11) diff --git a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java index 804f68474a..6b9650d1cd 100644 --- a/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java +++ b/spring-integration-ftp/src/test/java/org/springframework/integration/ftp/inbound/RotatingServersTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2021 the original author or authors. + * Copyright 2018-2022 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,6 @@ import org.springframework.integration.StaticMessageHeaderAccessor; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.dsl.Pollers; import org.springframework.integration.endpoint.SourcePollingChannelAdapter; @@ -324,7 +323,7 @@ public class RotatingServersTests extends FtpTestSupport { @Bean public IntegrationFlow flow() { - return IntegrationFlows.from(Ftp.inboundAdapter(sf()) + return IntegrationFlow.from(Ftp.inboundAdapter(sf()) .filter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate")) .localDirectory(localDir()) .remoteDirectory("."), @@ -360,7 +359,7 @@ public class RotatingServersTests extends FtpTestSupport { @Override @Bean public IntegrationFlow flow() { - return IntegrationFlows.from(Ftp.inboundAdapter(sf()) + return IntegrationFlow.from(Ftp.inboundAdapter(sf()) .filter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate")) .localDirectory(new File(TMP_DIR, "variable")) .localFilenameExpression("#remoteDirectory + T(java.io.File).separator + #root") @@ -378,7 +377,7 @@ public class RotatingServersTests extends FtpTestSupport { @Override @Bean public IntegrationFlow flow() { - return IntegrationFlows.from(Ftp.inboundStreamingAdapter(new FtpRemoteFileTemplate(sf())) + return IntegrationFlow.from(Ftp.inboundStreamingAdapter(new FtpRemoteFileTemplate(sf())) .filter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate")) .remoteDirectory("."), e -> e.poller(Pollers.fixedDelay(1).advice(advice()))) @@ -404,7 +403,7 @@ public class RotatingServersTests extends FtpTestSupport { @Override @Bean public IntegrationFlow flow() { - return IntegrationFlows.from(Ftp.inboundStreamingAdapter(new FtpRemoteFileTemplate(sf())) + return IntegrationFlow.from(Ftp.inboundStreamingAdapter(new FtpRemoteFileTemplate(sf())) .filter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate")) .remoteDirectory(".") .maxFetchSize(1), diff --git a/spring-integration-graphql/src/test/java/org/springframework/integration/graphql/outbound/GraphQlMessageHandlerTests.java b/spring-integration-graphql/src/test/java/org/springframework/integration/graphql/outbound/GraphQlMessageHandlerTests.java index ee266c8fcc..4ba410bbb7 100644 --- a/spring-integration-graphql/src/test/java/org/springframework/integration/graphql/outbound/GraphQlMessageHandlerTests.java +++ b/spring-integration-graphql/src/test/java/org/springframework/integration/graphql/outbound/GraphQlMessageHandlerTests.java @@ -44,7 +44,6 @@ import org.springframework.integration.channel.FluxMessageChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandlingException; @@ -287,7 +286,7 @@ public class GraphQlMessageHandlerTests { @Bean IntegrationFlow graphqlQueryMessageHandlerFlow(GraphQlMessageHandler handler) { - return IntegrationFlows.from(MessageChannels.flux("inputChannel")) + return IntegrationFlow.from(MessageChannels.flux("inputChannel")) .handle(handler) .channel(c -> c.flux("resultChannel")) .get(); diff --git a/spring-integration-http/src/test/java/org/springframework/integration/http/dsl/HttpDslTests.java b/spring-integration-http/src/test/java/org/springframework/integration/http/dsl/HttpDslTests.java index efe5090ba4..29ecc7023d 100644 --- a/spring-integration-http/src/test/java/org/springframework/integration/http/dsl/HttpDslTests.java +++ b/spring-integration-http/src/test/java/org/springframework/integration/http/dsl/HttpDslTests.java @@ -48,7 +48,6 @@ import org.springframework.integration.channel.DirectChannel; import org.springframework.integration.channel.FixedSubscriberChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.context.IntegrationFlowContext; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; import org.springframework.integration.http.multipart.UploadedMultipartFile; @@ -141,7 +140,7 @@ public class HttpDslTests { @Test public void testDynamicHttpEndpoint() throws Exception { IntegrationFlow flow = - IntegrationFlows.from(Http.inboundGateway("/dynamic") + IntegrationFlow.from(Http.inboundGateway("/dynamic") .requestMapping(r -> r.params("name")) .payloadExpression("#requestParams.name[0]")) .transform(String::toLowerCase) @@ -214,7 +213,7 @@ public class HttpDslTests { @Test public void testValidation() throws Exception { IntegrationFlow flow = - IntegrationFlows.from( + IntegrationFlow.from( Http.inboundChannelAdapter("/validation") .requestMapping((mapping) -> mapping .methods(HttpMethod.POST) @@ -241,7 +240,7 @@ public class HttpDslTests { @Test public void testBadRequest() throws Exception { IntegrationFlow flow = - IntegrationFlows.from( + IntegrationFlow.from( Http.inboundGateway("/badRequest") .errorChannel((message, timeout) -> { throw new ResponseStatusException(HttpStatus.BAD_REQUEST, @@ -266,7 +265,7 @@ public class HttpDslTests { @Test public void testErrorChannelFlow() throws Exception { IntegrationFlow flow = - IntegrationFlows.from( + IntegrationFlow.from( Http.inboundGateway("/errorFlow") .errorChannel(new FixedSubscriberChannel( new AbstractReplyProducingMessageHandler() { @@ -342,7 +341,7 @@ public class HttpDslTests { @Bean public IntegrationFlow httpInternalServiceFlow() { - return IntegrationFlows + return IntegrationFlow .from(Http.inboundGateway("/service/internal") .requestMapping(r -> r.params("name")) .payloadExpression("#requestParams.name")) @@ -360,7 +359,7 @@ public class HttpDslTests { @Bean public IntegrationFlow httpProxyFlow() { - return IntegrationFlows + return IntegrationFlow .from(httpService()) .handle(Http.outboundGateway("/service/internal?{params}") .uriVariable("params", "payload") @@ -381,7 +380,7 @@ public class HttpDslTests { @Bean public IntegrationFlow multiPartFilesFlow() { - return IntegrationFlows + return IntegrationFlow .from(Http.inboundChannelAdapter("/multiPartFiles") .headerFunction("contentLength", (entity) -> entity.getHeaders().getContentLength())) .channel((c) -> c.queue("multiPartFilesChannel")) diff --git a/spring-integration-ip/src/test/java/org/springframework/integration/ip/dsl/IpIntegrationTests.java b/spring-integration-ip/src/test/java/org/springframework/integration/ip/dsl/IpIntegrationTests.java index 65629f89f9..7c57bd4c41 100644 --- a/spring-integration-ip/src/test/java/org/springframework/integration/ip/dsl/IpIntegrationTests.java +++ b/spring-integration-ip/src/test/java/org/springframework/integration/ip/dsl/IpIntegrationTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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,6 @@ import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.core.MessagingTemplate; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.dsl.Transformers; import org.springframework.integration.dsl.context.IntegrationFlowContext; @@ -198,7 +197,7 @@ public class IpIntegrationTests { @Test void testCloseStream() throws InterruptedException { - IntegrationFlow server = IntegrationFlows.from(Tcp.inboundGateway(Tcp.netServer(0) + IntegrationFlow server = IntegrationFlow.from(Tcp.inboundGateway(Tcp.netServer(0) .deserializer(new ByteArrayRawSerializer()))) .transform(p -> "reply:" + new String(p).toUpperCase()) .get(); @@ -218,7 +217,7 @@ public class IpIntegrationTests { .id("streamCloseServer") .register(); assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue(); - IntegrationFlow client = IntegrationFlows.from(MessageChannels.direct()) + IntegrationFlow client = IntegrationFlow.from(MessageChannels.direct()) .handle(Tcp.outboundGateway(Tcp.netClient("localhost", port.get()) .singleUseConnections(true) .serializer(new ByteArrayRawSerializer())) @@ -258,7 +257,7 @@ public class IpIntegrationTests { @Bean public IntegrationFlow inTcpGateway() { - return IntegrationFlows.from( + return IntegrationFlow.from( Tcp.inboundGateway(server1()) .replyTimeout(1) .errorOnTimeout(true) @@ -296,7 +295,7 @@ public class IpIntegrationTests { @Bean public IntegrationFlow inUdpAdapter() { - return IntegrationFlows.from(Udp.inboundAdapter(0)) + return IntegrationFlow.from(Udp.inboundAdapter(0)) .channel(udpIn()) .get(); } diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/dsl/JmsTests.java b/spring-integration-jms/src/test/java/org/springframework/integration/jms/dsl/JmsTests.java index 0ba9fd05fb..468e29267d 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/dsl/JmsTests.java +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/dsl/JmsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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,6 @@ import org.springframework.integration.config.GlobalChannelInterceptor; import org.springframework.integration.core.MessageSource; import org.springframework.integration.dsl.IntegrationFlow; import org.springframework.integration.dsl.IntegrationFlowDefinition; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.dsl.Pollers; import org.springframework.integration.endpoint.MethodInvokingMessageSource; @@ -325,7 +324,7 @@ public class JmsTests extends ActiveMQMultiContextTests { @Bean public IntegrationFlow jmsInboundFlow() { - return IntegrationFlows + return IntegrationFlow .from(Jms.inboundAdapter(amqFactory).destination("jmsInbound")) .transform(String::toUpperCase) .channel(this.jmsOutboundInboundReplyChannel()) @@ -352,7 +351,7 @@ public class JmsTests extends ActiveMQMultiContextTests { @Bean public IntegrationFlow jmsMessageDrivenFlow() { - return IntegrationFlows + return IntegrationFlow .from(Jms.messageDrivenChannelAdapter(amqFactory, DefaultMessageListenerContainer.class) .outputChannel(jmsMessageDrivenInputChannel()) @@ -385,7 +384,7 @@ public class JmsTests extends ActiveMQMultiContextTests { @Bean public IntegrationFlow jmsMessageDrivenFlowWithContainer() { - return IntegrationFlows + return IntegrationFlow .from(Jms.messageDrivenChannelAdapter( Jms.container(amqFactory, "containerSpecDestination") .pubSubDomain(false) @@ -406,7 +405,7 @@ public class JmsTests extends ActiveMQMultiContextTests { @Bean public IntegrationFlow jmsInboundGatewayFlow() { - return IntegrationFlows.from( + return IntegrationFlow.from( Jms.inboundGateway(amqFactory) .requestChannel(jmsInboundGatewayInputChannel()) .replyTimeout(1) @@ -451,7 +450,7 @@ public class JmsTests extends ActiveMQMultiContextTests { @Bean public IntegrationFlow jmsMessageDrivenRedeliveryFlow() { - return IntegrationFlows + return IntegrationFlow .from(Jms.messageDrivenChannelAdapter(amqFactory) .errorChannel("errorChannelForRedelivery") .destination("jmsMessageDrivenRedelivery") @@ -473,7 +472,7 @@ public class JmsTests extends ActiveMQMultiContextTests { @Bean public IntegrationFlow errorHandlingFlow() { - return IntegrationFlows.from("errorChannelForRedelivery") + return IntegrationFlow.from("errorChannelForRedelivery") .handle(m -> { MessagingException exception = (MessagingException) m.getPayload(); redeliveryLatch().countDown(); diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/configuration/DslMBeanTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/configuration/DslMBeanTests.java index f1411817b2..cceed9b09b 100644 --- a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/configuration/DslMBeanTests.java +++ b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/configuration/DslMBeanTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2020 the original author or authors. + * Copyright 2018-2022 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,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.context.IntegrationFlowContext; import org.springframework.integration.jmx.config.EnableIntegrationMBeanExport; import org.springframework.jmx.support.MBeanServerFactoryBean; @@ -63,7 +62,7 @@ public class DslMBeanTests { assertThat(query).hasSize(0); IntegrationFlow dynamicFlow = - IntegrationFlows.fromSupplier(() -> "foo", e -> e.poller(p -> p.fixedDelay(1000))) + IntegrationFlow.fromSupplier(() -> "foo", e -> e.poller(p -> p.fixedDelay(1000))) .channel("channelTwo") .nullChannel(); @@ -105,7 +104,7 @@ public class DslMBeanTests { @Bean public IntegrationFlow staticFlow() { - return IntegrationFlows.from("channelOne") + return IntegrationFlow.from("channelOne") .nullChannel(); } diff --git a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/dsl/JpaTests.java b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/dsl/JpaTests.java index dd08629556..10294e0b70 100644 --- a/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/dsl/JpaTests.java +++ b/spring-integration-jpa/src/test/java/org/springframework/integration/jpa/dsl/JpaTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.jpa.support.PersistMode; import org.springframework.integration.jpa.test.entity.Gender; import org.springframework.integration.jpa.test.entity.StudentDomain; @@ -215,7 +214,7 @@ public class JpaTests { @Bean public IntegrationFlow pollingAdapterFlow(EntityManagerFactory entityManagerFactory) { - return IntegrationFlows + return IntegrationFlow .from(Jpa.inboundAdapter(entityManagerFactory) .entityClass(StudentDomain.class) .maxResults(1) diff --git a/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/dsl/KafkaDslTests.java b/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/dsl/KafkaDslTests.java index 37cc74650e..0a7d95ddfe 100644 --- a/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/dsl/KafkaDslTests.java +++ b/spring-integration-kafka/src/test/java/org/springframework/integration/kafka/dsl/KafkaDslTests.java @@ -43,7 +43,6 @@ import org.springframework.integration.channel.BroadcastCapableChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.Pollers; import org.springframework.integration.kafka.channel.PollableKafkaChannel; import org.springframework.integration.kafka.inbound.KafkaErrorSendingMessageRecoverer; @@ -301,7 +300,7 @@ public class KafkaDslTests { @Bean public IntegrationFlow topic1ListenerFromKafkaFlow() { - return IntegrationFlows + return IntegrationFlow .from(Kafka.messageDrivenChannelAdapter(consumerFactory(), KafkaMessageDrivenChannelAdapter.ListenerMode.record, TEST_TOPIC1) .configureListenerContainer(c -> @@ -331,7 +330,7 @@ public class KafkaDslTests { @Bean public IntegrationFlow topic2ListenerFromKafkaFlow() { - return IntegrationFlows + return IntegrationFlow .from(Kafka .messageDrivenChannelAdapter(kafkaListenerContainerFactory().createContainer(TEST_TOPIC2), KafkaMessageDrivenChannelAdapter.ListenerMode.record)) @@ -397,7 +396,7 @@ public class KafkaDslTests { @Bean public IntegrationFlow sourceFlow() { - return IntegrationFlows + return IntegrationFlow .from(Kafka.inboundChannelAdapter(consumerFactory(), new ConsumerProperties(TEST_TOPIC3)), e -> e.poller(Pollers.fixedDelay(100))) .handle(p -> { @@ -410,7 +409,7 @@ public class KafkaDslTests { @Bean public IntegrationFlow outboundGateFlow() { - return IntegrationFlows.from(Gate.class) + return IntegrationFlow.from(Gate.class) .handle(Kafka.outboundGateway(producerFactory(), replyContainer()) .flushExpression("true") .sync(true) @@ -440,7 +439,7 @@ public class KafkaDslTests { ConcurrentKafkaListenerContainerFactory containerFactory, KafkaMessageSource channelSource) { - return IntegrationFlows.from(topic6Channel(template, containerFactory)) + return IntegrationFlow.from(topic6Channel(template, containerFactory)) .publishSubscribeChannel(pubSub(template, containerFactory), channel -> channel .subscribe(f -> f.channel( Kafka.pollableChannel(template, channelSource).id("topic8Channel"))) @@ -478,7 +477,7 @@ public class KafkaDslTests { @Bean public IntegrationFlow serverGateway() { - return IntegrationFlows + return IntegrationFlow .from(Kafka.inboundGateway(consumerFactory(), containerProperties(), producerFactory()) .configureListenerContainer(container -> container.errorHandler(eh()))) @@ -495,7 +494,7 @@ public class KafkaDslTests { IntegrationFlow withRecoveringErrorHandler() { ContainerProperties props = containerProperties(); props.setGroupId("wreh"); - return IntegrationFlows.from(Kafka.messageDrivenChannelAdapter(consumerFactory(), props) + return IntegrationFlow.from(Kafka.messageDrivenChannelAdapter(consumerFactory(), props) .configureListenerContainer(container -> { container.errorHandler(recoveringErrorHandler()); })) diff --git a/spring-integration-mail/src/test/java/org/springframework/integration/mail/dsl/MailTests.java b/spring-integration-mail/src/test/java/org/springframework/integration/mail/dsl/MailTests.java index 43f4cbe4da..580d11d99c 100644 --- a/spring-integration-mail/src/test/java/org/springframework/integration/mail/dsl/MailTests.java +++ b/spring-integration-mail/src/test/java/org/springframework/integration/mail/dsl/MailTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 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,7 +43,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.integration.IntegrationMessageHeaderAccessor; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.mail.ImapIdleChannelAdapter; import org.springframework.integration.mail.MailHeaders; @@ -203,7 +202,7 @@ public class MailTests { @Bean public IntegrationFlow sendMailFlow() { - return IntegrationFlows.from("sendMailChannel") + return IntegrationFlow.from("sendMailChannel") .enrichHeaders(Mail.headers() .subjectFunction(m -> "foo") .from("foo@bar") @@ -219,7 +218,7 @@ public class MailTests { @Bean public IntegrationFlow pop3MailFlow() { - return IntegrationFlows + return IntegrationFlow .from(Mail.pop3InboundAdapter("localhost", mailServer.getPop3().getPort(), "popuser", "pw") .javaMailProperties(p -> p.put("mail.debug", "false")) .autoCloseFolder(true) @@ -233,7 +232,7 @@ public class MailTests { @Bean public IntegrationFlow imapMailFlow() { - return IntegrationFlows + return IntegrationFlow .from(Mail.imapInboundAdapter("imap://imapuser:pw@localhost:" + mailServer.getImap().getPort() + "/INBOX") .searchTermStrategy(this::fromAndNotSeenTerm) .userFlag("testSIUserFlag") @@ -248,7 +247,7 @@ public class MailTests { @Bean public IntegrationFlow imapIdleFlow() { - return IntegrationFlows + return IntegrationFlow .from(Mail.imapIdleAdapter("imap://imapidleuser:pw@localhost:" + mailServer.getImap().getPort() + "/INBOX") .autoStartup(true) .searchTermStrategy(this::fromAndNotSeenTerm) diff --git a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/inbound/MongoDbChangeStreamMessageProducerTests.java b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/inbound/MongoDbChangeStreamMessageProducerTests.java index e232ad74ba..30ad38ec90 100644 --- a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/inbound/MongoDbChangeStreamMessageProducerTests.java +++ b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/inbound/MongoDbChangeStreamMessageProducerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 the original author or authors. + * Copyright 2020-2022 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,6 @@ import org.springframework.data.mongodb.core.ReactiveMongoTemplate; import org.springframework.integration.channel.FluxMessageChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.endpoint.MessageProducerSupport; import org.springframework.integration.mongodb.Person; @@ -157,7 +156,7 @@ public class MongoDbChangeStreamMessageProducerTests { @Bean IntegrationFlow changeStreamFlow() { - return IntegrationFlows.from( + return IntegrationFlow.from( MongoDb.changeStreamInboundChannelAdapter(mongoTemplate()) .domainType(Person.class) .collection("person") diff --git a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/inbound/ReactiveMongoDbMessageSourceTests.java b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/inbound/ReactiveMongoDbMessageSourceTests.java index 1ccbcd436f..09350bfba9 100644 --- a/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/inbound/ReactiveMongoDbMessageSourceTests.java +++ b/spring-integration-mongodb/src/test/java/org/springframework/integration/mongodb/inbound/ReactiveMongoDbMessageSourceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020-2021 the original author or authors. + * Copyright 2020-2022 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. @@ -48,7 +48,6 @@ import org.springframework.expression.common.LiteralExpression; import org.springframework.integration.channel.FluxMessageChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.Pollers; import org.springframework.integration.mongodb.dsl.MongoDb; import org.springframework.integration.mongodb.rules.MongoDbAvailable; @@ -247,7 +246,7 @@ public class ReactiveMongoDbMessageSourceTests extends MongoDbAvailableTests { @Bean public IntegrationFlow pollingFlow() { - return IntegrationFlows + return IntegrationFlow .from(MongoDb.reactiveInboundChannelAdapter( REACTIVE_MONGO_DATABASE_FACTORY, "{'name' : 'Oleg'}") .update(Update.update("name", "DONE")) diff --git a/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/MqttDslTests.java b/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/MqttDslTests.java index 53bdd04b70..14d46c4423 100644 --- a/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/MqttDslTests.java +++ b/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/MqttDslTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2018-2021 the original author or authors. + * Copyright 2018-2022 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. @@ -33,7 +33,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.jmx.config.EnableIntegrationMBeanExport; import org.springframework.integration.mqtt.core.DefaultMqttPahoClientFactory; import org.springframework.integration.mqtt.inbound.MqttPahoMessageDrivenChannelAdapter; @@ -114,7 +113,7 @@ public class MqttDslTests implements MosquittoContainerTest { @Bean public IntegrationFlow mqttInFlow() { - return IntegrationFlows.from( + return IntegrationFlow.from( new MqttPahoMessageDrivenChannelAdapter("jmxTestIn", pahoClientFactory(), "jmxTests")) .channel(c -> c.queue("fromMqttChannel")) diff --git a/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/Mqttv5BackToBackAutomaticReconnectTests.java b/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/Mqttv5BackToBackAutomaticReconnectTests.java index c5a741f5e2..266eae5bb0 100644 --- a/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/Mqttv5BackToBackAutomaticReconnectTests.java +++ b/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/Mqttv5BackToBackAutomaticReconnectTests.java @@ -35,7 +35,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.event.EventListener; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.mqtt.event.MqttSubscribedEvent; import org.springframework.integration.mqtt.inbound.Mqttv5PahoMessageDrivenChannelAdapter; import org.springframework.integration.mqtt.outbound.Mqttv5PahoMessageHandler; @@ -126,7 +125,7 @@ public class Mqttv5BackToBackAutomaticReconnectTests implements MosquittoContain new Mqttv5PahoMessageDrivenChannelAdapter(mqttConnectOptions(), "mqttv5SIin", "siTest"); messageProducer.setPayloadType(String.class); - return IntegrationFlows.from(messageProducer) + return IntegrationFlow.from(messageProducer) .channel(c -> c.queue("fromMqttChannel")) .get(); } diff --git a/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/Mqttv5BackToBackTests.java b/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/Mqttv5BackToBackTests.java index f6e58501f5..a8160a03b9 100644 --- a/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/Mqttv5BackToBackTests.java +++ b/spring-integration-mqtt/src/test/java/org/springframework/integration/mqtt/Mqttv5BackToBackTests.java @@ -34,7 +34,6 @@ import org.springframework.integration.IntegrationMessageHeaderAccessor; import org.springframework.integration.acks.SimpleAcknowledgment; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.mqtt.event.MqttIntegrationEvent; import org.springframework.integration.mqtt.event.MqttMessageDeliveredEvent; import org.springframework.integration.mqtt.event.MqttMessageSentEvent; @@ -178,7 +177,7 @@ public class Mqttv5BackToBackTests implements MosquittoContainerTest { messageProducer.setMessageConverter(mqttStringToBytesConverter()); messageProducer.setManualAcks(true); - return IntegrationFlows.from(messageProducer) + return IntegrationFlow.from(messageProducer) .channel(c -> c.queue("fromMqttChannel")) .get(); } diff --git a/spring-integration-r2dbc/src/test/java/org/springframework/integration/r2dbc/dsl/R2dbcDslTests.java b/spring-integration-r2dbc/src/test/java/org/springframework/integration/r2dbc/dsl/R2dbcDslTests.java index df734bf567..4cddc94d2c 100644 --- a/spring-integration-r2dbc/src/test/java/org/springframework/integration/r2dbc/dsl/R2dbcDslTests.java +++ b/spring-integration-r2dbc/src/test/java/org/springframework/integration/r2dbc/dsl/R2dbcDslTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2020 the original author or authors. + * Copyright 2020-2022 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. @@ -35,7 +35,6 @@ import org.springframework.data.relational.core.query.Criteria; import org.springframework.data.relational.core.query.Query; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.r2dbc.config.R2dbcDatabaseConfiguration; import org.springframework.integration.r2dbc.entity.Person; @@ -102,7 +101,7 @@ public class R2dbcDslTests { @Bean IntegrationFlow r2dbcDslFlow(R2dbcEntityTemplate r2dbcEntityTemplate) { - return IntegrationFlows + return IntegrationFlow .from(R2dbc.inboundChannelAdapter(r2dbcEntityTemplate, (selectCreator) -> selectCreator.createSelect("person") diff --git a/spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/dsl/RSocketDslTests.java b/spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/dsl/RSocketDslTests.java index 99c1713c90..55dac63639 100644 --- a/spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/dsl/RSocketDslTests.java +++ b/spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/dsl/RSocketDslTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2019-2021 the original author or authors. + * Copyright 2019-2022 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,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.context.IntegrationFlowContext; import org.springframework.integration.rsocket.ClientRSocketConnector; import org.springframework.integration.rsocket.RSocketInteractionModel; @@ -129,7 +128,7 @@ public class RSocketDslTests { @Bean public IntegrationFlow rsocketUpperCaseRequestFlow(ClientRSocketConnector clientRSocketConnector) { - return IntegrationFlows + return IntegrationFlow .from(Function.class) .handle(RSockets.outboundGateway(message -> message.getHeaders().getOrDefault("route", "/uppercase")) @@ -145,7 +144,7 @@ public class RSocketDslTests { @Bean public IntegrationFlow rsocketUpperCaseFlow() { - return IntegrationFlows + return IntegrationFlow .from(RSockets.inboundGateway("/uppercase") .interactionModels(RSocketInteractionModel.requestChannel)) ., Flux>transform((flux) -> flux.map(String::toUpperCase)) @@ -154,7 +153,7 @@ public class RSocketDslTests { @Bean public IntegrationFlow rsocketUpperCaseWholeFlow() { - return IntegrationFlows + return IntegrationFlow .from(RSockets.inboundGateway("/uppercaseWhole") .interactionModels(RSocketInteractionModel.requestChannel) .decodeFluxAsUnit(true)) @@ -164,7 +163,7 @@ public class RSocketDslTests { @Bean public IntegrationFlow rsocketLowerCaseFlow() { - return IntegrationFlows + return IntegrationFlow .from(RSockets.inboundGateway("/lowercase")) ., Flux>transform((flux) -> flux.map(String::toLowerCase)) .get(); diff --git a/spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/outbound/RSocketOutboundGatewayIntegrationTests.java b/spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/outbound/RSocketOutboundGatewayIntegrationTests.java index 0006e81fb4..843d0a0f10 100644 --- a/spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/outbound/RSocketOutboundGatewayIntegrationTests.java +++ b/spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/outbound/RSocketOutboundGatewayIntegrationTests.java @@ -34,7 +34,6 @@ import org.springframework.integration.channel.FluxMessageChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.expression.FunctionExpression; import org.springframework.integration.rsocket.ClientRSocketConnector; @@ -501,7 +500,7 @@ public class RSocketOutboundGatewayIntegrationTests { @Bean public IntegrationFlow rsocketOutboundFlow() { - return IntegrationFlows.from(MessageChannels.flux("inputChannel")) + return IntegrationFlow.from(MessageChannels.flux("inputChannel")) .handle(rsocketOutboundGateway()) .channel(c -> c.flux("resultChannel")) .get(); diff --git a/spring-integration-scripting/src/test/java/org/springframework/integration/scripting/dsl/ScriptsTests.java b/spring-integration-scripting/src/test/java/org/springframework/integration/scripting/dsl/ScriptsTests.java index e2127066f9..ef137ec22a 100644 --- a/spring-integration-scripting/src/test/java/org/springframework/integration/scripting/dsl/ScriptsTests.java +++ b/spring-integration-scripting/src/test/java/org/springframework/integration/scripting/dsl/ScriptsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2021 the original author or authors. + * Copyright 2016-2022 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,6 @@ import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.channel.QueueChannelOperations; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; import org.springframework.messaging.MessageChannel; @@ -256,7 +255,7 @@ public class ScriptsTests { @Bean public IntegrationFlow scriptPollingAdapter() { - return IntegrationFlows + return IntegrationFlow .from(Scripts.messageSource("scripts/TestMessageSourceScript.rb"), e -> e.poller(p -> p.fixedDelay(100))) .channel(c -> c.queue("messageSourceChannel")) diff --git a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/dsl/SftpTests.java b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/dsl/SftpTests.java index d1e0ec167f..6c2688653b 100644 --- a/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/dsl/SftpTests.java +++ b/spring-integration-sftp/src/test/java/org/springframework/integration/sftp/dsl/SftpTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2021 the original author or authors. + * Copyright 2014-2022 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,6 @@ import org.springframework.integration.IntegrationMessageHeaderAccessor; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.Pollers; import org.springframework.integration.dsl.StandardIntegrationFlow; import org.springframework.integration.dsl.context.IntegrationFlowContext; @@ -72,7 +71,7 @@ public class SftpTests extends SftpTestSupport { @SuppressWarnings("unchecked") public void testSftpInboundFlow() { QueueChannel out = new QueueChannel(); - IntegrationFlow flow = IntegrationFlows + IntegrationFlow flow = IntegrationFlow .from(Sftp.inboundAdapter(sessionFactory()) .preserveTimestamp(true) .remoteDirectory("sftpSource") @@ -104,7 +103,7 @@ public class SftpTests extends SftpTestSupport { @Test public void testSftpInboundStreamFlow() throws Exception { QueueChannel out = new QueueChannel(); - StandardIntegrationFlow flow = IntegrationFlows.from( + StandardIntegrationFlow flow = IntegrationFlow.from( Sftp.inboundStreamingAdapter(new SftpRemoteFileTemplate(sessionFactory())) .remoteDirectory("sftpSource") .regexFilter(".*\\.txt$"), diff --git a/spring-integration-smb/src/test/java/org/springframework/integration/smb/dsl/SmbTests.java b/spring-integration-smb/src/test/java/org/springframework/integration/smb/dsl/SmbTests.java index 3990e37b27..c786879720 100644 --- a/spring-integration-smb/src/test/java/org/springframework/integration/smb/dsl/SmbTests.java +++ b/spring-integration-smb/src/test/java/org/springframework/integration/smb/dsl/SmbTests.java @@ -42,7 +42,6 @@ import org.springframework.integration.config.EnableIntegrationManagement; import org.springframework.integration.config.IntegrationManagementConfigurer; import org.springframework.integration.core.MessageSource; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.Pollers; import org.springframework.integration.dsl.StandardIntegrationFlow; import org.springframework.integration.dsl.context.IntegrationFlowContext; @@ -118,7 +117,7 @@ public class SmbTests extends SmbTestSupport { public void testSmbInboundFlow() throws IOException { QueueChannel out = new QueueChannel(); DirectoryScanner scanner = new DefaultDirectoryScanner(); - IntegrationFlow flow = IntegrationFlows.from(Smb.inboundAdapter(sessionFactory()) + IntegrationFlow flow = IntegrationFlow.from(Smb.inboundAdapter(sessionFactory()) .preserveTimestamp(true) .remoteDirectory("smbSource") .maxFetchSize(10) @@ -163,7 +162,7 @@ public class SmbTests extends SmbTestSupport { @Test public void testSmbInboundStreamFlow() throws Exception { QueueChannel out = new QueueChannel(); - StandardIntegrationFlow flow = IntegrationFlows.from( + StandardIntegrationFlow flow = IntegrationFlow.from( Smb.inboundStreamingAdapter(new SmbRemoteFileTemplate(sessionFactory())) .remoteDirectory("smbSource") .maxFetchSize(11) diff --git a/spring-integration-test/src/test/java/org/springframework/integration/test/mock/MockMessageSourceTests.java b/spring-integration-test/src/test/java/org/springframework/integration/test/mock/MockMessageSourceTests.java index 8aff663bb2..8da4c7d144 100644 --- a/spring-integration-test/src/test/java/org/springframework/integration/test/mock/MockMessageSourceTests.java +++ b/spring-integration-test/src/test/java/org/springframework/integration/test/mock/MockMessageSourceTests.java @@ -34,7 +34,6 @@ import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.core.MessageSource; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.PollerSpec; import org.springframework.integration.dsl.Pollers; import org.springframework.integration.dsl.StandardIntegrationFlow; @@ -148,7 +147,7 @@ public class MockMessageSourceTests { @Test public void testMockMessageSourceDynamicFlow() { QueueChannel out = new QueueChannel(); - StandardIntegrationFlow flow = IntegrationFlows + StandardIntegrationFlow flow = IntegrationFlow .from(MockIntegration.mockMessageSource("foo", "bar", "baz")) .transform(String::toUpperCase) .channel(out) @@ -205,7 +204,7 @@ public class MockMessageSourceTests { @Bean public IntegrationFlow myFlow() { - return IntegrationFlows + return IntegrationFlow .from(() -> new GenericMessage<>("myData"), e -> e.id("mySourceEndpoint")) .transform(String::toUpperCase) diff --git a/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java b/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java index bc0846551d..6775bd4fca 100644 --- a/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java +++ b/spring-integration-webflux/src/test/java/org/springframework/integration/webflux/dsl/WebFluxDslTests.java @@ -49,7 +49,6 @@ import org.springframework.integration.channel.FixedSubscriberChannel; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.MessageChannels; import org.springframework.integration.dsl.context.IntegrationFlowContext; import org.springframework.integration.handler.AbstractReplyProducingMessageHandler; @@ -267,7 +266,7 @@ public class WebFluxDslTests { @Test public void testDynamicHttpEndpoint() { IntegrationFlow flow = - IntegrationFlows.from(WebFlux.inboundGateway("/dynamic") + IntegrationFlow.from(WebFlux.inboundGateway("/dynamic") .requestMapping(r -> r.params("name")) .payloadExpression("#requestParams.name[0]")) .transform(String::toLowerCase) @@ -298,7 +297,7 @@ public class WebFluxDslTests { @Disabled("Fails after some recent SF change") public void testValidation() { IntegrationFlow flow = - IntegrationFlows.from( + IntegrationFlow.from( WebFlux.inboundGateway("/validation") .requestMapping((mapping) -> mapping .methods(HttpMethod.POST) @@ -325,7 +324,7 @@ public class WebFluxDslTests { @Test public void testErrorChannelFlow() { IntegrationFlow flow = - IntegrationFlows.from( + IntegrationFlow.from( WebFlux.inboundGateway("/errorFlow") .errorChannel(new FixedSubscriberChannel( new AbstractReplyProducingMessageHandler() { @@ -421,7 +420,7 @@ public class WebFluxDslTests { @Bean public IntegrationFlow httpReactiveProxyFlow() { - return IntegrationFlows + return IntegrationFlow .from(Http.inboundGateway("/service2") .requestMapping(r -> r.params("name"))) .handle(WebFlux.>outboundGateway(m -> @@ -436,7 +435,7 @@ public class WebFluxDslTests { @Bean public IntegrationFlow httpReactiveInboundChannelAdapterFlow() { - return IntegrationFlows + return IntegrationFlow .from(WebFlux.inboundChannelAdapter("/reactivePost") .requestMapping(m -> m.methods(HttpMethod.POST)) .requestPayloadType(ResolvableType.forClassWithGenerics(Flux.class, String.class)) @@ -450,7 +449,7 @@ public class WebFluxDslTests { @Bean public IntegrationFlow httpReactiveInboundGatewayFlowWithErrors() { - return IntegrationFlows + return IntegrationFlow .from(WebFlux.inboundGateway("/reactivePostErrors") .requestMapping(m -> m.methods(HttpMethod.POST)) .requestPayloadType(ResolvableType.forClassWithGenerics(Flux.class, String.class)) @@ -474,7 +473,7 @@ public class WebFluxDslTests { @Bean public IntegrationFlow sseFlow() { - return IntegrationFlows + return IntegrationFlow .from(WebFlux.inboundGateway("/sse") .requestMapping(m -> m.produces(MediaType.TEXT_EVENT_STREAM_VALUE)) .mappedResponseHeaders("*")) diff --git a/spring-integration-websocket/src/test/java/org/springframework/integration/websocket/dsl/WebSocketDslTests.java b/spring-integration-websocket/src/test/java/org/springframework/integration/websocket/dsl/WebSocketDslTests.java index 823e8d2c9f..19ab57e396 100644 --- a/spring-integration-websocket/src/test/java/org/springframework/integration/websocket/dsl/WebSocketDslTests.java +++ b/spring-integration-websocket/src/test/java/org/springframework/integration/websocket/dsl/WebSocketDslTests.java @@ -30,7 +30,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.integration.channel.QueueChannel; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.context.IntegrationFlowContext; import org.springframework.integration.websocket.ClientWebSocketContainer; import org.springframework.integration.websocket.ServerWebSocketContainer; @@ -78,7 +77,7 @@ public class WebSocketDslTests { QueueChannel dynamicRequestsChannel = new QueueChannel(); IntegrationFlow serverFlow = - IntegrationFlows.from(webSocketInboundChannelAdapter) + IntegrationFlow.from(webSocketInboundChannelAdapter) .channel(dynamicRequestsChannel) .get(); diff --git a/spring-integration-zeromq/src/test/java/org/springframework/integration/zeromq/dsl/ZeroMqDslTests.java b/spring-integration-zeromq/src/test/java/org/springframework/integration/zeromq/dsl/ZeroMqDslTests.java index d268e3d194..0e6c51eac7 100644 --- a/spring-integration-zeromq/src/test/java/org/springframework/integration/zeromq/dsl/ZeroMqDslTests.java +++ b/spring-integration-zeromq/src/test/java/org/springframework/integration/zeromq/dsl/ZeroMqDslTests.java @@ -34,7 +34,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.integration.config.EnableIntegration; import org.springframework.integration.dsl.IntegrationFlow; -import org.springframework.integration.dsl.IntegrationFlows; import org.springframework.integration.dsl.Transformers; import org.springframework.integration.dsl.context.IntegrationFlowContext; import org.springframework.integration.zeromq.ZeroMqHeaders; @@ -78,7 +77,7 @@ public class ZeroMqDslTests { for (int i = 0; i < 2; i++) { IntegrationFlow consumerFlow = - IntegrationFlows.from( + IntegrationFlow.from( ZeroMq.inboundChannelAdapter(this.context, SocketType.SUB) .connectUrl("tcp://localhost:" + this.subPubZeroMqProxy.getBackendPort()) .topics("someTopic") diff --git a/src/reference/asciidoc/amqp.adoc b/src/reference/asciidoc/amqp.adoc index 11be4131c6..f3e6145c19 100644 --- a/src/reference/asciidoc/amqp.adoc +++ b/src/reference/asciidoc/amqp.adoc @@ -52,7 +52,7 @@ The following listing shows the possible configuration options for an AMQP Inbou ---- @Bean public IntegrationFlow amqpInbound(ConnectionFactory connectionFactory) { - return IntegrationFlows.from(Amqp.inboundAdapter(connectionFactory, "aName")) + return IntegrationFlow.from(Amqp.inboundAdapter(connectionFactory, "aName")) .handle(m -> System.out.println(m.getPayload())) .get(); } @@ -283,7 +283,7 @@ The following example shows how to configure an `AmqpMessageSource`: ---- @Bean public IntegrationFlow flow() { - return IntegrationFlows.from(Amqp.inboundPolledAdapter(connectionFactory(), DSL_QUEUE), + return IntegrationFlow.from(Amqp.inboundPolledAdapter(connectionFactory(), DSL_QUEUE), e -> e.poller(Pollers.fixedDelay(1_000)).autoStartup(false)) .handle(p -> { ... @@ -328,7 +328,7 @@ The following listing shows the available attributes: ---- @Bean // return the upper cased payload public IntegrationFlow amqpInboundGateway(ConnectionFactory connectionFactory) { - return IntegrationFlows.from(Amqp.inboundGateway(connectionFactory, "foo")) + return IntegrationFlow.from(Amqp.inboundGateway(connectionFactory, "foo")) .transform(String.class, String::toUpperCase) .get(); } @@ -490,7 +490,7 @@ The following example shows the available properties for an AMQP outbound channe @Bean public IntegrationFlow amqpOutbound(AmqpTemplate amqpTemplate, MessageChannel amqpOutboundChannel) { - return IntegrationFlows.from(amqpOutboundChannel) + return IntegrationFlow.from(amqpOutboundChannel) .handle(Amqp.outboundAdapter(amqpTemplate) .routingKey("queue1")) // default exchange - route to queue 'queue1' .get(); @@ -1214,7 +1214,7 @@ The following example shows how to configure the channels with the Java DSL: ---- @Bean public IntegrationFlow pollableInFlow(ConnectionFactory connectionFactory) { - return IntegrationFlows.from(...) + return IntegrationFlow.from(...) ... .channel(Amqp.pollableChannel(connectionFactory) .queueName("foo")) @@ -1224,7 +1224,7 @@ public IntegrationFlow pollableInFlow(ConnectionFactory connectionFactory) { @Bean public IntegrationFlow messageDrivenInFow(ConnectionFactory connectionFactory) { - return IntegrationFlows.from(...) + return IntegrationFlow.from(...) ... .channel(Amqp.channel(connectionFactory) .queueName("bar")) @@ -1234,7 +1234,7 @@ public IntegrationFlow messageDrivenInFow(ConnectionFactory connectionFactory) { @Bean public IntegrationFlow pubSubInFlow(ConnectionFactory connectionFactory) { - return IntegrationFlows.from(...) + return IntegrationFlow.from(...) ... .channel(Amqp.publishSubscribeChannel(connectionFactory) .queueName("baz")) @@ -1361,7 +1361,7 @@ Consider the following integration flow: ---- @Bean public IntegrationFlow flow(RabbitTemplate template) { - return IntegrationFlows.from(Gateway.class) + return IntegrationFlow.from(Gateway.class) .split(s -> s.delimiters(",")) .transform(String::toUpperCase) .handle(Amqp.outboundAdapter(template).routingKey("rk")) @@ -1385,7 +1385,7 @@ The following example shows how to use `BoundRabbitChannelAdvice`: ---- @Bean public IntegrationFlow flow(RabbitTemplate template) { - return IntegrationFlows.from(Gateway.class) + return IntegrationFlow.from(Gateway.class) .split(s -> s.delimiters(",") .advice(new BoundRabbitChannelAdvice(template, Duration.ofSeconds(10)))) .transform(String::toUpperCase) diff --git a/src/reference/asciidoc/bridge.adoc b/src/reference/asciidoc/bridge.adoc index 8951b4571b..d812aff435 100644 --- a/src/reference/asciidoc/bridge.adoc +++ b/src/reference/asciidoc/bridge.adoc @@ -119,7 +119,7 @@ You can use the Java Domain Specific Language (DSL) to configure a bridge, as th ---- @Bean public IntegrationFlow bridgeFlow() { - return IntegrationFlows.from("polled") + return IntegrationFlow.from("polled") .bridge(e -> e.poller(Pollers.fixedDelay(5000).maxMessagesPerPoll(10))) .channel("direct") .get(); diff --git a/src/reference/asciidoc/channel-adapter.adoc b/src/reference/asciidoc/channel-adapter.adoc index 0613d44da3..bc9e68e1a4 100644 --- a/src/reference/asciidoc/channel-adapter.adoc +++ b/src/reference/asciidoc/channel-adapter.adoc @@ -23,7 +23,7 @@ The following example defines two `inbound-channel-adapter` instances: ---- @Bean public IntegrationFlow source1() { - return IntegrationFlows.from(() -> new GenericMessage<>(...), + return IntegrationFlow.from(() -> new GenericMessage<>(...), e -> e.poller(p -> p.fixedRate(5000))) ... .get(); @@ -31,7 +31,7 @@ public IntegrationFlow source1() { @Bean public IntegrationFlow source2() { - return IntegrationFlows.from(() -> new GenericMessage<>(...), + return IntegrationFlow.from(() -> new GenericMessage<>(...), e -> e.poller(p -> p.cron("30 * 9-17 * * MON-FRI"))) ... .get(); diff --git a/src/reference/asciidoc/channel.adoc b/src/reference/asciidoc/channel.adoc index 67abeb6378..9c3cc92b90 100644 --- a/src/reference/asciidoc/channel.adoc +++ b/src/reference/asciidoc/channel.adoc @@ -687,7 +687,7 @@ public PollableChannel priorityQueue(BasicMessageGroupStore mongoDbChannelMessag ---- @Bean public IntegrationFlow priorityFlow(PriorityCapableChannelMessageStore mongoDbChannelMessageStore) { - return IntegrationFlows.from((Channels c) -> + return IntegrationFlow.from((Channels c) -> c.priority("priorityChannel", mongoDbChannelMessageStore, "priorityGroup")) .... .get(); diff --git a/src/reference/asciidoc/control-bus.adoc b/src/reference/asciidoc/control-bus.adoc index 45d584d9a5..0d356e68b8 100644 --- a/src/reference/asciidoc/control-bus.adoc +++ b/src/reference/asciidoc/control-bus.adoc @@ -58,7 +58,7 @@ Similarly, you can configure Java DSL flow definitions as follows: ---- @Bean public IntegrationFlow controlBusFlow() { - return IntegrationFlows.from("controlBus") + return IntegrationFlow.from("controlBus") .controlBus() .get(); } diff --git a/src/reference/asciidoc/delayer.adoc b/src/reference/asciidoc/delayer.adoc index 389e884ffa..437d21d35b 100644 --- a/src/reference/asciidoc/delayer.adoc +++ b/src/reference/asciidoc/delayer.adoc @@ -32,7 +32,7 @@ If you need to determine the delay for each message, you can also provide the Sp ---- @Bean public IntegrationFlow flow() { - return IntegrationFlows.from("input") + return IntegrationFlow.from("input") .delay("delayer.messageGroupId", d -> d .defaultDelay(3_000L) .delayExpression("headers['delay']")) diff --git a/src/reference/asciidoc/dsl.adoc b/src/reference/asciidoc/dsl.adoc index de140496ac..cc5ea01aec 100644 --- a/src/reference/asciidoc/dsl.adoc +++ b/src/reference/asciidoc/dsl.adoc @@ -11,7 +11,7 @@ We also use and support lambdas (available with Java 8) to further simplify Java The https://github.com/spring-projects/spring-integration-samples/tree/main/dsl/cafe-dsl[cafe] offers a good example of using the DSL. -The DSL is presented by the `IntegrationFlows` factory for the `IntegrationFlowBuilder`. +The DSL is presented by the `IntegrationFlow` fluent API (see `IntegrationFlowBuilder`). This produces the `IntegrationFlow` component, which should be registered as a Spring bean (by using the `@Bean` annotation). The builder pattern is used to express arbitrarily complex structures as a hierarchy of methods that can accept lambdas as arguments. @@ -38,7 +38,7 @@ public class MyConfiguration { @Bean public IntegrationFlow myFlow() { - return IntegrationFlows.fromSupplier(integerSource()::getAndIncrement, + return IntegrationFlow.fromSupplier(integerSource()::getAndIncrement, c -> c.poller(Pollers.fixedRate(100))) .channel("inputChannel") .filter((Integer p) -> p > 0) @@ -76,14 +76,14 @@ Conceptually, integration processes are constructed by composing these endpoints Note that EIP does not formally define the term 'message flow', but it is useful to think of it as a unit of work that uses well known messaging patterns. The DSL provides an `IntegrationFlow` component to define a composition of channels and endpoints between them, but now `IntegrationFlow` plays only the configuration role to populate real beans in the application context and is not used at runtime. However, the bean for `IntegrationFlow` can be autowired as a `Lifecycle` to control `start()` and `stop()` for the whole flow which is delegated to all the Spring Integration components associated with this `IntegrationFlow`. -The following example uses the `IntegrationFlows` factory to define an `IntegrationFlow` bean by using EIP-methods from `IntegrationFlowBuilder`: +The following example uses the `IntegrationFlow` fluent API to define an `IntegrationFlow` bean by using EIP-methods from `IntegrationFlowBuilder`: ==== [source,java] ---- @Bean public IntegrationFlow integerFlow() { - return IntegrationFlows.from("input") + return IntegrationFlow.from("input") .transform(Integer::parseInt) .get(); } @@ -102,7 +102,7 @@ Consider another example: ---- @Bean public IntegrationFlow myFlow() { - return IntegrationFlows.from("input") + return IntegrationFlow.from("input") .filter("World"::equals) .transform("Hello "::concat) .handle(System.out::println) @@ -190,7 +190,7 @@ public MessageChannel publishSubscribe() { @Bean public IntegrationFlow channelFlow() { - return IntegrationFlows.from("input") + return IntegrationFlow.from("input") .fixedSubscriberChannel() .channel("queueChannel") .channel(publishSubscribe()) @@ -217,7 +217,7 @@ The following example is wrong: ---- @Bean public IntegrationFlow startFlow() { - return IntegrationFlows.from("input") + return IntegrationFlow.from("input") .transform(...) .channel(MessageChannels.queue("queueChannel")) .get(); @@ -225,7 +225,7 @@ public IntegrationFlow startFlow() { @Bean public IntegrationFlow endFlow() { - return IntegrationFlows.from(MessageChannels.queue("queueChannel")) + return IntegrationFlow.from(MessageChannels.queue("queueChannel")) .handle(...) .get(); } @@ -276,7 +276,7 @@ The following example demonstrates how to change the publishing thread from the ---- @Bean public IntegrationFlow reactiveEndpointFlow() { - return IntegrationFlows + return IntegrationFlow .from("inputChannel") .transform(Integer::parseInt, e -> e.reactive(flux -> flux.publishOn(Schedulers.parallel()))) @@ -298,7 +298,7 @@ Each of them has generic arguments, so it lets you configure an endpoint and eve ---- @Bean public IntegrationFlow flow2() { - return IntegrationFlows.from(this.inputChannel) + return IntegrationFlow.from(this.inputChannel) .transform(new PayloadSerializingTransformer(), c -> c.autoStartup(false).id("payloadSerializingTransformer")) .transform((Integer p) -> p * 2, c -> c.advice(this.expressionAdvice())) @@ -342,7 +342,7 @@ The following example shows how to use it: ---- @Bean public IntegrationFlow transformFlow() { - return IntegrationFlows.from("input") + return IntegrationFlow.from("input") .transform(Transformers.fromJson(MyPojo.class)) .transform(Transformers.serializer()) .get(); @@ -364,9 +364,9 @@ Also see <>. Typically, message flows start from an inbound channel adapter (such as ``). The adapter is configured with ``, and it asks a `MessageSource` to periodically produce messages. Java DSL allows for starting `IntegrationFlow` from a `MessageSource`, too. -For this purpose, the `IntegrationFlows` builder factory provides an overloaded `IntegrationFlows.from(MessageSource messageSource)` method. +For this purpose, the `IntegrationFlow` fluent API provides an overloaded `IntegrationFlow.from(MessageSource messageSource)` method. You can configure the `MessageSource` as a bean and provide it as an argument for that method. -The second parameter of `IntegrationFlows.from()` is a `Consumer` lambda that lets you provide options (such as `PollerMetadata` or `SmartLifecycle`) for the `SourcePollingChannelAdapter`. +The second parameter of `IntegrationFlow.from()` is a `Consumer` lambda that lets you provide options (such as `PollerMetadata` or `SmartLifecycle`) for the `SourcePollingChannelAdapter`. The following example shows how to use the fluent API and a lambda to create an `IntegrationFlow`: ==== @@ -379,7 +379,7 @@ public MessageSource jdbcMessageSource() { @Bean public IntegrationFlow pollingFlow() { - return IntegrationFlows.from(jdbcMessageSource(), + return IntegrationFlow.from(jdbcMessageSource(), c -> c.poller(Pollers.fixedRate(100).maxMessagesPerPoll(1))) .transform(Transformers.toJson()) .channel("furtherProcessChannel") @@ -388,7 +388,7 @@ public IntegrationFlow pollingFlow() { ---- ==== -For those cases that have no requirements to build `Message` objects directly, you can use a `IntegrationFlows.fromSupplier()` variant that is based on the `java.util.function.Supplier` . +For those cases that have no requirements to build `Message` objects directly, you can use a `IntegrationFlow.fromSupplier()` variant that is based on the `java.util.function.Supplier` . The result of the `Supplier.get()` is automatically wrapped in a `Message` (if it is not already a `Message`). [[java-dsl-routers]] @@ -411,7 +411,7 @@ The fluent API also provides `AbstractMappingMessageRouter` options such as `cha ---- @Bean public IntegrationFlow routeFlowByLambda() { - return IntegrationFlows.from("routerInput") + return IntegrationFlow.from("routerInput") .route(p -> p % 2 == 0, m -> m.suffix("Channel") .channelMapping(true, "even") @@ -429,7 +429,7 @@ The following example shows a simple expression-based router: ---- @Bean public IntegrationFlow routeFlowByExpression() { - return IntegrationFlows.from("routerInput") + return IntegrationFlow.from("routerInput") .route("headers['destChannel']") .get(); } @@ -443,7 +443,7 @@ The `routeToRecipients()` method takes a `Consumer`, as ---- @Bean public IntegrationFlow recipientListFlow() { - return IntegrationFlows.from("recipientListInput") + return IntegrationFlow.from("recipientListInput") .transform(p -> p.replaceFirst("Payload", "")) .routeToRecipients(r -> r .recipient("thing1-channel", "'thing1' == payload") @@ -482,7 +482,7 @@ The following example shows how to use the `split()` method by providing a lambd ---- @Bean public IntegrationFlow splitFlow() { - return IntegrationFlows.from("splitInput") + return IntegrationFlow.from("splitInput") .split(s -> s.applySequence(false).delimiters(",")) .channel(MessageChannels.executor(taskExecutor())) .get(); @@ -506,7 +506,7 @@ The following example shows a canonical example of the splitter-aggregator patte ---- @Bean public IntegrationFlow splitAggregateFlow() { - return IntegrationFlows.from("splitAggregateInput") + return IntegrationFlow.from("splitAggregateInput") .split() .channel(MessageChannels.executor(this.taskExecutor())) .resequence() @@ -550,7 +550,7 @@ Having that, we can define a flow as follows: ---- @Bean public IntegrationFlow myFlow() { - return IntegrationFlows.from("flow3Input") + return IntegrationFlow.from("flow3Input") .handle((p, h) -> p * 2) .get(); } @@ -569,7 +569,7 @@ The following example shows what the resulting `IntegrationFlow` might look like ---- @Bean public IntegrationFlow integerFlow() { - return IntegrationFlows.from("input") + return IntegrationFlow.from("input") .transform(p - > new String(p, "UTF-8")) .handle(Integer.class, (p, h) -> p * 2) .get(); @@ -590,7 +590,7 @@ public BytesToIntegerConverter bytesToIntegerConverter() { @Bean public IntegrationFlow integerFlow() { - return IntegrationFlows.from("input") + return IntegrationFlow.from("input") .handle(Integer.class, (p, h) -> p * 2) .get(); } @@ -619,7 +619,7 @@ Also, the `IntegrationFlow`-based methods allows calling existing `IntegrationFl ---- @Bean IntegrationFlow someFlow() { - return IntegrationFlows + return IntegrationFlow .from(...) .gateway(subFlow()) .handle(...) @@ -971,7 +971,7 @@ The following example shows how to use three of them (`Amqp`, `Jms`, and `Mail`) ---- @Bean public IntegrationFlow amqpFlow() { - return IntegrationFlows.from(Amqp.inboundGateway(this.rabbitConnectionFactory, queue())) + return IntegrationFlow.from(Amqp.inboundGateway(this.rabbitConnectionFactory, queue())) .transform("hello "::concat) .transform(String.class, String::toUpperCase) .get(); @@ -979,7 +979,7 @@ public IntegrationFlow amqpFlow() { @Bean public IntegrationFlow jmsOutboundGatewayFlow() { - return IntegrationFlows.from("jmsOutboundGatewayChannel") + return IntegrationFlow.from("jmsOutboundGatewayChannel") .handle(Jms.outboundGateway(this.jmsConnectionFactory) .replyContainer(c -> c.concurrentConsumers(3) @@ -990,7 +990,7 @@ public IntegrationFlow jmsOutboundGatewayFlow() { @Bean public IntegrationFlow sendMailFlow() { - return IntegrationFlows.from("sendMailChannel") + return IntegrationFlow.from("sendMailChannel") .handle(Mail.outboundAdapter("localhost") .port(smtpPort) .credentials("user", "pw") @@ -1024,7 +1024,7 @@ public QueueChannelSpec wrongMessagesChannel() { @Bean public IntegrationFlow xpathFlow(MessageChannel wrongMessagesChannel) { - return IntegrationFlows.from("inputChannel") + return IntegrationFlow.from("inputChannel") .filter(new StringValueTestXPathMessageSelector("namespace-uri(/*)", "my:namespace"), e -> e.discardChannel(wrongMessagesChannel)) .log(LoggingHandler.Level.ERROR, "test.category", m -> m.getHeaders().getId()) @@ -1200,7 +1200,7 @@ Flux> messageFlux = QueueChannel resultChannel = new QueueChannel(); IntegrationFlow integrationFlow = - IntegrationFlows.from(messageFlux) + IntegrationFlow.from(messageFlux) .transform(p -> p * 2) .channel(resultChannel) .get(); @@ -1274,7 +1274,7 @@ public interface ControlBusGateway { @Bean public IntegrationFlow controlBusFlow() { - return IntegrationFlows.from(ControlBusGateway.class) + return IntegrationFlow.from(ControlBusGateway.class) .controlBus() .get(); } @@ -1287,7 +1287,7 @@ Nevertheless, the `requestChannel` is ignored and overridden with that internal Otherwise, creating such a configuration by using `IntegrationFlow` does not make sense. By default, a `GatewayProxyFactoryBean` gets a conventional bean name, such as `[FLOW_BEAN_NAME.gateway]`. -You can change that ID by using the `@MessagingGateway.name()` attribute or the overloaded `IntegrationFlows.from(Class serviceInterface, Consumer endpointConfigurer)` factory method. +You can change that ID by using the `@MessagingGateway.name()` attribute or the overloaded `IntegrationFlow.from(Class serviceInterface, Consumer endpointConfigurer)` factory method. Also, all the attributes from the `@MessagingGateway` annotation on the interface are applied to the target `GatewayProxyFactoryBean`. When annotation configuration is not applicable, the `Consumer` variant can be used for providing appropriate option for the target proxy. This DSL method is available starting with version 5.2. @@ -1299,7 +1299,7 @@ With Java 8, you can even create an integration gateway with the `java.util.func ---- @Bean public IntegrationFlow errorRecovererFlow() { - return IntegrationFlows.from(Function.class, (gateway) -> gateway.beanName("errorRecovererFunction")) + return IntegrationFlow.from(Function.class, (gateway) -> gateway.beanName("errorRecovererFunction")) .handle((GenericHandler) (p, h) -> { throw new RuntimeException("intentional"); }, e -> e.advice(retryAdvice())) @@ -1387,21 +1387,21 @@ The input channel of any endpoint in the flow can be used to send messages from Furthermore, with a `@MessagingGateway` contract, Content Enricher components, composite endpoints like a ``, and now with `IntegrationFlow` beans (e.g. `IntegrationFlowAdapter`), it is straightforward enough to distribute the business logic between shorter, reusable parts. All that is needed for the final composition is knowledge about a `MessageChannel` to send to or receive from. -Starting with version `5.5.4`, to abstract more from `MessageChannel` and hide implementation details from the end-user, the `IntegrationFlows` introduces the `from(IntegrationFlow)` factory method to allow starting the current `IntegrationFlow` from the output of an existing flow: +Starting with version `5.5.4`, to abstract more from `MessageChannel` and hide implementation details from the end-user, the `IntegrationFlow` introduces the `from(IntegrationFlow)` factory method to allow starting the current `IntegrationFlow` from the output of an existing flow: ==== [source,java] ---- @Bean IntegrationFlow templateSourceFlow() { - return IntegrationFlows.fromSupplier(() -> "test data") + return IntegrationFlow.fromSupplier(() -> "test data") .channel("sourceChannel") .get(); } @Bean IntegrationFlow compositionMainFlow(IntegrationFlow templateSourceFlow) { - return IntegrationFlows.from(templateSourceFlow) + return IntegrationFlow.from(templateSourceFlow) .transform(String::toUpperCase) .channel(c -> c.queue("compositionMainFlowResult")) .get(); diff --git a/src/reference/asciidoc/endpoint.adoc b/src/reference/asciidoc/endpoint.adoc index 9d6c6f63d3..b8b9f71b6c 100644 --- a/src/reference/asciidoc/endpoint.adoc +++ b/src/reference/asciidoc/endpoint.adoc @@ -339,7 +339,7 @@ public PollerMetadata defaultPoller() { // No 'poller' attribute because there is a default global poller @Bean public IntegrationFlow transformFlow(MyTransformer transformer) { - return IntegrationFlows.from(MessageChannels.queue("pollable")) + return IntegrationFlow.from(MessageChannels.queue("pollable")) .transform(transformer) // No 'poller' attribute because there is a default global poller .channel("output") .get(); diff --git a/src/reference/asciidoc/event.adoc b/src/reference/asciidoc/event.adoc index 8eef4305f3..5c0ee86e4d 100644 --- a/src/reference/asciidoc/event.adoc +++ b/src/reference/asciidoc/event.adoc @@ -91,7 +91,7 @@ public ApplicationEventListeningMessageProducer eventsAdapter() { public IntegrationFlow eventFlow(ApplicationEventListeningMessageProducer eventsAdapter, MessageChannel eventErrorChannel) { - return IntegrationFlows.from(eventsAdapter, e -> e.errorChannel(eventErrorChannel)) + return IntegrationFlow.from(eventsAdapter, e -> e.errorChannel(eventErrorChannel)) .handle(...) ... .get(); diff --git a/src/reference/asciidoc/feed.adoc b/src/reference/asciidoc/feed.adoc index feca7f5a41..c0a9bcbe69 100644 --- a/src/reference/asciidoc/feed.adoc +++ b/src/reference/asciidoc/feed.adoc @@ -58,7 +58,7 @@ public class ContextConfiguration { @Bean public IntegrationFlow feedFlow() { - return IntegrationFlows + return IntegrationFlow .from(Feed.inboundAdapter(this.feedResource, "feedTest") .preserveWireFeed(true), e -> e.poller(p -> p.fixedDelay(100))) diff --git a/src/reference/asciidoc/file.adoc b/src/reference/asciidoc/file.adoc index 80cc2a0b97..c307ccee2d 100644 --- a/src/reference/asciidoc/file.adoc +++ b/src/reference/asciidoc/file.adoc @@ -462,7 +462,7 @@ public class FileReadingJavaApplication { @Bean public IntegrationFlow fileReadingFlow() { - return IntegrationFlows + return IntegrationFlow .from(Files.inboundAdapter(new File(INBOUND_PATH)) .patternFilter("*.txt"), e -> e.poller(Pollers.fixedDelay(1000))) @@ -929,7 +929,7 @@ public class FileWritingJavaApplication { @Bean public IntegrationFlow fileWritingFlow() { - return IntegrationFlows.from("fileWritingInput") + return IntegrationFlow.from("fileWritingInput") .enrichHeaders(h -> h.header(FileHeaders.FILENAME, "foo.txt") .header("directory", new File(tmpDir.getRoot(), "fileWritingFlow"))) .handle(Files.outboundGateway(m -> m.getHeaders().get("directory"))) @@ -1006,7 +1006,7 @@ public class FileSplitterApplication { @Bean public IntegrationFlow fileSplitterFlow() { - return IntegrationFlows + return IntegrationFlow .from(Files.inboundAdapter(tmpDir.getRoot()) .filter(new ChainFileListFilter() .addFilter(new AcceptOnceFileListFilter<>()) diff --git a/src/reference/asciidoc/ftp.adoc b/src/reference/asciidoc/ftp.adoc index 724398fc45..38d28f5d9e 100644 --- a/src/reference/asciidoc/ftp.adoc +++ b/src/reference/asciidoc/ftp.adoc @@ -559,7 +559,7 @@ public class FtpJavaApplication { @Bean public IntegrationFlow ftpInboundFlow() { - return IntegrationFlows + return IntegrationFlow .from(Ftp.inboundAdapter(this.ftpSessionFactory) .preserveTimestamp(true) .remoteDirectory("foo") @@ -772,7 +772,7 @@ This allows files retrieved from different directories to be downloaded to simil ---- @Bean public IntegrationFlow flow() { - return IntegrationFlows.from(Ftp.inboundAdapter(sf()) + return IntegrationFlow.from(Ftp.inboundAdapter(sf()) .filter(new FtpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate")) .localDirectory(new File(tmpDir)) .localFilenameExpression("#remoteDirectory + T(java.io.File).separator + #root") @@ -979,7 +979,7 @@ public class FtpJavaApplication { @Bean public IntegrationFlow ftpOutboundFlow() { - return IntegrationFlows.from("toFtpChannel") + return IntegrationFlow.from("toFtpChannel") .handle(Ftp.outboundAdapter(ftpSessionFactory(), FileExistsMode.FAIL) .useTemporaryFileName(false) .fileNameExpression("headers['" + FileHeaders.FILENAME + "']") diff --git a/src/reference/asciidoc/functions-support.adoc b/src/reference/asciidoc/functions-support.adoc index de0e0013c7..dfce0d1448 100644 --- a/src/reference/asciidoc/functions-support.adoc +++ b/src/reference/asciidoc/functions-support.adoc @@ -101,7 +101,7 @@ public Supplier stringSupplier() { @Bean public IntegrationFlow supplierFlow() { - return IntegrationFlows.from(stringSupplier()) + return IntegrationFlow.from(stringSupplier()) .transform(toUpperCaseFunction()) .channel("suppliedChannel") .get(); diff --git a/src/reference/asciidoc/gateway.adoc b/src/reference/asciidoc/gateway.adoc index f59d2ba80a..9023a77a6a 100644 --- a/src/reference/asciidoc/gateway.adoc +++ b/src/reference/asciidoc/gateway.adoc @@ -893,4 +893,4 @@ At that time, the calling thread starts waiting for the reply. If the flow was completely synchronous, the reply is immediately available. For asynchronous flows, the thread waits for up to this time. -See <<./dsl.adoc#integration-flow-as-gateway,`IntegrationFlow` as Gateway>> in the Java DSL chapter for options to define gateways through `IntegrationFlows`. +See <<./dsl.adoc#integration-flow-as-gateway,`IntegrationFlow` as Gateway>> in the Java DSL chapter for options to define gateways through `IntegrationFlow`. diff --git a/src/reference/asciidoc/graphql.adoc b/src/reference/asciidoc/graphql.adoc index ff59bbaeb8..592a01f74b 100644 --- a/src/reference/asciidoc/graphql.adoc +++ b/src/reference/asciidoc/graphql.adoc @@ -61,7 +61,7 @@ GraphQlMessageHandler handler(ExecutionGraphQlService graphQlService) { @Bean IntegrationFlow graphqlQueryMessageHandlerFlow(GraphQlMessageHandler handler) { - return IntegrationFlows.from(MessageChannels.flux("inputChannel")) + return IntegrationFlow.from(MessageChannels.flux("inputChannel")) .handle(handler) .channel(c -> c.flux("resultChannel")) .get(); diff --git a/src/reference/asciidoc/http.adoc b/src/reference/asciidoc/http.adoc index 4faa1878f5..4799683260 100644 --- a/src/reference/asciidoc/http.adoc +++ b/src/reference/asciidoc/http.adoc @@ -775,7 +775,7 @@ The following example shows how to configure an inbound gateway with the Java DS ---- @Bean public IntegrationFlow inbound() { - return IntegrationFlows.from(Http.inboundGateway("/foo") + return IntegrationFlow.from(Http.inboundGateway("/foo") .requestMapping(m -> m.methods(HttpMethod.POST)) .requestPayloadType(String.class)) .channel("httpRequest") @@ -810,7 +810,7 @@ The following example shows how to configure an outbound gateway with the Java D ---- @Bean public IntegrationFlow outbound() { - return IntegrationFlows.from("httpOutRequest") + return IntegrationFlow.from("httpOutRequest") .handle(Http.outboundGateway("http://localhost:8080/foo") .httpMethod(HttpMethod.POST) .expectedResponseType(String.class)) diff --git a/src/reference/asciidoc/ip.adoc b/src/reference/asciidoc/ip.adoc index 92aabbdeda..4d1470cbae 100644 --- a/src/reference/asciidoc/ip.adoc +++ b/src/reference/asciidoc/ip.adoc @@ -228,7 +228,7 @@ The following example shows how to configure an inbound UDP adapter with the Jav ---- @Bean public IntegrationFlow udpIn() { - return IntegrationFlows.from(Udp.inboundAdapter(11111)) + return IntegrationFlow.from(Udp.inboundAdapter(11111)) .channel("udpChannel") .get(); } @@ -283,7 +283,7 @@ The following example shows the equivalent configuration with the Java DSL: ---- @Bean public IntegrationFlow udpEchoUpcaseServer() { - return IntegrationFlows.from(Udp.inboundAdapter(11111).id("udpIn")) + return IntegrationFlow.from(Udp.inboundAdapter(11111).id("udpIn")) .transform(p -> new String(p).toUpperCase()) .handle(Udp.outboundAdapter("headers['ip_packetAddress']") .socketExpression("@udpIn.socket")) @@ -2266,7 +2266,7 @@ Here are some examples of using the DSL to configure flows using the DSL. ---- @Bean public IntegrationFlow server() { - return IntegrationFlows.from(Tcp.inboundAdapter(Tcp.netServer(1234) + return IntegrationFlow.from(Tcp.inboundAdapter(Tcp.netServer(1234) .deserializer(TcpCodecs.lengthHeader1()) .backlog(30)) .errorChannel("tcpIn.errorChannel") @@ -2296,7 +2296,7 @@ public IntegrationFlow client() { ---- @Bean public IntegrationFlow server() { - return IntegrationFlows.from(Tcp.inboundGateway(Tcp.netServer(1234) + return IntegrationFlow.from(Tcp.inboundGateway(Tcp.netServer(1234) .deserializer(TcpCodecs.lengthHeader1()) .serializer(TcpCodecs.lengthHeader1()) .backlog(30)) diff --git a/src/reference/asciidoc/jms.adoc b/src/reference/asciidoc/jms.adoc index fb88c87d84..94aa4abfb8 100644 --- a/src/reference/asciidoc/jms.adoc +++ b/src/reference/asciidoc/jms.adoc @@ -56,7 +56,7 @@ The following example defines an inbound channel adapter with a `Destination` re ---- @Bean public IntegrationFlow jmsInbound(ConnectionFactory connectionFactory) { - return IntegrationFlows.from( + return IntegrationFlow.from( Jms.inboundAdapter(connectionFactory) .destination("inQueue"), e -> e.poller(poller -> poller.fixedRate(30000))) @@ -148,7 +148,7 @@ The following example defines a message-driven channel adapter with a `Destinati ---- @Bean public IntegrationFlow jmsMessageDrivenRedeliveryFlow() { - return IntegrationFlows + return IntegrationFlow .from(Jms.messageDrivenChannelAdapter(jmsConnectionFactory()) .destination("inQueue")) .channel("exampleChannel") diff --git a/src/reference/asciidoc/jpa.adoc b/src/reference/asciidoc/jpa.adoc index f47c40eafc..70e6fa03e2 100644 --- a/src/reference/asciidoc/jpa.adoc +++ b/src/reference/asciidoc/jpa.adoc @@ -445,7 +445,7 @@ public class JpaJavaApplication { @Bean public IntegrationFlow pollingAdapterFlow() { - return IntegrationFlows + return IntegrationFlow .from(Jpa.inboundAdapter(this.entityManagerFactory) .entityClass(StudentDomain.class) .maxResults(1) diff --git a/src/reference/asciidoc/kafka.adoc b/src/reference/asciidoc/kafka.adoc index aa53bdd88a..2b90c89beb 100644 --- a/src/reference/asciidoc/kafka.adoc +++ b/src/reference/asciidoc/kafka.adoc @@ -239,7 +239,7 @@ The following example shows how to configure a message-driven channel adapter: ---- @Bean public IntegrationFlow topic1ListenerFromKafkaFlow() { - return IntegrationFlows + return IntegrationFlow .from(Kafka.messageDrivenChannelAdapter(consumerFactory(), KafkaMessageDrivenChannelAdapter.ListenerMode.record, TEST_TOPIC1) .configureListenerContainer(c -> @@ -332,7 +332,7 @@ The following example shows how to do so: ---- @Bean public IntegrationFlow topic2ListenerFromKafkaFlow() { - return IntegrationFlows + return IntegrationFlow .from(Kafka.messageDrivenChannelAdapter(kafkaListenerContainerFactory().createContainer(TEST_TOPIC2), KafkaMessageDrivenChannelAdapter.ListenerMode.record) .id("topic2Adapter")) @@ -360,7 +360,7 @@ The `KafkaMessageSource` provides a pollable channel adapter implementation. ---- @Bean public IntegrationFlow flow(ConsumerFactory cf) { - return IntegrationFlows.from(Kafka.inboundChannelAdapter(cf, "myTopic") + return IntegrationFlow.from(Kafka.inboundChannelAdapter(cf, "myTopic") .groupId("myDslGroupId"), e -> e.poller(Pollers.fixedDelay(5000))) .handle(System.out::println) .get(); @@ -437,7 +437,7 @@ The following example shows how to configure a gateway: public IntegrationFlow outboundGateFlow( ReplyingKafkaTemplate kafkaTemplate) { - return IntegrationFlows.from("kafkaRequests") + return IntegrationFlow.from("kafkaRequests") .handle(Kafka.outboundGateway(kafkaTemplate)) .channel("kafkaReplies") .get(); @@ -497,7 +497,7 @@ Alternatively, you can also use a configuration similar to the following bean: ---- @Bean public IntegrationFlow outboundGateFlow() { - return IntegrationFlows.from("kafkaRequests") + return IntegrationFlow.from("kafkaRequests") .handle(Kafka.outboundGateway(producerFactory(), replyContainer()) .configureKafkaTemplate(t -> t.replyTimeout(30_000))) .channel("kafkaReplies") @@ -524,7 +524,7 @@ The following example shows how to configure an inbound gateway: public IntegrationFlow serverGateway( ConcurrentMessageListenerContainer container, KafkaTemplate replyTemplate) { - return IntegrationFlows + return IntegrationFlow .from(Kafka.inboundGateway(container, replyTemplate) .replyTimeout(30_000)) .transform(String::toUpperCase) @@ -589,7 +589,7 @@ Alternatively, you could configure an upper-case converter by using code similar ---- @Bean public IntegrationFlow serverGateway() { - return IntegrationFlows + return IntegrationFlow .from(Kafka.inboundGateway(consumerFactory(), containerProperties(), producerFactory()) .replyTimeout(30_000)) @@ -619,7 +619,7 @@ Each channel requires a `KafkaTemplate` for the sending side and either a listen public IntegrationFlow flowWithSubscribable(KafkaTemplate template, ConcurrentKafkaListenerContainerFactory containerFactory) { - return IntegrationFlows.from(...) + return IntegrationFlow.from(...) ... .channel(Kafka.channel(template, containerFactory, "someTopic1").groupId("group1")) ... @@ -630,7 +630,7 @@ public IntegrationFlow flowWithSubscribable(KafkaTemplate templ public IntegrationFlow flowWithPubSub(KafkaTemplate template, ConcurrentKafkaListenerContainerFactory containerFactory) { - return IntegrationFlows.from(...) + return IntegrationFlow.from(...) ... .publishSubscribeChannel(pubSub(template, containerFactory), pubsub -> pubsub @@ -652,7 +652,7 @@ public BroadcastCapableChannel pubSub(KafkaTemplate template, public IntegrationFlow flowWithPollable(KafkaTemplate template, KafkaMessageSource source) { - return IntegrationFlows.from(...) + return IntegrationFlow.from(...) ... .channel(Kafka.pollableChannel(template, source, "someTopic3").groupId("group3")) .handle(..., e -> e.poller(...)) @@ -821,7 +821,7 @@ public MessagingTransformer transformer( @Bean public IntegrationFlow flow() { - return IntegrationFlows.from(MessagingFunction.class) + return IntegrationFlow.from(MessagingFunction.class) ... .get(); } @@ -856,7 +856,7 @@ public class FuturesChannelApplication { @Bean IntegrationFlow inbound(ConsumerFactory consumerFactory, Handler handler) { - return IntegrationFlows.from(Kafka.messageDrivenChannelAdapter(consumerFactory, + return IntegrationFlow.from(Kafka.messageDrivenChannelAdapter(consumerFactory, ListenerMode.batch, "inTopic")) .handle(handler) .get(); @@ -864,7 +864,7 @@ public class FuturesChannelApplication { @Bean IntegrationFlow outbound(KafkaTemplate kafkaTemplate) { - return IntegrationFlows.from(Gate.class) + return IntegrationFlow.from(Gate.class) .enrichHeaders(h -> h .header(KafkaHeaders.TOPIC, "outTopic") .headerExpression(KafkaIntegrationHeaders.FUTURE_TOKEN, "headers[id]")) diff --git a/src/reference/asciidoc/kotlin-dsl.adoc b/src/reference/asciidoc/kotlin-dsl.adoc index 73f98e640a..7d69d1b689 100644 --- a/src/reference/asciidoc/kotlin-dsl.adoc +++ b/src/reference/asciidoc/kotlin-dsl.adoc @@ -41,22 +41,22 @@ Such a global `integrationFlow()` function expects a lambda in builder style for See more overloaded `integrationFlow()` variants below. Many other scenarios require an `IntegrationFlow` to be started from source of data (e.g. `JdbcPollingChannelAdapter`, `JmsInboundGateway` or just an existing `MessageChannel`). -For this purpose, the Spring Integration Java DSL provides an `IntegrationFlows` factory with its large number of overloaded `from()` methods. -This factory can be used in Kotlin as well: +For this purpose, the Spring Integration Java DSL provides an `IntegrationFlow` fluent API with its large number of overloaded `from()` methods. +This API can be used in Kotlin as well: ==== [source, kotlin] ---- @Bean fun flowFromSupplier() = - IntegrationFlows.from({ "bar" }) { e -> e.poller { p -> p.fixedDelay(10).maxMessagesPerPoll(1) } } + IntegrationFlow.from({ "bar" }) { e -> e.poller { p -> p.fixedDelay(10).maxMessagesPerPoll(1) } } .channel { c -> c.queue("fromSupplierQueue") } .get() ---- ==== But unfortunately not all `from()` methods are compatible with Kotlin structures. -To fix the gap, this project provides a Kotlin DSL around an `IntegrationFlows` factory. +To fix the gap, this project provides a Kotlin DSL around an `IntegrationFlow` fluent API. It is implemented as a set of overloaded `integrationFlow()` functions. With a consumer for a `KotlinIntegrationFlowDefinition` to declare the rest of the flow as an `IntegrationFlow` lambda to reuse the mentioned above experience and also avoid `get()` call in the end. For example: diff --git a/src/reference/asciidoc/logging-adapter.adoc b/src/reference/asciidoc/logging-adapter.adoc index f931de6f40..c2d93781c0 100644 --- a/src/reference/asciidoc/logging-adapter.adoc +++ b/src/reference/asciidoc/logging-adapter.adoc @@ -98,7 +98,7 @@ public class LoggingJavaApplication { @Bean public IntegrationFlow loggingFlow() { - return IntegrationFlows.from(MyGateway.class) + return IntegrationFlow.from(MyGateway.class) .log(LoggingHandler.Level.DEBUG, "TEST_LOGGER", m -> m.getHeaders().getId() + ": " + m.getPayload()); } diff --git a/src/reference/asciidoc/mail.adoc b/src/reference/asciidoc/mail.adoc index 00da0a77a1..ab788d357d 100644 --- a/src/reference/asciidoc/mail.adoc +++ b/src/reference/asciidoc/mail.adoc @@ -612,7 +612,7 @@ public class MailApplication { @Bean public IntegrationFlow imapMailFlow() { - return IntegrationFlows + return IntegrationFlow .from(Mail.imapInboundAdapter("imap://user:pw@host:port/INBOX") .searchTermStrategy(this::fromAndNotSeenTerm) .userFlag("testSIUserFlag") @@ -626,7 +626,7 @@ public class MailApplication { @Bean public IntegrationFlow sendMailFlow() { - return IntegrationFlows.from("sendMailChannel") + return IntegrationFlow.from("sendMailChannel") .enrichHeaders(Mail.headers() .subjectFunction(m -> "foo") .from("foo@bar") diff --git a/src/reference/asciidoc/mongodb.adoc b/src/reference/asciidoc/mongodb.adoc index 34298cfae3..4fec5c30ea 100644 --- a/src/reference/asciidoc/mongodb.adoc +++ b/src/reference/asciidoc/mongodb.adoc @@ -364,7 +364,7 @@ The Java DSL configuration for this channel adapter may look like this: ---- @Bean IntegrationFlow changeStreamFlow(ReactiveMongoOperations mongoTemplate) { - return IntegrationFlows.from( + return IntegrationFlow.from( MongoDb.changeStreamInboundChannelAdapter(mongoTemplate) .domainType(Person.class) .collection("person") @@ -602,7 +602,7 @@ With Java DSL such a channel adapter could be configured like: ---- @Bean public IntegrationFlow reactiveMongoDbFlow(ReactiveMongoDatabaseFactory mongoDbFactory) { - return IntegrationFlows + return IntegrationFlow .from(MongoDb.reactiveInboundChannelAdapter(mongoDbFactory, "{'name' : 'Name'}") .entityClass(Person.class), c -> c.poller(Pollers.fixedDelay(1000))) diff --git a/src/reference/asciidoc/mqtt.adoc b/src/reference/asciidoc/mqtt.adoc index d0bffc87c1..140033bf7a 100644 --- a/src/reference/asciidoc/mqtt.adoc +++ b/src/reference/asciidoc/mqtt.adoc @@ -237,7 +237,7 @@ public class MqttJavaApplication { @Bean public IntegrationFlow mqttInbound() { - return IntegrationFlows.from( + return IntegrationFlow.from( new MqttPahoMessageDrivenChannelAdapter("tcp://localhost:1883", "testClient", "topic1", "topic2");) .handle(m -> System.out.println(m.getPayload())) @@ -488,7 +488,7 @@ public IntegrationFlow mqttInFlow() { messageProducer.setMessageConverter(mqttStringToBytesConverter()); messageProducer.setManualAcks(true); - return IntegrationFlows.from(messageProducer) + return IntegrationFlow.from(messageProducer) .channel(c -> c.queue("fromMqttChannel")) .get(); } diff --git a/src/reference/asciidoc/r2dbc.adoc b/src/reference/asciidoc/r2dbc.adoc index c2e6fa7aa3..b4e905bfef 100644 --- a/src/reference/asciidoc/r2dbc.adoc +++ b/src/reference/asciidoc/r2dbc.adoc @@ -59,7 +59,7 @@ With Java DSL a configuration for this channel adapter is like this: ---- @Bean IntegrationFlow r2dbcDslFlow(R2dbcEntityTemplate r2dbcEntityTemplate) { - return IntegrationFlows + return IntegrationFlow .from(R2dbc.inboundChannelAdapter(r2dbcEntityTemplate, (selectCreator) -> selectCreator.createSelect("person") diff --git a/src/reference/asciidoc/reactive-streams.adoc b/src/reference/asciidoc/reactive-streams.adoc index 89c1757a25..65feb7c974 100644 --- a/src/reference/asciidoc/reactive-streams.adoc +++ b/src/reference/asciidoc/reactive-streams.adoc @@ -122,7 +122,7 @@ See <<./splitter.adoc#split-stream-and-flux,Stream and Flux Splitting>> and <<./ === Java DSL -An `IntegrationFlow` in Java DSL can start from any `Publisher` instance (see `IntegrationFlows.from(Publisher>)`). +An `IntegrationFlow` in Java DSL can start from any `Publisher` instance (see `IntegrationFlow.from(Publisher>)`). Also, with an `IntegrationFlowBuilder.toReactivePublisher()` operator, the `IntegrationFlow` can be turned into a reactive hot source. A `FluxMessageChannel` is used internally in both cases; it can subscribe to an inbound `Publisher` according to its `ReactiveStreamsSubscribableChannel` contract and it is a `Publisher>` by itself for downstream subscribers. With a dynamic `IntegrationFlow` registration we can implement a powerful logic combining Reactive Streams with this integration flow bridging to/from `Publisher`. @@ -205,7 +205,7 @@ public class MainFlow { @Bean public IntegrationFlow buildFlow() { - return IntegrationFlows.from(customReactiveMessageProducer) + return IntegrationFlow.from(customReactiveMessageProducer) .channel(outputChannel) .get(); } @@ -221,7 +221,7 @@ Or in a declarative way: public class MainFlow { @Bean public IntegrationFlow buildFlow() { - return IntegrationFlows.from(new CustomReactiveMessageProducer(new CustomReactiveSource())) + return IntegrationFlow.from(new CustomReactiveMessageProducer(new CustomReactiveSource())) .handle(outputChannel) .get(); } @@ -243,7 +243,7 @@ public class MainFlow { .withPayload(event.getBody()) .setHeader(MyReactiveHeaders.SOURCE_NAME, event.getSourceName()) .build()); - return IntegrationFlows.from(myFlux) + return IntegrationFlow.from(myFlux) .handle(outputChannel) .get(); } @@ -317,7 +317,7 @@ public class MainFlow { @Bean public IntegrationFlow buildFlow() { - return IntegrationFlows.from(customReactiveMessageProducer) + return IntegrationFlow.from(customReactiveMessageProducer) .transform(someOperation) .handle(customReactiveMessageHandler) .get(); diff --git a/src/reference/asciidoc/router.adoc b/src/reference/asciidoc/router.adoc index 74c734356a..731bae16f5 100644 --- a/src/reference/asciidoc/router.adoc +++ b/src/reference/asciidoc/router.adoc @@ -464,7 +464,7 @@ First, you can define the router object as shown in the preceding example: ---- @Bean public IntegrationFlow routerFlow1() { - return IntegrationFlows.from("routingChannel") + return IntegrationFlow.from("routingChannel") .route(router()) .get(); } @@ -487,7 +487,7 @@ Second, you can define the routing function within the DSL flow itself, as the f ---- @Bean public IntegrationFlow routerFlow2() { - return IntegrationFlows.from("routingChannel") + return IntegrationFlow.from("routingChannel") .>route(Object::getClass, m -> m .channelMapping(String.class, "stringChannel") .channelMapping(Integer.class, "integerChannel")) @@ -555,7 +555,7 @@ First, you can define the router object as shown in the preceding example: ---- @Bean public IntegrationFlow routerFlow1() { - return IntegrationFlows.from("routingChannel") + return IntegrationFlow.from("routingChannel") .route(router()) .get(); } @@ -579,7 +579,7 @@ Second, you can define the routing function within the DSL flow itself, as the f ---- @Bean public IntegrationFlow routerFlow2() { - return IntegrationFlows.from("routingChannel") + return IntegrationFlow.from("routingChannel") .route(Message.class, m -> m.getHeaders().get("testHeader", String.class), m -> m .channelMapping("someHeaderValue", "channelA") @@ -673,7 +673,7 @@ The following example shows the equivalent router configured by using the Java D ---- @Bean public IntegrationFlow routerFlow() { - return IntegrationFlows.from("routingChannel") + return IntegrationFlow.from("routingChannel") .routeToRecipients(r -> r .applySequence(true) .ignoreSendFailures(true) @@ -861,7 +861,7 @@ The following example shows the equivalent router configured by using the Java D ---- @Bean public IntegrationFlow routerFlow() { - return IntegrationFlows.from("routingChannel") + return IntegrationFlow.from("routingChannel") .route(myCustomRouter()) .get(); } @@ -886,7 +886,7 @@ Alternately, you can route on data from the message payload, as the following ex ---- @Bean public IntegrationFlow routerFlow() { - return IntegrationFlows.from("routingChannel") + return IntegrationFlow.from("routingChannel") .route(String.class, p -> p.contains("foo") ? "fooChannel" : "barChannel") .get(); } @@ -938,7 +938,7 @@ The following example shows the equivalent router configured in the Java DSL: ---- @Bean public IntegrationFlow routerFlow() { - return IntegrationFlows.from("routingChannel") + return IntegrationFlow.from("routingChannel") .route("payload.paymentType", r -> r .channelMapping("CASH", "cashPaymentChannel") .channelMapping("CREDIT", "authorizePaymentChannel") diff --git a/src/reference/asciidoc/rsocket.adoc b/src/reference/asciidoc/rsocket.adoc index c2a5e0ab7a..e6bad33667 100644 --- a/src/reference/asciidoc/rsocket.adoc +++ b/src/reference/asciidoc/rsocket.adoc @@ -290,7 +290,7 @@ The following example shows how to configure a RSocket inbound gateway with the ---- @Bean public IntegrationFlow rsocketUpperCaseFlow() { - return IntegrationFlows + return IntegrationFlow .from(RSockets.inboundGateway("/uppercase") .interactionModels(RSocketInteractionModel.requestChannel)) ., Mono>transform((flux) -> flux.next().map(String::toUpperCase)) @@ -332,7 +332,7 @@ The following example shows how to configure a RSocket outbound gateway with the ---- @Bean public IntegrationFlow rsocketUpperCaseRequestFlow(ClientRSocketConnector clientRSocketConnector) { - return IntegrationFlows + return IntegrationFlow .from(Function.class) .handle(RSockets.outboundGateway("/uppercase") .interactionModel(RSocketInteractionModel.requestResponse) diff --git a/src/reference/asciidoc/sftp.adoc b/src/reference/asciidoc/sftp.adoc index 2c8c69bfb6..38ff8da4c1 100644 --- a/src/reference/asciidoc/sftp.adoc +++ b/src/reference/asciidoc/sftp.adoc @@ -552,7 +552,7 @@ public class SftpJavaApplication { @Bean public IntegrationFlow sftpInboundFlow() { - return IntegrationFlows + return IntegrationFlow .from(Sftp.inboundAdapter(this.sftpSessionFactory) .preserveTimestamp(true) .remoteDirectory("foo") @@ -763,7 +763,7 @@ This allows files retrieved from different directories to be downloaded to simil ---- @Bean public IntegrationFlow flow() { - return IntegrationFlows.from(Sftp.inboundAdapter(sf()) + return IntegrationFlow.from(Sftp.inboundAdapter(sf()) .filter(new SftpPersistentAcceptOnceFileListFilter(new SimpleMetadataStore(), "rotate")) .localDirectory(new File(tmpDir)) .localFilenameExpression("#remoteDirectory + T(java.io.File).separator + #root") @@ -952,7 +952,7 @@ public class SftpJavaApplication { @Bean public IntegrationFlow sftpOutboundFlow() { - return IntegrationFlows.from("toSftpChannel") + return IntegrationFlow.from("toSftpChannel") .handle(Sftp.outboundAdapter(this.sftpSessionFactory, FileExistsMode.FAIL) .useTemporaryFileName(false) .remoteDirectory("/foo") @@ -1310,7 +1310,7 @@ public class SftpJavaApplication { @Bean public IntegrationFlow sftpMGetFlow() { - return IntegrationFlows.from("sftpMgetInputChannel") + return IntegrationFlow.from("sftpMgetInputChannel") .handle(Sftp.outboundGateway(sftpSessionFactory(), AbstractRemoteFileOutboundGateway.Command.MGET, "payload") .options(AbstractRemoteFileOutboundGateway.Option.RECURSIVE) diff --git a/src/reference/asciidoc/smb.adoc b/src/reference/asciidoc/smb.adoc index 9ce3267eaa..fbeccc4f89 100644 --- a/src/reference/asciidoc/smb.adoc +++ b/src/reference/asciidoc/smb.adoc @@ -169,7 +169,7 @@ public class SmbJavaApplication { @Bean public IntegrationFlow smbInboundFlow() { - return IntegrationFlows + return IntegrationFlow .from(Smb.inboundAdapter(smbSessionFactory()) .preserveTimestamp(true) .remoteDirectory("smbSource") @@ -375,7 +375,7 @@ public class SmbJavaApplication { @Bean public IntegrationFlow smbOutboundFlow() { - return IntegrationFlows.from("toSmbChannel") + return IntegrationFlow.from("toSmbChannel") .handle(Smb.outboundAdapter(smbSessionFactory(), FileExistsMode.REPLACE) .useTemporaryFileName(false) .fileNameExpression("headers['" + FileHeaders.FILENAME + "']") diff --git a/src/reference/asciidoc/testing.adoc b/src/reference/asciidoc/testing.adoc index 66758f9e37..7e2282524a 100644 --- a/src/reference/asciidoc/testing.adoc +++ b/src/reference/asciidoc/testing.adoc @@ -288,7 +288,7 @@ public MessageSource testingMessageSource() { return MockIntegration.mockMessageSource(1, 2, 3); } ... -StandardIntegrationFlow flow = IntegrationFlows +StandardIntegrationFlow flow = IntegrationFlow .from(MockIntegration.mockMessageSource("foo", "bar", "baz")) .transform(String::toUpperCase) .channel(out) diff --git a/src/reference/asciidoc/web-sockets.adoc b/src/reference/asciidoc/web-sockets.adoc index a324db73b3..437a8a0f2f 100644 --- a/src/reference/asciidoc/web-sockets.adoc +++ b/src/reference/asciidoc/web-sockets.adoc @@ -415,7 +415,7 @@ WebSocketInboundChannelAdapter webSocketInboundChannelAdapter = QueueChannel dynamicRequestsChannel = new QueueChannel(); IntegrationFlow serverFlow = - IntegrationFlows.from(webSocketInboundChannelAdapter) + IntegrationFlow.from(webSocketInboundChannelAdapter) .channel(dynamicRequestsChannel) .get(); diff --git a/src/reference/asciidoc/webflux.adoc b/src/reference/asciidoc/webflux.adoc index 0a83d561ec..8edba5b95d 100644 --- a/src/reference/asciidoc/webflux.adoc +++ b/src/reference/asciidoc/webflux.adoc @@ -68,7 +68,7 @@ The following example shows a simple implementation of a WebFlux endpoint: ---- @Bean public IntegrationFlow inboundChannelAdapterFlow() { - return IntegrationFlows + return IntegrationFlow .from(WebFlux.inboundChannelAdapter("/reactivePost") .requestMapping(m -> m.methods(HttpMethod.POST)) .requestPayloadType(ResolvableType.forClassWithGenerics(Flux.class, String.class)) @@ -142,7 +142,7 @@ This way, we can implement https://en.wikipedia.org/wiki/Server-sent_events[Serv ---- @Bean public IntegrationFlow sseFlow() { - return IntegrationFlows + return IntegrationFlow .from(WebFlux.inboundGateway("/sse") .requestMapping(m -> m.produces(MediaType.TEXT_EVENT_STREAM_VALUE))) .handle((p, h) -> Flux.just("foo", "bar", "baz")) diff --git a/src/reference/asciidoc/whats-new.adoc b/src/reference/asciidoc/whats-new.adoc index 4e19ffbcb1..a2963d2a4d 100644 --- a/src/reference/asciidoc/whats-new.adoc +++ b/src/reference/asciidoc/whats-new.adoc @@ -47,6 +47,9 @@ The `AggregatingMessageHandler` now does not split a `Collection>` re See <<./aggregator.adoc#aggregator,Aggregator>> for more information. +The `IntegrationFlows` factory is now marked as deprecated in favor of the fluent API available in the `IntegrationFlow` interface itself. +The factory class will be removed in the future releases. + [[x6.0-http]] === HTTP Changes diff --git a/src/reference/asciidoc/ws.adoc b/src/reference/asciidoc/ws.adoc index f5c4c5c3fe..44955adce7 100644 --- a/src/reference/asciidoc/ws.adoc +++ b/src/reference/asciidoc/ws.adoc @@ -178,7 +178,7 @@ The equivalent configuration for the gateways shown in <> ---- @Bean IntegrationFlow inbound() { - return IntegrationFlows.from(Ws.simpleInboundGateway() + return IntegrationFlow.from(Ws.simpleInboundGateway() .id("simpleGateway")) ... .get(); @@ -205,7 +205,7 @@ IntegrationFlow outboundMarshalled() { ---- @Bean IntegrationFlow inboundMarshalled() { - return IntegrationFlows.from(Ws.marshallingInboundGateway() + return IntegrationFlow.from(Ws.marshallingInboundGateway() .marshaller(someMarshaller()) .unmarshaller(someUnmarshalller()) .id("marshallingGateway")) diff --git a/src/reference/asciidoc/zeromq.adoc b/src/reference/asciidoc/zeromq.adoc index 134a905f63..c9df7cf8f7 100644 --- a/src/reference/asciidoc/zeromq.adoc +++ b/src/reference/asciidoc/zeromq.adoc @@ -193,7 +193,7 @@ The Inbound Channel Adapter for ZeroMQ Java DSL is: ==== [source,java] ---- -IntegrationFlows.from( +IntegrationFlow.from( ZeroMq.inboundChannelAdapter(this.context, SocketType.SUB) .connectUrl("tcp://localhost:9000") .topics("someTopic")