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-2020 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.
|
||||
@@ -56,7 +56,7 @@ public class TcpInboundChannelAdapterSpec
|
||||
*/
|
||||
protected TcpInboundChannelAdapterSpec(AbstractConnectionFactorySpec<?, ?> connectionFactorySpec) {
|
||||
super(new TcpReceivingChannelAdapter());
|
||||
this.connectionFactory = connectionFactorySpec.get();
|
||||
this.connectionFactory = connectionFactorySpec.getObject();
|
||||
this.target.setConnectionFactory(this.connectionFactory);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class TcpInboundChannelAdapterSpec
|
||||
public Map<Object, String> getComponentsToRegister() {
|
||||
return this.connectionFactory != null
|
||||
? Collections.singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
|
||||
: null;
|
||||
: Collections.emptyMap();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -55,7 +55,7 @@ public class TcpInboundGatewaySpec extends MessagingGatewaySpec<TcpInboundGatewa
|
||||
*/
|
||||
protected TcpInboundGatewaySpec(AbstractConnectionFactorySpec<?, ?> connectionFactorySpec) {
|
||||
super(new TcpInboundGateway());
|
||||
this.connectionFactory = connectionFactorySpec.get();
|
||||
this.connectionFactory = connectionFactorySpec.getObject();
|
||||
this.target.setConnectionFactory(this.connectionFactory);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class TcpInboundGatewaySpec extends MessagingGatewaySpec<TcpInboundGatewa
|
||||
public Map<Object, String> getComponentsToRegister() {
|
||||
return this.connectionFactory != null
|
||||
? Collections.singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
|
||||
: null;
|
||||
: Collections.emptyMap();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -56,7 +56,7 @@ public class TcpOutboundChannelAdapterSpec
|
||||
*/
|
||||
protected TcpOutboundChannelAdapterSpec(AbstractConnectionFactorySpec<?, ?> connectionFactorySpec) {
|
||||
this.target = new TcpSendingMessageHandler();
|
||||
this.connectionFactory = connectionFactorySpec.get();
|
||||
this.connectionFactory = connectionFactorySpec.getObject();
|
||||
this.target.setConnectionFactory(this.connectionFactory);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class TcpOutboundChannelAdapterSpec
|
||||
public Map<Object, String> getComponentsToRegister() {
|
||||
return this.connectionFactory != null
|
||||
? Collections.singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
|
||||
: null;
|
||||
: Collections.emptyMap();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public class TcpOutboundGatewaySpec extends MessageHandlerSpec<TcpOutboundGatewa
|
||||
*/
|
||||
public TcpOutboundGatewaySpec(TcpClientConnectionFactorySpec<?, ?> connectionFactorySpec) {
|
||||
this.target = new TcpOutboundGateway();
|
||||
this.connectionFactory = connectionFactorySpec.get();
|
||||
this.connectionFactory = connectionFactorySpec.getObject();
|
||||
this.target.setConnectionFactory(this.connectionFactory);
|
||||
}
|
||||
|
||||
@@ -120,8 +120,21 @@ public class TcpOutboundGatewaySpec extends MessageHandlerSpec<TcpOutboundGatewa
|
||||
* @param channelName the name.
|
||||
* @return the spec.
|
||||
* @since 5.4
|
||||
* @deprecated in favor of {@link #unsolicitedMessageChannelName(String)}
|
||||
* due to the typo in method name.
|
||||
*/
|
||||
@Deprecated(since = "6.1", forRemoval = true)
|
||||
public TcpOutboundGatewaySpec unsolictedMessageChannelName(String channelName) {
|
||||
return unsolicitedMessageChannelName(channelName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the unsolicited message channel name.
|
||||
* @param channelName the name.
|
||||
* @return the spec.
|
||||
* @since 6.1
|
||||
*/
|
||||
public TcpOutboundGatewaySpec unsolicitedMessageChannelName(String channelName) {
|
||||
this.target.setUnsolicitedMessageChannelName(channelName);
|
||||
return this;
|
||||
}
|
||||
@@ -131,8 +144,21 @@ public class TcpOutboundGatewaySpec extends MessageHandlerSpec<TcpOutboundGatewa
|
||||
* @param channel the channel.
|
||||
* @return the spec.
|
||||
* @since 5.4
|
||||
* @deprecated in favor of {@link #unsolicitedMessageChannel(MessageChannel)}
|
||||
* due to the typo in method name.
|
||||
*/
|
||||
@Deprecated(since = "6.1", forRemoval = true)
|
||||
public TcpOutboundGatewaySpec unsolictedMessageChannelName(MessageChannel channel) {
|
||||
return unsolicitedMessageChannel(channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the unsolicited message channel.
|
||||
* @param channel the channel.
|
||||
* @return the spec.
|
||||
* @since 6.1
|
||||
*/
|
||||
public TcpOutboundGatewaySpec unsolicitedMessageChannel(MessageChannel channel) {
|
||||
this.target.setUnsolicitedMessageChannel(channel);
|
||||
return this;
|
||||
}
|
||||
@@ -141,7 +167,7 @@ public class TcpOutboundGatewaySpec extends MessageHandlerSpec<TcpOutboundGatewa
|
||||
public Map<Object, String> getComponentsToRegister() {
|
||||
return this.connectionFactory != null
|
||||
? Collections.singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
|
||||
: null;
|
||||
: Collections.emptyMap();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user