GH-8586: Deprecate IntegrationComponentSpec.get() (#8594)
* GH-8586: Deprecate IntegrationComponentSpec.get() Fixes https://github.com/spring-projects/spring-integration/issues/8586 The `IntegrationComponentSpec` is not a plain wrapper around single component. Sometimes it comes with several components where all of them must be registered as beans. If `IntegrationComponentSpec.get()` is called from end-user code, we may lose other related components, for example filters in the `FileInboundChannelAdapterSpec`. * Deprecate `IntegrationComponentSpec.get()` with no-op for end-user, rather encourage to leave it as is and let the framework take care about its lifecycle and related components registration * Fix `IntegrationComponentSpec` logic to deal as a simple `FactoryBean` instead of extra overhead via `AbstractFactoryBean` * Use `IntegrationComponentSpec.getObject()` in the framework code where `get()` was called * Fix tests to expose `IntegrationComponentSpec` as beans instead of previously called `get()` * Some other clean up and typos fixes in the affected classes * Document the change * * Revert `ObjectStringMapBuilder` in the `KafkaInboundGatewaySpec.getComponentsToRegister()` * Fix language in docs Co-authored-by: Gary Russell <grussell@vmware.com> * * Remove trailing whitespace in the `ScriptMessageSourceSpec` --------- Co-authored-by: Gary Russell <grussell@vmware.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2022 the original author or authors.
|
||||
* Copyright 2016-2023 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.
|
||||
@@ -119,7 +119,7 @@ public class FluxMessageChannelTests {
|
||||
|
||||
@Test
|
||||
void testFluxMessageChannelCleanUp() throws InterruptedException {
|
||||
FluxMessageChannel flux = MessageChannels.flux().get();
|
||||
FluxMessageChannel flux = MessageChannels.flux().getObject();
|
||||
|
||||
CountDownLatch finishLatch = new CountDownLatch(1);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2022 the original author or authors.
|
||||
* Copyright 2019-2023 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,19 +35,19 @@ public class PollersTests {
|
||||
|
||||
@Test
|
||||
public void testDurations() {
|
||||
PeriodicTrigger trigger = (PeriodicTrigger) Pollers.fixedDelay(Duration.ofMinutes(1L)).get().getTrigger();
|
||||
PeriodicTrigger trigger = (PeriodicTrigger) Pollers.fixedDelay(Duration.ofMinutes(1L)).getObject().getTrigger();
|
||||
assertThat(trigger.getPeriodDuration()).isEqualTo(Duration.ofSeconds(60));
|
||||
assertThat(trigger.isFixedRate()).isFalse();
|
||||
trigger = (PeriodicTrigger) Pollers.fixedDelay(Duration.ofMinutes(1L), Duration.ofSeconds(10L))
|
||||
.get().getTrigger();
|
||||
.getObject().getTrigger();
|
||||
assertThat(trigger.getPeriodDuration()).isEqualTo(Duration.ofSeconds(60));
|
||||
assertThat(trigger.getInitialDelayDuration()).isEqualTo(Duration.ofSeconds(10));
|
||||
assertThat(trigger.isFixedRate()).isFalse();
|
||||
trigger = (PeriodicTrigger) Pollers.fixedRate(Duration.ofMinutes(1L)).get().getTrigger();
|
||||
trigger = (PeriodicTrigger) Pollers.fixedRate(Duration.ofMinutes(1L)).getObject().getTrigger();
|
||||
assertThat(trigger.getPeriodDuration()).isEqualTo(Duration.ofSeconds(60));
|
||||
assertThat(trigger.isFixedRate()).isTrue();
|
||||
trigger = (PeriodicTrigger) Pollers.fixedRate(Duration.ofMinutes(1L), Duration.ofSeconds(10L))
|
||||
.get().getTrigger();
|
||||
.getObject().getTrigger();
|
||||
assertThat(trigger.getPeriodDuration()).isEqualTo(Duration.ofSeconds(60));
|
||||
assertThat(trigger.getInitialDelayDuration()).isEqualTo(Duration.ofSeconds(10));
|
||||
assertThat(trigger.isFixedRate()).isTrue();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021-2022 the original author or authors.
|
||||
* Copyright 2021-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -27,6 +27,7 @@ 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.PollerSpec;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
import org.springframework.integration.dsl.context.IntegrationFlowContext;
|
||||
import org.springframework.integration.scheduling.PollerMetadata;
|
||||
@@ -142,8 +143,8 @@ public class IntegrationFlowCompositionTests {
|
||||
public static class ContextConfiguration {
|
||||
|
||||
@Bean(PollerMetadata.DEFAULT_POLLER)
|
||||
PollerMetadata defaultPoller() {
|
||||
return Pollers.fixedDelay(100).get();
|
||||
PollerSpec defaultPoller() {
|
||||
return Pollers.fixedDelay(100);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2022 the original author or authors.
|
||||
* Copyright 2016-2023 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,13 +54,16 @@ import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.FixedSubscriberChannel;
|
||||
import org.springframework.integration.channel.NullChannel;
|
||||
import org.springframework.integration.channel.PublishSubscribeChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.core.GenericTransformer;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.integration.dsl.PollerSpec;
|
||||
import org.springframework.integration.dsl.Pollers;
|
||||
import org.springframework.integration.dsl.QueueChannelSpec;
|
||||
import org.springframework.integration.dsl.Transformers;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
@@ -575,8 +578,8 @@ public class IntegrationFlowTests {
|
||||
}
|
||||
|
||||
@Bean(name = PollerMetadata.DEFAULT_POLLER)
|
||||
public PollerMetadata poller() {
|
||||
return Pollers.fixedRate(100).get();
|
||||
public PollerSpec poller() {
|
||||
return Pollers.fixedRate(100);
|
||||
}
|
||||
|
||||
@Bean(name = IntegrationContextUtils.TASK_SCHEDULER_BEAN_NAME)
|
||||
@@ -588,8 +591,8 @@ public class IntegrationFlowTests {
|
||||
|
||||
|
||||
@Bean
|
||||
public MessageChannel suppliedChannel() {
|
||||
return MessageChannels.queue(10).get();
|
||||
public QueueChannelSpec suppliedChannel() {
|
||||
return MessageChannels.queue(10);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -608,8 +611,8 @@ public class IntegrationFlowTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageChannel suppliedChannel2() {
|
||||
return MessageChannels.queue(10).get();
|
||||
public QueueChannelSpec suppliedChannel2() {
|
||||
return MessageChannels.queue(10);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -627,12 +630,12 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public MessageChannel inputChannel() {
|
||||
return MessageChannels.direct().get();
|
||||
return new DirectChannel();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageChannel foo() {
|
||||
return MessageChannels.publishSubscribe().get();
|
||||
return new PublishSubscribeChannel();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -682,7 +685,7 @@ public class IntegrationFlowTests {
|
||||
|
||||
@Bean
|
||||
public MessageChannel publishSubscribeChannel() {
|
||||
return MessageChannels.publishSubscribe().get();
|
||||
return new PublishSubscribeChannel();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -784,8 +787,8 @@ public class IntegrationFlowTests {
|
||||
private MethodInterceptor delayedAdvice;
|
||||
|
||||
@Bean
|
||||
public QueueChannel successChannel() {
|
||||
return MessageChannels.queue().get();
|
||||
public QueueChannelSpec successChannel() {
|
||||
return MessageChannels.queue();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2022 the original author or authors.
|
||||
* Copyright 2019-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,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.MessageChannels;
|
||||
import org.springframework.integration.gateway.GatewayProxyFactoryBean;
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
import org.springframework.integration.gateway.MethodArgsHolder;
|
||||
@@ -189,7 +188,7 @@ public class GatewayDslTests {
|
||||
|
||||
@Bean
|
||||
public MessageChannel gatewayError() {
|
||||
return MessageChannels.queue().get();
|
||||
return new QueueChannel();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.MessageRejectedException;
|
||||
import org.springframework.integration.annotation.Transformer;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.FixedSubscriberChannel;
|
||||
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.MessageChannels;
|
||||
import org.springframework.integration.dsl.Transformers;
|
||||
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
|
||||
import org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice;
|
||||
@@ -423,7 +423,7 @@ public class TransformerTests {
|
||||
|
||||
@Bean
|
||||
public MessageChannel enricherReplyChannel() {
|
||||
return MessageChannels.direct().get();
|
||||
return new DirectChannel();
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
* Copyright 2017-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -20,8 +20,7 @@ import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -32,6 +31,7 @@ import org.springframework.integration.annotation.GatewayHeader;
|
||||
import org.springframework.integration.annotation.MessagingGateway;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.dsl.DirectChannelSpec;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.MessageChannels;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -39,7 +39,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.handler.annotation.Payload;
|
||||
import org.springframework.messaging.support.ChannelInterceptor;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -48,7 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringJUnitConfig
|
||||
public class ContentTypeConversionTests {
|
||||
|
||||
@Autowired
|
||||
@@ -91,7 +91,7 @@ public class ContentTypeConversionTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageChannel serviceChannel(final AtomicReference<Object> sendData) {
|
||||
public DirectChannelSpec serviceChannel(AtomicReference<Object> sendData) {
|
||||
return MessageChannels.direct()
|
||||
.interceptor(new ChannelInterceptor() {
|
||||
|
||||
@@ -101,8 +101,7 @@ public class ContentTypeConversionTests {
|
||||
return message;
|
||||
}
|
||||
|
||||
})
|
||||
.get();
|
||||
});
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2020-2021 the original author or authors.
|
||||
* Copyright 2020-2023 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.
|
||||
@@ -231,7 +231,7 @@ class KotlinDslTests {
|
||||
|
||||
@Bean(PollerMetadata.DEFAULT_POLLER)
|
||||
fun defaultPoller() =
|
||||
Pollers.fixedDelay(100).maxMessagesPerPoll(1).get()
|
||||
Pollers.fixedDelay(100).maxMessagesPerPoll(1)
|
||||
|
||||
@Bean
|
||||
fun convertFlow() =
|
||||
|
||||
Reference in New Issue
Block a user