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:
@@ -36,7 +36,6 @@ import org.springframework.integration.annotation.InboundChannelAdapter;
|
||||
import org.springframework.integration.annotation.IntegrationComponentScan;
|
||||
import org.springframework.integration.annotation.MessagingGateway;
|
||||
import org.springframework.integration.annotation.Poller;
|
||||
import org.springframework.integration.channel.BroadcastCapableChannel;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.FixedSubscriberChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
@@ -46,11 +45,14 @@ import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
import org.springframework.integration.dsl.IntegrationFlowDefinition;
|
||||
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.endpoint.MethodInvokingMessageSource;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.jms.ActiveMQMultiContextTests;
|
||||
import org.springframework.integration.jms.JmsDestinationPollingSource;
|
||||
import org.springframework.integration.jms.SubscribableJmsChannel;
|
||||
import org.springframework.integration.scheduling.PollerMetadata;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
@@ -302,8 +304,8 @@ public class JmsTests extends ActiveMQMultiContextTests {
|
||||
}
|
||||
|
||||
@Bean(name = PollerMetadata.DEFAULT_POLLER)
|
||||
public PollerMetadata poller() {
|
||||
return Pollers.fixedDelay(1000).get();
|
||||
public PollerSpec poller() {
|
||||
return Pollers.fixedDelay(1000);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -338,30 +340,29 @@ public class JmsTests extends ActiveMQMultiContextTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageChannel jmsOutboundInboundReplyChannel() {
|
||||
return MessageChannels.queue().get();
|
||||
public QueueChannelSpec jmsOutboundInboundReplyChannel() {
|
||||
return MessageChannels.queue();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow jmsInboundFlow() {
|
||||
public IntegrationFlow jmsInboundFlow(QueueChannel jmsOutboundInboundReplyChannel) {
|
||||
return IntegrationFlow
|
||||
.from(Jms.inboundAdapter(amqFactory).destination("jmsInbound"))
|
||||
.<String, String>transform(String::toUpperCase)
|
||||
.channel(this.jmsOutboundInboundReplyChannel())
|
||||
.channel(jmsOutboundInboundReplyChannel)
|
||||
.get();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BroadcastCapableChannel jmsPublishSubscribeChannel() {
|
||||
public JmsPublishSubscribeMessageChannelSpec jmsPublishSubscribeChannel() {
|
||||
return Jms.publishSubscribeChannel(amqFactory)
|
||||
.destination("pubsub")
|
||||
.get();
|
||||
.destination("pubsub");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public IntegrationFlow pubSubFlow() {
|
||||
public IntegrationFlow pubSubFlow(SubscribableJmsChannel jmsPublishSubscribeChannel) {
|
||||
return f -> f
|
||||
.publishSubscribeChannel(jmsPublishSubscribeChannel(),
|
||||
.publishSubscribeChannel(jmsPublishSubscribeChannel,
|
||||
pubsub -> pubsub
|
||||
.subscribe(subFlow -> subFlow
|
||||
.channel(c -> c.queue("jmsPubSubBridgeChannel")))
|
||||
@@ -408,8 +409,7 @@ public class JmsTests extends ActiveMQMultiContextTests {
|
||||
.from(Jms.messageDrivenChannelAdapter(
|
||||
Jms.container(amqFactory, "containerSpecDestination")
|
||||
.pubSubDomain(false)
|
||||
.taskExecutor(Executors.newCachedThreadPool())
|
||||
.get()))
|
||||
.taskExecutor(Executors.newCachedThreadPool())))
|
||||
.transform(String::trim)
|
||||
.channel(jmsOutboundInboundReplyChannel())
|
||||
.get();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2021 the original author or authors.
|
||||
* Copyright 2018-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.
|
||||
@@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Qualifier
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.integration.IntegrationMessageHeaderAccessor
|
||||
import org.springframework.integration.channel.QueueChannel
|
||||
import org.springframework.integration.config.EnableIntegration
|
||||
import org.springframework.integration.dsl.MessageChannels
|
||||
import org.springframework.integration.dsl.integrationFlow
|
||||
@@ -112,10 +113,10 @@ class JmsDslKotlinTests : ActiveMQMultiContextTests() {
|
||||
}
|
||||
|
||||
@Bean
|
||||
fun jmsOutboundInboundReplyChannel() = MessageChannels.queue().get()
|
||||
fun jmsOutboundInboundReplyChannel() = MessageChannels.queue()
|
||||
|
||||
@Bean
|
||||
fun jmsMessageDrivenFlowWithContainer() =
|
||||
fun jmsMessageDrivenFlowWithContainer(jmsOutboundInboundReplyChannel: QueueChannel) =
|
||||
integrationFlow(
|
||||
Jms.messageDrivenChannelAdapter(
|
||||
Jms.container(amqFactory, "containerSpecDestination")
|
||||
@@ -125,7 +126,7 @@ class JmsDslKotlinTests : ActiveMQMultiContextTests() {
|
||||
.headerMapper(jmsHeaderMapper())
|
||||
) {
|
||||
transform { it: String -> it.trim { it <= ' ' } }
|
||||
channel(jmsOutboundInboundReplyChannel())
|
||||
channel(jmsOutboundInboundReplyChannel)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user