INT-4252 IntegrationFlow: Allow Custom Bean Names

JIRA: https://jira.spring.io/browse/INT-4252

To allow to provide arbitrary bean names for the intermediate components
in the `IntegrationFlow` change `ComponentsRegistration` to return
a `Map<Object, String>` instead of raw `Collection<Object>`

* Use the value from that map in the `IntegrationFlowBeanPostProcessor` as a
fallback option before walking into bean name generation
* Provide `containerId` option for the AMQP DSL components

* Revert `@AfterClass` in the `AmqpTests`
* Expose `id()` for the `JmsDestinationAccessorSpec`
* Register `ListenerContainer` and `JmsTemplate`
as bean via `ComponentRegistration` in the particular JMS Java DSL components
* Fix `Jms` factory to populate the `JmsDefaultListenerContainerSpec`
for the `messageDrivenChannelAdapter()` without class specified

* Refactor AMQP DSL Inbound components to deal with the new ContainerSpec API
* Remove `containerId()` in favor of `id()` in the ContainerSpec
This commit is contained in:
Artem Bilan
2017-05-16 17:33:02 -04:00
committed by Gary Russell
parent 2b99c191f6
commit ea89682368
50 changed files with 396 additions and 267 deletions

View File

@@ -24,18 +24,20 @@ import org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer;
* Spec for an inbound channel adapter with a {@link DirectMessageListenerContainer}.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*
*/
public class AmqpInboundChannelAdapterDMLCSpec extends AmqpInboundChannelAdapterSpec<AmqpInboundChannelAdapterDMLCSpec,
DirectMessageListenerContainer> {
public class AmqpInboundChannelAdapterDMLCSpec
extends AmqpInboundChannelAdapterSpec<AmqpInboundChannelAdapterDMLCSpec, DirectMessageListenerContainer> {
AmqpInboundChannelAdapterDMLCSpec(DirectMessageListenerContainer listenerContainer) {
super(listenerContainer);
super(new DirectMessageListenerContainerSpec(listenerContainer));
}
AmqpInboundChannelAdapterDMLCSpec configureContainer(Consumer<DirectMessageListenerContainerSpec> configurer) {
configurer.accept(new DirectMessageListenerContainerSpec(this.listenerContainer));
configurer.accept((DirectMessageListenerContainerSpec) this.listenerContainerSpec);
return this;
}

View File

@@ -24,18 +24,20 @@ import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
* Spec for an inbound channel adapter with a {@link SimpleMessageListenerContainer}.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*
*/
public class AmqpInboundChannelAdapterSMLCSpec extends AmqpInboundChannelAdapterSpec<AmqpInboundChannelAdapterSMLCSpec,
SimpleMessageListenerContainer> {
public class AmqpInboundChannelAdapterSMLCSpec
extends AmqpInboundChannelAdapterSpec<AmqpInboundChannelAdapterSMLCSpec, SimpleMessageListenerContainer> {
AmqpInboundChannelAdapterSMLCSpec(SimpleMessageListenerContainer listenerContainer) {
super(listenerContainer);
super(new SimpleMessageListenerContainerSpec(listenerContainer));
}
AmqpInboundChannelAdapterSMLCSpec configureContainer(Consumer<SimpleMessageListenerContainerSpec> configurer) {
configurer.accept(new SimpleMessageListenerContainerSpec(this.listenerContainer));
configurer.accept((SimpleMessageListenerContainerSpec) this.listenerContainerSpec);
return this;
}

View File

@@ -16,8 +16,8 @@
package org.springframework.integration.amqp.dsl;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer;
import org.springframework.integration.amqp.inbound.AmqpInboundChannelAdapter;
@@ -31,6 +31,7 @@ import org.springframework.integration.dsl.MessageProducerSpec;
* @param <C> the container type.
*
* @author Artem Bilan
*
* @since 5.0
*/
public abstract class AmqpInboundChannelAdapterSpec
@@ -38,16 +39,16 @@ public abstract class AmqpInboundChannelAdapterSpec
extends AmqpBaseInboundChannelAdapterSpec<S>
implements ComponentsRegistration {
protected final C listenerContainer;
protected final AbstractMessageListenerContainerSpec<?, C> listenerContainerSpec;
AmqpInboundChannelAdapterSpec(C listenerContainer) {
super(new AmqpInboundChannelAdapter(listenerContainer));
this.listenerContainer = listenerContainer;
AmqpInboundChannelAdapterSpec(AbstractMessageListenerContainerSpec<?, C> listenerContainerSpec) {
super(new AmqpInboundChannelAdapter(listenerContainerSpec.get()));
this.listenerContainerSpec = listenerContainerSpec;
}
@Override
public Collection<Object> getComponentsToRegister() {
return Collections.<Object>singleton(this.listenerContainer);
public Map<Object, String> getComponentsToRegister() {
return Collections.singletonMap(this.listenerContainerSpec.get(), this.listenerContainerSpec.getId());
}
}

View File

@@ -25,6 +25,8 @@ import org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer;
* Spec for a gateway with a {@link DirectMessageListenerContainer}.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*
*/
@@ -32,15 +34,15 @@ public class AmqpInboundGatewayDMLCSpec
extends AmqpInboundGatewaySpec<AmqpInboundGatewayDMLCSpec, DirectMessageListenerContainer> {
AmqpInboundGatewayDMLCSpec(DirectMessageListenerContainer listenerContainer, AmqpTemplate amqpTemplate) {
super(listenerContainer, amqpTemplate);
super(new DirectMessageListenerContainerSpec(listenerContainer), amqpTemplate);
}
AmqpInboundGatewayDMLCSpec(DirectMessageListenerContainer listenerContainer) {
super(listenerContainer);
super(new DirectMessageListenerContainerSpec(listenerContainer));
}
public AmqpInboundGatewayDMLCSpec configureContainer(Consumer<DirectMessageListenerContainerSpec> configurer) {
configurer.accept(new DirectMessageListenerContainerSpec(this.listenerContainer));
configurer.accept((DirectMessageListenerContainerSpec) this.listenerContainerSpec);
return this;
}

View File

@@ -25,6 +25,8 @@ import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
* Spec for a gateway with a {@link SimpleMessageListenerContainer}.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*
*/
@@ -32,15 +34,15 @@ public class AmqpInboundGatewaySMLCSpec
extends AmqpInboundGatewaySpec<AmqpInboundGatewaySMLCSpec, SimpleMessageListenerContainer> {
AmqpInboundGatewaySMLCSpec(SimpleMessageListenerContainer listenerContainer, AmqpTemplate amqpTemplate) {
super(listenerContainer, amqpTemplate);
super(new SimpleMessageListenerContainerSpec(listenerContainer), amqpTemplate);
}
AmqpInboundGatewaySMLCSpec(SimpleMessageListenerContainer listenerContainer) {
super(listenerContainer);
super(new SimpleMessageListenerContainerSpec(listenerContainer));
}
public AmqpInboundGatewaySMLCSpec configureContainer(Consumer<SimpleMessageListenerContainerSpec> configurer) {
configurer.accept(new SimpleMessageListenerContainerSpec(this.listenerContainer));
configurer.accept((SimpleMessageListenerContainerSpec) this.listenerContainerSpec);
return this;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2015 the original author or authors.
* Copyright 2014-2017 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,12 +16,11 @@
package org.springframework.integration.amqp.dsl;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.integration.amqp.inbound.AmqpInboundGateway;
import org.springframework.integration.dsl.ComponentsRegistration;
@@ -29,34 +28,41 @@ import org.springframework.integration.dsl.ComponentsRegistration;
* An {@link AmqpBaseInboundGatewaySpec} implementation for a {@link AmqpInboundGateway}.
* Allows to provide {@link AbstractMessageListenerContainer} options.
*
* @param <S> the spec type.
* @param <C> the container type.
*
* @author Artem Bilan
*
* @since 5.0
*/
public abstract class AmqpInboundGatewaySpec
<S extends AmqpInboundGatewaySpec<S, C>, C extends AbstractMessageListenerContainer>
extends AmqpBaseInboundGatewaySpec<S> implements ComponentsRegistration {
extends AmqpBaseInboundGatewaySpec<S>
implements ComponentsRegistration {
protected final C listenerContainer;
protected final AbstractMessageListenerContainerSpec<?, C> listenerContainerSpec;
AmqpInboundGatewaySpec(C listenerContainer) {
super(new AmqpInboundGateway(listenerContainer));
this.listenerContainer = listenerContainer;
AmqpInboundGatewaySpec(AbstractMessageListenerContainerSpec<?, C> listenerContainerSpec) {
super(new AmqpInboundGateway(listenerContainerSpec.get()));
this.listenerContainerSpec = listenerContainerSpec;
}
/**
* Instantiate {@link AmqpInboundGateway} based on the provided {@link AbstractMessageListenerContainer}
* and {@link AmqpTemplate}.
* @param listenerContainer the {@link SimpleMessageListenerContainer} to use.
* @param listenerContainerSpec the {@link AbstractMessageListenerContainerSpec} to use.
* @param amqpTemplate the {@link AmqpTemplate} to use.
*/
AmqpInboundGatewaySpec(C listenerContainer, AmqpTemplate amqpTemplate) {
super(new AmqpInboundGateway(listenerContainer, amqpTemplate));
this.listenerContainer = listenerContainer;
AmqpInboundGatewaySpec(
AbstractMessageListenerContainerSpec<?, C> listenerContainerSpec,
AmqpTemplate amqpTemplate) {
super(new AmqpInboundGateway(listenerContainerSpec.get(), amqpTemplate));
this.listenerContainerSpec = listenerContainerSpec;
}
@Override
public Collection<Object> getComponentsToRegister() {
return Collections.<Object>singleton(this.listenerContainer);
public Map<Object, String> getComponentsToRegister() {
return Collections.singletonMap(this.listenerContainerSpec.get(), this.listenerContainerSpec.getId());
}
}

View File

@@ -37,6 +37,7 @@ import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.junit.BrokerRunning;
import org.springframework.amqp.rabbit.listener.DirectMessageListenerContainer;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
@@ -61,6 +62,7 @@ import org.springframework.test.context.junit4.SpringRunner;
/**
* @author Artem Bilan
* @author Gary Russell
*
* @since 5.0
*/
@RunWith(SpringRunner.class)
@@ -68,7 +70,9 @@ import org.springframework.test.context.junit4.SpringRunner;
public class AmqpTests {
@ClassRule
public static BrokerRunning brokerRunning = BrokerRunning.isRunning();
public static BrokerRunning brokerRunning =
BrokerRunning.isRunningWithEmptyQueues("amqpOutboundInput", "amqpReplyChannel", "asyncReplies",
"defaultReplyTo", "si.dsl.test", "testTemplateChannelTransacted");
@Autowired
private ConnectionFactory rabbitConnectionFactory;
@@ -83,10 +87,13 @@ public class AmqpTests {
@Autowired
private AmqpInboundGateway amqpInboundGateway;
@Autowired(required = false)
@Qualifier("amqpInboundGatewayContainer")
private SimpleMessageListenerContainer amqpInboundGatewayContainer;
@AfterClass
public static void tearDown() {
brokerRunning.removeTestQueues("amqpOutboundInput", "amqpReplyChannel", "asyncReplies", "defaultReplyTo",
"si.dsl.test", "testTemplateChannelTransacted");
brokerRunning.removeTestQueues();
}
@Test
@@ -103,6 +110,8 @@ public class AmqpTests {
result = this.amqpTemplate.receiveAndConvert("defaultReplyTo");
assertEquals("HELLO WORLD", result);
assertSame(this.amqpTemplate, TestUtils.getPropertyValue(this.amqpInboundGateway, "amqpTemplate"));
assertNotNull(this.amqpInboundGatewayContainer);
}
@Autowired
@@ -213,6 +222,7 @@ public class AmqpTests {
.from(Amqp.inboundGateway(rabbitConnectionFactory, amqpTemplate, queue())
.id("amqpInboundGateway")
.configureContainer(c -> c
.id("amqpInboundGatewayContainer")
.recoveryInterval(5000)
.concurrentConsumers(1))
.defaultReplyTo(defaultReplyTo().getName()))

View File

@@ -16,10 +16,10 @@
package org.springframework.integration.config.dsl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import org.springframework.beans.BeansException;
@@ -130,45 +130,44 @@ public class IntegrationFlowBeanPostProcessor implements BeanPostProcessor, Bean
}
}
private Object processStandardIntegrationFlow(StandardIntegrationFlow flow, String beanName) {
String flowNamePrefix = beanName + ".";
private Object processStandardIntegrationFlow(StandardIntegrationFlow flow, String flowBeanName) {
String flowNamePrefix = flowBeanName + ".";
int subFlowNameIndex = 0;
int channelNameIndex = 0;
boolean registerSingleton = flow.isRegisterComponents();
List<Object> integrationComponents = new ArrayList<>(flow.getIntegrationComponents());
for (int i = 0; i < integrationComponents.size(); i++) {
Object component = integrationComponents.get(i);
Map<Object, String> integrationComponents = flow.getIntegrationComponents();
Map<Object, String> targetIntegrationComponents = new LinkedHashMap<>(integrationComponents.size());
for (Map.Entry<Object, String> entry : integrationComponents.entrySet()) {
Object component = entry.getKey();
if (component instanceof ConsumerEndpointSpec) {
ConsumerEndpointSpec<?, ?> endpointSpec = (ConsumerEndpointSpec<?, ?>) component;
MessageHandler messageHandler = endpointSpec.get().getT2();
ConsumerEndpointFactoryBean endpoint = endpointSpec.get().getT1();
String id = endpointSpec.getId();
Collection<?> messageHandlers = this.beanFactory.getBeansOfType(messageHandler.getClass(), false,
false).values();
if (id == null) {
id = generateBeanName(endpoint, entry.getValue());
}
Collection<?> messageHandlers =
this.beanFactory.getBeansOfType(messageHandler.getClass(), false, false)
.values();
if (!messageHandlers.contains(messageHandler)) {
String handlerBeanName = generateBeanName(messageHandler);
String[] handlerAlias = id != null
? new String[] { id + IntegrationConfigUtils.HANDLER_ALIAS_SUFFIX }
: null;
String[] handlerAlias = new String[] { id + IntegrationConfigUtils.HANDLER_ALIAS_SUFFIX };
registerComponent(messageHandler, handlerBeanName, beanName, registerSingleton);
if (handlerAlias != null) {
for (String alias : handlerAlias) {
this.beanFactory.registerAlias(handlerBeanName, alias);
}
registerComponent(messageHandler, handlerBeanName, flowBeanName, registerSingleton);
for (String alias : handlerAlias) {
this.beanFactory.registerAlias(handlerBeanName, alias);
}
}
String endpointBeanName = id;
if (endpointBeanName == null) {
endpointBeanName = generateBeanName(endpoint);
}
registerComponent(endpoint, endpointBeanName, beanName, registerSingleton);
integrationComponents.set(i, endpoint);
registerComponent(endpoint, id, flowBeanName, registerSingleton);
targetIntegrationComponents.put(endpoint, id);
}
else {
Collection<?> values = this.beanFactory.getBeansOfType(component.getClass(), false, false).values();
@@ -176,17 +175,21 @@ public class IntegrationFlowBeanPostProcessor implements BeanPostProcessor, Bean
if (component instanceof AbstractMessageChannel) {
String channelBeanName = ((AbstractMessageChannel) component).getComponentName();
if (channelBeanName == null) {
channelBeanName = flowNamePrefix + "channel" +
BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + channelNameIndex++;
channelBeanName = entry.getValue();
if (channelBeanName == null) {
channelBeanName = flowNamePrefix + "channel" +
BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + channelNameIndex++;
}
}
registerComponent(component, channelBeanName, beanName, registerSingleton);
registerComponent(component, channelBeanName, flowBeanName, registerSingleton);
targetIntegrationComponents.put(component, channelBeanName);
}
else if (component instanceof MessageChannelReference) {
String channelBeanName = ((MessageChannelReference) component).getName();
if (!this.beanFactory.containsBean(channelBeanName)) {
DirectChannel directChannel = new DirectChannel();
registerComponent(directChannel, channelBeanName, beanName, registerSingleton);
integrationComponents.set(i, directChannel);
registerComponent(directChannel, channelBeanName, flowBeanName, registerSingleton);
targetIntegrationComponents.put(directChannel, channelBeanName);
}
}
else if (component instanceof FixedSubscriberChannel) {
@@ -196,26 +199,29 @@ public class IntegrationFlowBeanPostProcessor implements BeanPostProcessor, Bean
channelBeanName = flowNamePrefix + "channel" +
BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + channelNameIndex++;
}
registerComponent(component, channelBeanName, beanName, registerSingleton);
registerComponent(component, channelBeanName, flowBeanName, registerSingleton);
targetIntegrationComponents.put(component, channelBeanName);
}
else if (component instanceof SourcePollingChannelAdapterSpec) {
SourcePollingChannelAdapterSpec spec = (SourcePollingChannelAdapterSpec) component;
Collection<Object> componentsToRegister = spec.getComponentsToRegister();
Map<Object, String> componentsToRegister = spec.getComponentsToRegister();
if (!CollectionUtils.isEmpty(componentsToRegister)) {
componentsToRegister.stream()
.filter(o -> !this.beanFactory.getBeansOfType(o.getClass(), false, false)
.values()
.contains(o))
.forEach(o -> registerComponent(o, generateBeanName(o))
);
componentsToRegister.entrySet()
.stream()
.filter(o ->
!this.beanFactory.getBeansOfType(o.getKey().getClass(), false, false)
.values()
.contains(o.getKey()))
.forEach(o ->
registerComponent(o.getKey(), generateBeanName(o.getKey(), o.getValue())));
}
SourcePollingChannelAdapterFactoryBean pollingChannelAdapterFactoryBean = spec.get().getT1();
String id = spec.getId();
if (!StringUtils.hasText(id)) {
id = generateBeanName(pollingChannelAdapterFactoryBean);
id = generateBeanName(pollingChannelAdapterFactoryBean, entry.getValue());
}
registerComponent(pollingChannelAdapterFactoryBean, id, beanName, registerSingleton);
integrationComponents.set(i, pollingChannelAdapterFactoryBean);
registerComponent(pollingChannelAdapterFactoryBean, id, flowBeanName, registerSingleton);
targetIntegrationComponents.put(pollingChannelAdapterFactoryBean, id);
MessageSource<?> messageSource = spec.get().getT2();
if (!this.beanFactory.getBeansOfType(messageSource.getClass(), false, false)
@@ -226,25 +232,37 @@ public class IntegrationFlowBeanPostProcessor implements BeanPostProcessor, Bean
&& ((NamedComponent) messageSource).getComponentName() != null) {
messageSourceId = ((NamedComponent) messageSource).getComponentName();
}
registerComponent(messageSource, messageSourceId, beanName, registerSingleton);
registerComponent(messageSource, messageSourceId, flowBeanName, registerSingleton);
}
}
else if (component instanceof StandardIntegrationFlow) {
String subFlowBeanName = flowNamePrefix + "subFlow" +
BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + subFlowNameIndex++;
registerComponent(component, subFlowBeanName, beanName, registerSingleton);
String subFlowBeanName =
entry.getValue() != null
? entry.getValue()
: flowNamePrefix + "subFlow" +
BeanFactoryUtils.GENERATED_BEAN_NAME_SEPARATOR + subFlowNameIndex++;
registerComponent(component, subFlowBeanName, flowBeanName, registerSingleton);
targetIntegrationComponents.put(component, subFlowBeanName);
}
else if (component instanceof AnnotationGatewayProxyFactoryBean) {
registerComponent(component, flowNamePrefix + "gateway", beanName, registerSingleton);
String gatewayId = entry.getValue() != null
? entry.getValue()
: flowNamePrefix + "gateway";
registerComponent(component, gatewayId, flowBeanName, registerSingleton);
targetIntegrationComponents.put(component, gatewayId);
}
else {
String generateBeanName = generateBeanName(component);
registerComponent(component, generateBeanName, beanName, registerSingleton);
String generateBeanName = generateBeanName(component, entry.getValue());
registerComponent(component, generateBeanName, flowBeanName, registerSingleton);
}
}
else {
targetIntegrationComponents.put(entry.getKey(), entry.getValue());
}
}
}
flow.setIntegrationComponents(integrationComponents);
flow.setIntegrationComponents(targetIntegrationComponents);
return flow;
}
@@ -256,15 +274,21 @@ public class IntegrationFlowBeanPostProcessor implements BeanPostProcessor, Bean
}
private void processIntegrationComponentSpec(IntegrationComponentSpec<?, ?> bean) {
registerComponent(bean.get(), generateBeanName(bean.get()), null, false);
registerComponent(bean.get(), generateBeanName(bean.get(), bean.getId()), null, false);
if (bean instanceof ComponentsRegistration) {
Collection<Object> componentsToRegister = ((ComponentsRegistration) bean).getComponentsToRegister();
Map<Object, String> componentsToRegister = ((ComponentsRegistration) bean).getComponentsToRegister();
if (!CollectionUtils.isEmpty(componentsToRegister)) {
componentsToRegister.stream()
.filter(component -> !this.beanFactory.getBeansOfType(component.getClass(), false, false)
.values()
.contains(component))
.forEach(component -> registerComponent(component, generateBeanName(component)));
componentsToRegister.entrySet()
.stream()
.filter(component ->
!this.beanFactory.getBeansOfType(component.getKey().getClass(), false, false)
.values()
.contains(component.getKey()))
.forEach(component ->
registerComponent(component.getKey(),
generateBeanName(component.getKey(), component.getValue())));
}
}
}
@@ -293,9 +317,17 @@ public class IntegrationFlowBeanPostProcessor implements BeanPostProcessor, Bean
}
private String generateBeanName(Object instance) {
return generateBeanName(instance, null);
}
private String generateBeanName(Object instance, String fallbackId) {
if (instance instanceof NamedComponent && ((NamedComponent) instance).getComponentName() != null) {
return ((NamedComponent) instance).getComponentName();
}
else if (fallbackId != null) {
return fallbackId;
}
String generatedBeanName = instance.getClass().getName();
String id = generatedBeanName;
int counter = -1;

View File

@@ -96,7 +96,7 @@ public class AbstractRouterSpec<S extends AbstractRouterSpec<S, R>, R extends Ab
IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(channel);
subFlow.configure(flowBuilder);
this.componentsToRegister.add(flowBuilder);
this.componentsToRegister.put(flowBuilder, null);
return defaultOutputChannel(channel);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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,7 +16,7 @@
package org.springframework.integration.dsl;
import java.util.Collection;
import java.util.Map;
/**
* The marker interface for the {@link IntegrationComponentSpec} implementation,
@@ -33,6 +33,6 @@ import java.util.Collection;
@FunctionalInterface
public interface ComponentsRegistration {
Collection<Object> getComponentsToRegister();
Map<Object, String> getComponentsToRegister();
}

View File

@@ -149,7 +149,7 @@ public abstract class ConsumerEndpointSpec<S extends ConsumerEndpointSpec<S, H>,
*/
public S transactional(boolean handleMessageAdvice) {
TransactionInterceptor transactionInterceptor = new TransactionInterceptorBuilder(handleMessageAdvice).build();
this.componentsToRegister.add(transactionInterceptor);
this.componentsToRegister.put(transactionInterceptor, null);
return transactional(transactionInterceptor);
}

View File

@@ -16,8 +16,8 @@
package org.springframework.integration.dsl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
import org.springframework.beans.factory.BeanNameAware;
@@ -46,7 +46,7 @@ public abstract class EndpointSpec<S extends EndpointSpec<S, F, H>, F extends Be
extends IntegrationComponentSpec<S, Tuple2<F, H>>
implements ComponentsRegistration {
protected final Collection<Object> componentsToRegister = new ArrayList<>();
protected final Map<Object, String> componentsToRegister = new LinkedHashMap<>();
protected H handler;
@@ -87,9 +87,9 @@ public abstract class EndpointSpec<S extends EndpointSpec<S, F, H>, F extends Be
* @see PollerSpec
*/
public S poller(PollerSpec pollerMetadataSpec) {
Collection<Object> componentsToRegister = pollerMetadataSpec.getComponentsToRegister();
Map<Object, String> componentsToRegister = pollerMetadataSpec.getComponentsToRegister();
if (componentsToRegister != null) {
this.componentsToRegister.addAll(componentsToRegister);
this.componentsToRegister.putAll(componentsToRegister);
}
return poller(pollerMetadataSpec.get());
}
@@ -116,7 +116,7 @@ public abstract class EndpointSpec<S extends EndpointSpec<S, F, H>, F extends Be
public abstract S autoStartup(boolean autoStartup);
@Override
public Collection<Object> getComponentsToRegister() {
public Map<Object, String> getComponentsToRegister() {
return this.componentsToRegister.isEmpty()
? null
: this.componentsToRegister;

View File

@@ -150,7 +150,7 @@ public class EnricherSpec extends ConsumerEndpointSpec<EnricherSpec, ContentEnri
IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(requestChannel);
subFlow.configure(flowBuilder);
this.componentsToRegister.add(flowBuilder.get());
this.componentsToRegister.put(flowBuilder.get(), null);
return requestChannel(requestChannel);
}

View File

@@ -91,7 +91,7 @@ public final class FilterEndpointSpec extends ConsumerEndpointSpec<FilterEndpoin
DirectChannel channel = new DirectChannel();
IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(channel);
discardFlow.configure(flowBuilder);
this.componentsToRegister.add(flowBuilder.get());
this.componentsToRegister.put(flowBuilder.get(), null);
return discardChannel(channel);
}

View File

@@ -437,7 +437,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
headerEnricher.setShouldSkipNulls(this.shouldSkipNulls);
headerEnricher.setMessageProcessor(this.messageProcessor);
this.componentsToRegister.add(headerEnricher);
this.componentsToRegister.put(headerEnricher, null);
this.handler = new MessageTransformingHandler(headerEnricher);
return super.doGet();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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,7 @@ public abstract class IntegrationFlowAdapter implements IntegrationFlow, SmartLi
IntegrationFlowDefinition<?> targetFlow = buildFlow();
Assert.state(targetFlow != null, "the 'buildFlow()' must not return null");
flow.integrationComponents.clear();
flow.integrationComponents.addAll(targetFlow.integrationComponents);
flow.integrationComponents.putAll(targetFlow.integrationComponents);
this.targetIntegrationFlow = flow.get();
}

View File

@@ -16,9 +16,8 @@
package org.springframework.integration.dsl;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
@@ -120,7 +119,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
private static final Set<MessageProducer> REFERENCED_REPLY_PRODUCERS = new HashSet<>();
protected final Set<Object> integrationComponents = new LinkedHashSet<>();
protected final Map<Object, String> integrationComponents = new LinkedHashMap<>();
protected MessageChannel currentMessageChannel;
@@ -134,13 +133,13 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
}
B addComponent(Object component) {
this.integrationComponents.add(component);
this.integrationComponents.put(component, null);
return _this();
}
B addComponents(Collection<Object> components) {
B addComponents(Map<Object, String> components) {
if (components != null) {
this.integrationComponents.addAll(components);
this.integrationComponents.putAll(components);
}
return _this();
}
@@ -1974,9 +1973,10 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
BridgeHandler bridgeHandler = new BridgeHandler();
boolean registerSubflowBridge = false;
Collection<Object> componentsToRegister = routerSpec.getComponentsToRegister();
Map<Object, String> componentsToRegister = routerSpec.getComponentsToRegister();
if (!CollectionUtils.isEmpty(componentsToRegister)) {
for (Object component : componentsToRegister) {
for (Map.Entry<Object, String> entry : componentsToRegister.entrySet()) {
Object component = entry.getKey();
if (component instanceof IntegrationFlowDefinition) {
IntegrationFlowDefinition<?> flowBuilder = (IntegrationFlowDefinition<?>) component;
if (flowBuilder.isOutputChannelRequired()) {
@@ -1986,7 +1986,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
addComponent(flowBuilder.get());
}
else {
addComponent(component);
this.integrationComponents.put(component, entry.getValue());
}
}
}
@@ -2621,7 +2621,7 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
private B registerOutputChannelIfCan(MessageChannel outputChannel) {
if (!(outputChannel instanceof FixedSubscriberChannelPrototype)) {
this.integrationComponents.add(outputChannel);
this.integrationComponents.put(outputChannel, null);
if (this.currentComponent != null) {
String channelName = null;
if (outputChannel instanceof MessageChannelReference) {
@@ -2718,7 +2718,10 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
}
if (this.implicitChannel) {
Optional<Object> lastComponent = this.integrationComponents.stream().reduce((first, second) -> second);
Optional<Object> lastComponent =
this.integrationComponents.keySet()
.stream()
.reduce((first, second) -> second);
if (lastComponent.get() instanceof WireTapSpec) {
channel(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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,11 +16,11 @@
package org.springframework.integration.dsl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import org.aopalliance.aop.Advice;
@@ -49,7 +49,7 @@ public final class PollerSpec extends IntegrationComponentSpec<PollerSpec, Polle
private final List<Advice> adviceChain = new LinkedList<>();
private final Collection<Object> componentsToRegister = new ArrayList<>();
private final Map<Object, String> componentsToRegister = new LinkedHashMap<>();
PollerSpec(Trigger trigger) {
this.target = new PollerMetadata();
@@ -92,7 +92,7 @@ public final class PollerSpec extends IntegrationComponentSpec<PollerSpec, Polle
public PollerSpec errorChannel(MessageChannel errorChannel) {
MessagePublishingErrorHandler errorHandler = new MessagePublishingErrorHandler();
errorHandler.setDefaultErrorChannel(errorChannel);
this.componentsToRegister.add(errorHandler);
this.componentsToRegister.put(errorHandler, null);
return errorHandler(errorHandler);
}
@@ -106,7 +106,7 @@ public final class PollerSpec extends IntegrationComponentSpec<PollerSpec, Polle
public PollerSpec errorChannel(String errorChannelName) {
MessagePublishingErrorHandler errorHandler = new MessagePublishingErrorHandler();
errorHandler.setDefaultErrorChannelName(errorChannelName);
this.componentsToRegister.add(errorHandler);
this.componentsToRegister.put(errorHandler, null);
return errorHandler(errorHandler);
}
@@ -163,7 +163,7 @@ public final class PollerSpec extends IntegrationComponentSpec<PollerSpec, Polle
*/
public PollerSpec transactional() {
TransactionInterceptor transactionInterceptor = new TransactionInterceptorBuilder().build();
this.componentsToRegister.add(transactionInterceptor);
this.componentsToRegister.put(transactionInterceptor, null);
return transactional(transactionInterceptor);
}
@@ -193,7 +193,7 @@ public final class PollerSpec extends IntegrationComponentSpec<PollerSpec, Polle
}
@Override
public Collection<Object> getComponentsToRegister() {
public Map<Object, String> getComponentsToRegister() {
return this.componentsToRegister;
}

View File

@@ -16,9 +16,8 @@
package org.springframework.integration.dsl;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.Executor;
import org.springframework.integration.dsl.channel.PublishSubscribeChannelSpec;
@@ -30,7 +29,7 @@ import org.springframework.integration.dsl.channel.PublishSubscribeChannelSpec;
*/
public class PublishSubscribeSpec extends PublishSubscribeChannelSpec<PublishSubscribeSpec> {
private final List<Object> subscriberFlows = new ArrayList<>();
private final Map<Object, String> subscriberFlows = new LinkedHashMap<>();
PublishSubscribeSpec() {
super();
@@ -50,15 +49,15 @@ public class PublishSubscribeSpec extends PublishSubscribeChannelSpec<PublishSub
IntegrationFlows.from(this.channel)
.bridge();
flow.configure(flowBuilder);
this.subscriberFlows.add(flowBuilder.get());
this.subscriberFlows.put(flowBuilder.get(), null);
return _this();
}
@Override
public Collection<Object> getComponentsToRegister() {
List<Object> objects = new ArrayList<Object>();
objects.addAll(super.getComponentsToRegister());
objects.addAll(this.subscriberFlows);
public Map<Object, String> getComponentsToRegister() {
Map<Object, String> objects = new LinkedHashMap<>();
objects.putAll(super.getComponentsToRegister());
objects.putAll(this.subscriberFlows);
return objects;
}

View File

@@ -16,7 +16,7 @@
package org.springframework.integration.dsl;
import java.util.Set;
import java.util.Map;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
@@ -35,7 +35,7 @@ class PublisherIntegrationFlow<T> extends StandardIntegrationFlow implements Pub
private final Publisher<Message<T>> delegate;
PublisherIntegrationFlow(Set<Object> integrationComponents, Publisher<Message<T>> publisher) {
PublisherIntegrationFlow(Map<Object, String> integrationComponents, Publisher<Message<T>> publisher) {
super(integrationComponents);
this.delegate = publisher;
}

View File

@@ -76,7 +76,7 @@ public class RecipientListRouterSpec extends AbstractRouterSpec<RecipientListRou
public RecipientListRouterSpec recipient(String channelName, Expression expression) {
ExpressionEvaluatingSelector selector = new ExpressionEvaluatingSelector(expression);
this.handler.addRecipient(channelName, selector);
this.componentsToRegister.add(selector);
this.componentsToRegister.put(selector, null);
return _this();
}
@@ -146,7 +146,7 @@ public class RecipientListRouterSpec extends AbstractRouterSpec<RecipientListRou
if (expression != null) {
ExpressionEvaluatingSelector selector = new ExpressionEvaluatingSelector(expression);
this.handler.addRecipient(channel, selector);
this.componentsToRegister.add(selector);
this.componentsToRegister.put(selector, null);
}
else {
this.handler.addRecipient(channel);
@@ -247,7 +247,7 @@ public class RecipientListRouterSpec extends AbstractRouterSpec<RecipientListRou
DirectChannel channel = new DirectChannel();
IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(channel);
subFlow.configure(flowBuilder);
this.componentsToRegister.add(flowBuilder.get());
this.componentsToRegister.put(flowBuilder.get(), null);
return channel;
}

View File

@@ -16,7 +16,6 @@
package org.springframework.integration.dsl;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -161,19 +160,19 @@ public final class RouterSpec<K, R extends AbstractMappingMessageRouter>
IntegrationFlowBuilder flowBuilder = IntegrationFlows.from(channel);
subFlow.configure(flowBuilder);
this.componentsToRegister.add(flowBuilder);
this.componentsToRegister.put(flowBuilder, null);
this.mappingProvider.addMapping(key, channel);
return _this();
}
@Override
public Collection<Object> getComponentsToRegister() {
public Map<Object, String> getComponentsToRegister() {
// The 'mappingProvider' must be added to the 'componentsToRegister' in the end to
// let all other components to be registered before the 'RouterMappingProvider.onInit()' logic.
if (!this.mappingProviderRegistered) {
if (!this.mappingProvider.mapping.isEmpty()) {
this.componentsToRegister.add(this.mappingProvider);
this.componentsToRegister.put(this.mappingProvider, null);
}
this.mappingProviderRegistered = true;
}

View File

@@ -16,10 +16,12 @@
package org.springframework.integration.dsl;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Set;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import org.springframework.context.SmartLifecycle;
@@ -63,7 +65,7 @@ import org.springframework.context.SmartLifecycle;
*/
public class StandardIntegrationFlow implements IntegrationFlow, SmartLifecycle {
private final List<Object> integrationComponents;
private final Map<Object, String> integrationComponents;
private final List<SmartLifecycle> lifecycles = new LinkedList<>();
@@ -71,8 +73,8 @@ public class StandardIntegrationFlow implements IntegrationFlow, SmartLifecycle
private boolean running;
StandardIntegrationFlow(Set<Object> integrationComponents) {
this.integrationComponents = new LinkedList<>(integrationComponents);
StandardIntegrationFlow(Map<Object, String> integrationComponents) {
this.integrationComponents = new LinkedHashMap<>(integrationComponents);
}
//TODO Figure out some custom DestinationResolver when we don't register singletons - remove NOSONAR above when done
@@ -84,13 +86,13 @@ public class StandardIntegrationFlow implements IntegrationFlow, SmartLifecycle
return this.registerComponents;
}
public void setIntegrationComponents(List<Object> integrationComponents) {
public void setIntegrationComponents(Map<Object, String> integrationComponents) {
this.integrationComponents.clear();
this.integrationComponents.addAll(integrationComponents);
this.integrationComponents.putAll(integrationComponents);
}
public List<Object> getIntegrationComponents() {
return this.integrationComponents;
public Map<Object, String> getIntegrationComponents() {
return Collections.unmodifiableMap(this.integrationComponents);
}
@Override
@@ -101,7 +103,8 @@ public class StandardIntegrationFlow implements IntegrationFlow, SmartLifecycle
@Override
public void start() {
if (!this.running) {
ListIterator<Object> iterator = this.integrationComponents.listIterator(this.integrationComponents.size());
List<Object> components = new LinkedList<>(this.integrationComponents.keySet());
ListIterator<Object> iterator = components.listIterator(this.integrationComponents.size());
this.lifecycles.clear();
while (iterator.hasPrevious()) {
Object component = iterator.previous();

View File

@@ -18,9 +18,10 @@ package org.springframework.integration.dsl.channel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.springframework.integration.channel.AbstractMessageChannel;
import org.springframework.integration.channel.interceptor.WireTap;
@@ -44,7 +45,7 @@ public abstract class MessageChannelSpec<S extends MessageChannelSpec<S, C>, C e
extends IntegrationComponentSpec<S, C>
implements ComponentsRegistration {
private final List<Object> componentsToRegister = new ArrayList<>();
private final Map<Object, String> componentsToRegister = new LinkedHashMap<>();
private final List<Class<?>> datatypes = new ArrayList<>();
@@ -108,7 +109,7 @@ public abstract class MessageChannelSpec<S extends MessageChannelSpec<S, C>, C e
*/
public S wireTap(WireTapSpec wireTapSpec) {
WireTap interceptor = wireTapSpec.get();
this.componentsToRegister.add(interceptor);
this.componentsToRegister.put(interceptor, null);
return interceptor(interceptor);
}
@@ -118,7 +119,7 @@ public abstract class MessageChannelSpec<S extends MessageChannelSpec<S, C>, C e
}
@Override
public Collection<Object> getComponentsToRegister() {
public Map<Object, String> getComponentsToRegister() {
return this.componentsToRegister;
}

View File

@@ -16,8 +16,8 @@
package org.springframework.integration.dsl.channel;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import org.springframework.expression.Expression;
import org.springframework.integration.channel.interceptor.WireTap;
@@ -101,9 +101,9 @@ public class WireTapSpec extends IntegrationComponentSpec<WireTapSpec, WireTap>
}
@Override
public Collection<Object> getComponentsToRegister() {
public Map<Object, String> getComponentsToRegister() {
if (this.selector != null) {
return Collections.singleton(this.selector);
return Collections.singletonMap(this.selector, null);
}
else {
return null;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import org.springframework.messaging.MessageChannel;
* and provide an API for some useful {@link IntegrationFlow} options and its lifecycle.
*
* @author Artem Bilan
*
* @since 5.0
*
* @see IntegrationFlowContext
@@ -80,7 +81,7 @@ public class IntegrationFlowRegistration {
if (this.inputChannel == null) {
if (this.integrationFlow instanceof StandardIntegrationFlow) {
StandardIntegrationFlow integrationFlow = (StandardIntegrationFlow) this.integrationFlow;
Object next = integrationFlow.getIntegrationComponents().iterator().next();
Object next = integrationFlow.getIntegrationComponents().keySet().iterator().next();
if (next instanceof MessageChannel) {
this.inputChannel = (MessageChannel) next;
}

View File

@@ -17,9 +17,9 @@
package org.springframework.integration.file.dsl;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.function.Function;
import org.springframework.beans.factory.BeanCreationException;
@@ -260,9 +260,9 @@ public class FileInboundChannelAdapterSpec
}
@Override
public Collection<Object> getComponentsToRegister() {
public Map<Object, String> getComponentsToRegister() {
if (this.expressionFileListFilter != null) {
return Collections.singleton(this.expressionFileListFilter);
return Collections.singletonMap(this.expressionFileListFilter, null);
}
else {
return null;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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,8 @@
package org.springframework.integration.file.dsl;
import java.nio.charset.Charset;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
import org.springframework.expression.common.LiteralExpression;
@@ -228,9 +228,9 @@ public abstract class FileTransferringMessageHandlerSpec<F, S extends FileTransf
}
@Override
public Collection<Object> getComponentsToRegister() {
public Map<Object, String> getComponentsToRegister() {
if (this.defaultFileNameGenerator != null) {
return Collections.singletonList(this.defaultFileNameGenerator);
return Collections.singletonMap(this.defaultFileNameGenerator, null);
}
return null;
}

View File

@@ -17,8 +17,8 @@
package org.springframework.integration.file.dsl;
import java.io.File;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
import org.springframework.expression.Expression;
@@ -261,9 +261,9 @@ public class FileWritingMessageHandlerSpec
}
@Override
public Collection<Object> getComponentsToRegister() {
public Map<Object, String> getComponentsToRegister() {
if (this.defaultFileNameGenerator != null) {
return Collections.singletonList(this.defaultFileNameGenerator);
return Collections.singletonMap(this.defaultFileNameGenerator, null);
}
return null;
}

View File

@@ -17,9 +17,8 @@
package org.springframework.integration.file.dsl;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
import org.springframework.expression.Expression;
@@ -234,12 +233,12 @@ public abstract class RemoteFileInboundChannelAdapterSpec<F, S extends RemoteFil
}
@Override
public Collection<Object> getComponentsToRegister() {
List<Object> componentsToRegister = new ArrayList<>();
componentsToRegister.add(this.synchronizer);
public Map<Object, String> getComponentsToRegister() {
Map<Object, String> componentsToRegister = new LinkedHashMap<>();
componentsToRegister.put(this.synchronizer, null);
if (this.expressionFileListFilter != null) {
componentsToRegister.add(this.expressionFileListFilter);
componentsToRegister.put(this.expressionFileListFilter, null);
}
return componentsToRegister;

View File

@@ -17,9 +17,8 @@
package org.springframework.integration.file.dsl;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.function.Function;
import org.springframework.expression.Expression;
@@ -340,13 +339,13 @@ public abstract class RemoteFileOutboundGatewaySpec<F, S extends RemoteFileOutbo
}
@Override
public Collection<Object> getComponentsToRegister() {
List<Object> componentsToRegister = new ArrayList<>();
public Map<Object, String> getComponentsToRegister() {
Map<Object, String> componentsToRegister = new LinkedHashMap<>();
if (this.expressionFileListFilter != null) {
componentsToRegister.add(this.expressionFileListFilter);
componentsToRegister.put(this.expressionFileListFilter, null);
}
if (this.mputExpressionFileListFilter != null) {
componentsToRegister.add(this.expressionFileListFilter);
componentsToRegister.put(this.mputExpressionFileListFilter, null);
}
return componentsToRegister;

View File

@@ -16,8 +16,8 @@
package org.springframework.integration.file.dsl;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
import org.springframework.expression.Expression;
@@ -127,9 +127,9 @@ public abstract class RemoteFileStreamingInboundChannelAdapterSpec<F,
}
@Override
public Collection<Object> getComponentsToRegister() {
public Map<Object, String> getComponentsToRegister() {
if (this.expressionFileListFilter != null) {
return Collections.singleton(this.expressionFileListFilter);
return Collections.singletonMap(this.expressionFileListFilter, null);
}
else {
return null;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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,7 +17,6 @@
package org.springframework.integration.http.dsl;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -306,10 +305,10 @@ public abstract class BaseHttpInboundEndpointSpec<S extends BaseHttpInboundEndpo
}
@Override
public Collection<Object> getComponentsToRegister() {
public Map<Object, String> getComponentsToRegister() {
HeaderMapper<HttpHeaders> headerMapperToRegister =
(this.explicitHeaderMapper != null ? this.explicitHeaderMapper : this.headerMapper);
return Collections.singletonList(headerMapperToRegister);
return Collections.singletonMap(headerMapperToRegister, null);
}
/**

View File

@@ -16,7 +16,6 @@
package org.springframework.integration.http.dsl;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@@ -310,10 +309,11 @@ public abstract class BaseHttpMessageHandlerSpec<S extends BaseHttpMessageHandle
}
@Override
public Collection<Object> getComponentsToRegister() {
public Map<Object, String> getComponentsToRegister() {
this.target.setUriVariableExpressions(this.uriVariableExpressions);
return Collections.singletonList(this.headerMapper);
return Collections.singletonMap(this.headerMapper, null);
}
protected abstract boolean isClientSet();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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,8 +16,8 @@
package org.springframework.integration.ip.dsl;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import org.springframework.integration.dsl.ComponentsRegistration;
import org.springframework.integration.dsl.MessageProducerSpec;
@@ -29,6 +29,8 @@ import org.springframework.scheduling.TaskScheduler;
* A {@link MessageProducerSpec} for {@link TcpReceivingChannelAdapter}s.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*
*/
@@ -89,9 +91,10 @@ public class TcpInboundChannelAdapterSpec
}
@Override
public Collection<Object> getComponentsToRegister() {
return this.connectionFactory == null ? Collections.emptyList()
: Collections.singletonList(this.connectionFactory);
public Map<Object, String> getComponentsToRegister() {
return this.connectionFactory != null
? Collections.singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
: null;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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,8 +16,8 @@
package org.springframework.integration.ip.dsl;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import org.springframework.integration.dsl.ComponentsRegistration;
import org.springframework.integration.dsl.MessagingGatewaySpec;
@@ -29,6 +29,8 @@ import org.springframework.scheduling.TaskScheduler;
* A {@link MessagingGatewaySpec} for {@link TcpInboundGateway}s.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*
*/
@@ -88,9 +90,10 @@ public class TcpInboundGatewaySpec extends MessagingGatewaySpec<TcpInboundGatewa
}
@Override
public Collection<Object> getComponentsToRegister() {
return this.connectionFactory == null ? Collections.emptyList()
: Collections.singletonList(this.connectionFactory);
public Map<Object, String> getComponentsToRegister() {
return this.connectionFactory != null
? Collections.singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
: null;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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,8 +16,8 @@
package org.springframework.integration.ip.dsl;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import org.springframework.integration.dsl.ComponentsRegistration;
import org.springframework.integration.dsl.MessageHandlerSpec;
@@ -29,6 +29,8 @@ import org.springframework.scheduling.TaskScheduler;
* A {@link MessageHandlerSpec} for {@link TcpSendingMessageHandler}s.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*
*/
@@ -89,9 +91,10 @@ public class TcpOutboundChannelAdapterSpec
}
@Override
public Collection<Object> getComponentsToRegister() {
return this.connectionFactory == null ? Collections.emptyList()
: Collections.singletonList(this.connectionFactory);
public Map<Object, String> getComponentsToRegister() {
return this.connectionFactory != null
? Collections.singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
: null;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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,8 +16,8 @@
package org.springframework.integration.ip.dsl;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.function.Function;
import org.springframework.integration.dsl.ComponentsRegistration;
@@ -31,6 +31,8 @@ import org.springframework.messaging.Message;
* A {@link MessageHandlerSpec} for {@link TcpOutboundGateway}s.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*
*/
@@ -88,9 +90,10 @@ public class TcpOutboundGatewaySpec extends MessageHandlerSpec<TcpOutboundGatewa
}
@Override
public Collection<Object> getComponentsToRegister() {
return this.connectionFactory == null ? Collections.emptyList()
: Collections.singletonList(this.connectionFactory);
public Map<Object, String> getComponentsToRegister() {
return this.connectionFactory != null
? Collections.singletonMap(this.connectionFactory, this.connectionFactory.getComponentName())
: null;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@@ -21,6 +21,8 @@ import org.springframework.util.Assert;
/**
* @author Mark Fisher
* @author Artem Bilan
*
* @since 2.0.2
*/
public class DynamicJmsTemplate extends JmsTemplate {
@@ -32,13 +34,13 @@ public class DynamicJmsTemplate extends JmsTemplate {
return super.getPriority();
}
Assert.isTrue(priority >= 0 && priority <= 9, "JMS priority must be in the range of 0-9");
return priority.intValue();
return priority;
}
@Override
public long getReceiveTimeout() {
Long receiveTimeout = DynamicJmsTemplateProperties.getReceiveTimeout();
return (receiveTimeout != null) ? receiveTimeout.longValue() : super.getReceiveTimeout();
return (receiveTimeout != null) ? receiveTimeout : super.getReceiveTimeout();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2017 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.
@@ -211,10 +211,15 @@ public final class Jms {
* @param connectionFactory the JMS ConnectionFactory to build on
* @return the {@link JmsMessageDrivenChannelAdapterSpec} instance
*/
public static JmsMessageDrivenChannelAdapterSpec
.JmsMessageDrivenChannelAdapterListenerContainerSpec<JmsDefaultListenerContainerSpec, DefaultMessageListenerContainer>
public static JmsMessageDrivenChannelAdapterSpec.JmsMessageDrivenChannelAdapterListenerContainerSpec<JmsDefaultListenerContainerSpec, DefaultMessageListenerContainer>
messageDrivenChannelAdapter(ConnectionFactory connectionFactory) {
return messageDrivenChannelAdapter(connectionFactory, DefaultMessageListenerContainer.class);
try {
return new JmsMessageDrivenChannelAdapterSpec.JmsMessageDrivenChannelAdapterListenerContainerSpec<>(
new JmsDefaultListenerContainerSpec().connectionFactory(connectionFactory));
}
catch (Exception e) {
throw new IllegalStateException(e);
}
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,10 +29,10 @@ import org.springframework.jms.support.destination.JmsDestinationAccessor;
* @param <A> the target {@link JmsDestinationAccessor} implementation type.
*
* @author Artem Bilan
*
* @since 5.0
*/
public abstract class
JmsDestinationAccessorSpec<S extends JmsDestinationAccessorSpec<S, A>, A extends JmsDestinationAccessor>
public abstract class JmsDestinationAccessorSpec<S extends JmsDestinationAccessorSpec<S, A>, A extends JmsDestinationAccessor>
extends IntegrationComponentSpec<S, A> {
protected JmsDestinationAccessorSpec(A accessor) {
@@ -44,6 +44,11 @@ public abstract class
return _this();
}
@Override
public S id(String id) {
return super.id(id);
}
/**
* A {@link DestinationResolver} to use.
* @param destinationResolver the {@link DestinationResolver} to use.

View File

@@ -16,11 +16,14 @@
package org.springframework.integration.jms.dsl;
import java.util.Collections;
import java.util.Map;
import java.util.function.Consumer;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import org.springframework.integration.dsl.ComponentsRegistration;
import org.springframework.integration.dsl.MessageSourceSpec;
import org.springframework.integration.jms.JmsDestinationPollingSource;
import org.springframework.integration.jms.JmsHeaderMapper;
@@ -33,6 +36,7 @@ import org.springframework.util.Assert;
* @param <S> the target {@link JmsInboundChannelAdapterSpec} implementation type.
*
* @author Artem Bilan
*
* @since 5.0
*/
public class JmsInboundChannelAdapterSpec<S extends JmsInboundChannelAdapterSpec<S>>
@@ -92,8 +96,9 @@ public class JmsInboundChannelAdapterSpec<S extends JmsInboundChannelAdapterSpec
/**
* A {@link JmsTemplate}-based {@link JmsInboundChannelAdapterSpec} extension.
*/
public static class JmsInboundChannelSpecTemplateAware extends
JmsInboundChannelAdapterSpec<JmsInboundChannelSpecTemplateAware> {
public static class JmsInboundChannelSpecTemplateAware
extends JmsInboundChannelAdapterSpec<JmsInboundChannelSpecTemplateAware>
implements ComponentsRegistration {
JmsInboundChannelSpecTemplateAware(ConnectionFactory connectionFactory) {
super(connectionFactory);
@@ -111,6 +116,11 @@ public class JmsInboundChannelAdapterSpec<S extends JmsInboundChannelAdapterSpec
return _this();
}
@Override
public Map<Object, String> getComponentsToRegister() {
return Collections.singletonMap(this.jmsTemplateSpec.get(), this.jmsTemplateSpec.getId());
}
}
}

View File

@@ -16,10 +16,13 @@
package org.springframework.integration.jms.dsl;
import java.util.Collections;
import java.util.Map;
import java.util.function.Consumer;
import javax.jms.Destination;
import org.springframework.integration.dsl.ComponentsRegistration;
import org.springframework.integration.dsl.MessageProducerSpec;
import org.springframework.integration.jms.ChannelPublishingJmsMessageListener;
import org.springframework.integration.jms.JmsHeaderMapper;
@@ -34,6 +37,7 @@ import org.springframework.util.Assert;
* @param <S> the target {@link JmsMessageDrivenChannelAdapterSpec} implementation type.
*
* @author Artem Bilan
*
* @since 5.0
*/
public class JmsMessageDrivenChannelAdapterSpec<S extends JmsMessageDrivenChannelAdapterSpec<S>>
@@ -81,7 +85,8 @@ public class JmsMessageDrivenChannelAdapterSpec<S extends JmsMessageDrivenChanne
*/
public static class
JmsMessageDrivenChannelAdapterListenerContainerSpec<S extends JmsListenerContainerSpec<S, C>, C extends AbstractMessageListenerContainer>
extends JmsMessageDrivenChannelAdapterSpec<JmsMessageDrivenChannelAdapterListenerContainerSpec<S, C>> {
extends JmsMessageDrivenChannelAdapterSpec<JmsMessageDrivenChannelAdapterListenerContainerSpec<S, C>>
implements ComponentsRegistration {
private final JmsListenerContainerSpec<S, C> spec;
@@ -89,6 +94,7 @@ public class JmsMessageDrivenChannelAdapterSpec<S extends JmsMessageDrivenChanne
super(spec.get());
this.spec = spec;
this.spec.get().setAutoStartup(false);
}
/**
@@ -125,6 +131,11 @@ public class JmsMessageDrivenChannelAdapterSpec<S extends JmsMessageDrivenChanne
return _this();
}
@Override
public Map<Object, String> getComponentsToRegister() {
return Collections.singletonMap(this.spec.get(), this.spec.getId());
}
}
}

View File

@@ -16,12 +16,15 @@
package org.springframework.integration.jms.dsl;
import java.util.Collections;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import org.springframework.integration.dsl.ComponentsRegistration;
import org.springframework.integration.dsl.MessageHandlerSpec;
import org.springframework.integration.expression.FunctionExpression;
import org.springframework.integration.jms.JmsHeaderMapper;
@@ -127,8 +130,9 @@ public class JmsOutboundChannelAdapterSpec<S extends JmsOutboundChannelAdapterSp
/**
* A {@link JmsTemplate}-based {@link JmsOutboundChannelAdapterSpec} extension.
*/
public static class JmsOutboundChannelSpecTemplateAware extends
JmsOutboundChannelAdapterSpec<JmsOutboundChannelSpecTemplateAware> {
public static class JmsOutboundChannelSpecTemplateAware
extends JmsOutboundChannelAdapterSpec<JmsOutboundChannelSpecTemplateAware>
implements ComponentsRegistration {
JmsOutboundChannelSpecTemplateAware(ConnectionFactory connectionFactory) {
super(connectionFactory);
@@ -140,6 +144,11 @@ public class JmsOutboundChannelAdapterSpec<S extends JmsOutboundChannelAdapterSp
return _this();
}
@Override
public Map<Object, String> getComponentsToRegister() {
return Collections.singletonMap(this.jmsTemplateSpec.get(), this.jmsTemplateSpec.getId());
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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.
@@ -64,6 +64,7 @@ import org.springframework.integration.support.MessageBuilder;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.jms.connection.CachingConnectionFactory;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.listener.MessageListenerContainer;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
@@ -127,6 +128,17 @@ public class JmsTests {
@Autowired
private AtomicBoolean jmsInboundGatewayChannelCalled;
@Autowired(required = false)
@Qualifier("jmsOutboundFlowTemplate")
private JmsTemplate jmsOutboundFlowTemplate;
@Autowired(required = false)
@Qualifier("jmsMessageDrivenRedeliveryFlowContainer")
private MessageListenerContainer jmsMessageDrivenRedeliveryFlowContainer;
@Autowired
private CountDownLatch redeliveryLatch;
@Test
public void testPollingFlow() {
this.controlBus.send("@'jmsTests.ContextConfiguration.integerMessageSource.inboundChannelAdapter'.start()");
@@ -174,6 +186,8 @@ public class JmsTests {
assertNotNull(receive);
assertEquals("foo", receive.getPayload());
assertNotNull(this.jmsOutboundFlowTemplate);
}
@Test
@@ -206,9 +220,6 @@ public class JmsTests {
assertEquals("foo", received.getPayload());
}
@Autowired
private CountDownLatch redeliveryLatch;
@Test
public void testJmsRedeliveryFlow() throws InterruptedException {
this.jmsOutboundInboundChannel.send(MessageBuilder.withPayload("foo")
@@ -216,6 +227,8 @@ public class JmsTests {
.build());
assertTrue(this.redeliveryLatch.await(10, TimeUnit.SECONDS));
assertNotNull(this.jmsMessageDrivenRedeliveryFlowContainer);
}
@MessagingGateway(defaultRequestChannel = "controlBus.input")
@@ -279,8 +292,10 @@ public class JmsTests {
@Bean
public IntegrationFlow jmsOutboundFlow() {
return f -> f.handle(Jms.outboundAdapter(jmsConnectionFactory())
.destinationExpression("headers." + SimpMessageHeaderAccessor.DESTINATION_HEADER));
return f -> f
.handle(Jms.outboundAdapter(jmsConnectionFactory())
.destinationExpression("headers." + SimpMessageHeaderAccessor.DESTINATION_HEADER)
.configureJmsTemplate(t -> t.id("jmsOutboundFlowTemplate")));
}
@Bean
@@ -353,16 +368,16 @@ public class JmsTests {
@Bean
public IntegrationFlow jmsOutboundGatewayFlow() {
return f -> f.handle(Jms.outboundGateway(jmsConnectionFactory())
.replyContainer(c -> c.idleReplyContainerTimeout(10))
.requestDestination("jmsPipelineTest"),
.replyContainer(c -> c.idleReplyContainerTimeout(10))
.requestDestination("jmsPipelineTest"),
e -> e.id("jmsOutboundGateway"));
}
@Bean
public IntegrationFlow jmsInboundGatewayFlow() {
return IntegrationFlows.from(Jms.inboundGateway(jmsConnectionFactory())
.requestChannel(jmsInboundGatewayInputChannel())
.destination("jmsPipelineTest"))
.requestChannel(jmsInboundGatewayInputChannel())
.destination("jmsPipelineTest"))
.<String, String>transform(String::toUpperCase)
.get();
}
@@ -392,7 +407,8 @@ public class JmsTests {
return IntegrationFlows
.from(Jms.messageDrivenChannelAdapter(jmsConnectionFactory())
.errorChannel(IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME)
.destination("jmsMessageDrivenRedelivery"))
.destination("jmsMessageDrivenRedelivery")
.configureListenerContainer(c -> c.id("jmsMessageDrivenRedeliveryFlowContainer")))
.<String, String>transform(p -> {
throw new RuntimeException("intentional");
})

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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,10 +16,10 @@
package org.springframework.integration.jpa.dsl;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.springframework.integration.dsl.ComponentsRegistration;
import org.springframework.integration.dsl.MessageHandlerSpec;
@@ -159,8 +159,8 @@ public abstract class JpaBaseOutboundEndpointSpec<S extends JpaBaseOutboundEndpo
}
@Override
public Collection<Object> getComponentsToRegister() {
return Collections.singletonList(this.jpaExecutor);
public Map<Object, String> getComponentsToRegister() {
return Collections.singletonMap(this.jpaExecutor, null);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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,8 +16,8 @@
package org.springframework.integration.jpa.dsl;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import org.springframework.expression.Expression;
import org.springframework.integration.dsl.ComponentsRegistration;
@@ -183,8 +183,8 @@ public class JpaInboundChannelAdapterSpec
}
@Override
public Collection<Object> getComponentsToRegister() {
return Collections.singletonList(this.jpaExecutor);
public Map<Object, String> getComponentsToRegister() {
return Collections.singletonMap(this.jpaExecutor, null);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2017 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,11 +16,11 @@
package org.springframework.integration.mail.dsl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
@@ -64,7 +64,7 @@ public class ImapIdleChannelAdapterSpec
private final ImapMailReceiver receiver;
private final Collection<Object> componentsToRegister = new ArrayList<Object>();
private final Map<Object, String> componentsToRegister = new LinkedHashMap<>();
private final List<Advice> adviceChain = new LinkedList<>();
@@ -80,7 +80,7 @@ public class ImapIdleChannelAdapterSpec
super(new ImapIdleChannelAdapter(receiver));
this.target.setAdviceChain(this.adviceChain);
this.receiver = receiver;
this.componentsToRegister.add(receiver);
this.componentsToRegister.put(receiver, receiver.getComponentName());
this.externalReceiver = externalReceiver;
}
@@ -326,7 +326,7 @@ public class ImapIdleChannelAdapterSpec
*/
public ImapIdleChannelAdapterSpec transactional() {
TransactionInterceptor transactionInterceptor = new TransactionInterceptorBuilder(false).build();
this.componentsToRegister.add(transactionInterceptor);
this.componentsToRegister.put(transactionInterceptor, null);
return transactional(transactionInterceptor);
}
@@ -352,7 +352,7 @@ public class ImapIdleChannelAdapterSpec
}
@Override
public Collection<Object> getComponentsToRegister() {
public Map<Object, String> getComponentsToRegister() {
return this.componentsToRegister;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2017 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,8 +16,8 @@
package org.springframework.integration.mail.dsl;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.Properties;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -50,7 +50,7 @@ import org.springframework.util.Assert;
* @since 5.0
*/
public abstract class
MailInboundChannelAdapterSpec<S extends MailInboundChannelAdapterSpec<S, R>, R extends AbstractMailReceiver>
MailInboundChannelAdapterSpec<S extends MailInboundChannelAdapterSpec<S, R>, R extends AbstractMailReceiver>
extends MessageSourceSpec<S, MailReceivingMessageSource>
implements ComponentsRegistration {
@@ -253,8 +253,8 @@ public abstract class
}
@Override
public Collection<Object> getComponentsToRegister() {
return Collections.<Object>singletonList(this.receiver);
public Map<Object, String> getComponentsToRegister() {
return Collections.singletonMap(this.receiver, this.receiver.getComponentName());
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2017 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,7 +16,6 @@
package org.springframework.integration.scripting.dsl;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
@@ -126,8 +125,8 @@ public class ScriptMessageSourceSpec extends MessageSourceSpec<ScriptMessageSour
}
@Override
public Collection<Object> getComponentsToRegister() {
return Collections.singletonList(this.delegate.get());
public Map<Object, String> getComponentsToRegister() {
return Collections.singletonMap(this.delegate.get(), this.delegate.getId());
}
}