GH-3155: Add support for Java DSL extensions (#3167)

* GH-3155: Add support for Java DSL extensions

Fixes https://github.com/spring-projects/spring-integration/issues/3155

Provide an `IntegrationFlowExtension` for possible custom EI-operators
in the target project use-cases.

* * Move `IntegrationFlowExtension` tests ot its own test class
* Make all the `IntegrationComponentSpec` ctors as `protected` for possible custom extensions
* Make some `BaseIntegrationFlowDefinition` methods and properties as `protected` to get them
access from the `IntegrationFlowExtension` implementations
* Document the feature

* * Fix language and typos in docs

* * Add `protected` to one more `GatewayEndpointSpec` ctor
* Add JavaDocs to `GatewayEndpointSpec` methods

* * Add `protected` to one more `JmsPollableMessageChannelSpec` ctor
This commit is contained in:
Artem Bilan
2020-02-07 13:40:39 -05:00
committed by GitHub
parent 00b771d8a8
commit 867a8cf108
82 changed files with 607 additions and 275 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,7 +34,7 @@ public class AbstractRouterSpec<S extends AbstractRouterSpec<S, R>, R extends Ab
private boolean defaultToParentFlow;
AbstractRouterSpec(R router) {
protected AbstractRouterSpec(R router) {
super(router);
}
@@ -100,7 +100,7 @@ public class AbstractRouterSpec<S extends AbstractRouterSpec<S, R>, R extends Ab
return _this();
}
boolean isDefaultToParentFlow() {
protected boolean isDefaultToParentFlow() {
return this.defaultToParentFlow;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ public class AggregatorSpec extends CorrelationHandlerSpec<AggregatorSpec, Aggre
private Function<MessageGroup, Map<String, Object>> headersFunction;
AggregatorSpec() {
protected AggregatorSpec() {
super(new AggregatingMessageHandler(new DefaultAggregatingMessageGroupProcessor()));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -52,7 +52,7 @@ public class BarrierSpec extends ConsumerEndpointSpec<BarrierSpec, BarrierMessag
private boolean async;
BarrierSpec(long timeout) {
protected BarrierSpec(long timeout) {
super(null);
this.timeout = timeout;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 the original author or authors.
* Copyright 2019-2020 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.
@@ -121,10 +121,10 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
private static final String MESSAGE_PROCESSOR_SPEC_MUST_NOT_BE_NULL = "'messageProcessorSpec' must not be null";
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
private static final Set<MessageProducer> REFERENCED_REPLY_PRODUCERS = new HashSet<>();
protected static final SpelExpressionParser PARSER = new SpelExpressionParser(); //NOSONAR - final
protected final Map<Object, String> integrationComponents = new LinkedHashMap<>(); //NOSONAR - final
private MessageChannel currentMessageChannel;
@@ -380,7 +380,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
return wireTap(wireTapChannel, wireTapConfigurer);
}
private MessageChannel obtainInputChannelFromFlow(IntegrationFlow flow) {
protected MessageChannel obtainInputChannelFromFlow(IntegrationFlow flow) {
Assert.notNull(flow, "'flow' must not be null");
MessageChannel messageChannel = flow.getInputChannel();
if (messageChannel == null) {
@@ -1222,6 +1222,18 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
return enrichHeaders(headers.get(), endpointConfigurer);
}
/**
* Accept a {@link Map} of values to be used for the
* {@link Message} header enrichment.
* {@code values} can apply an {@link Expression}
* to be evaluated against a request {@link Message}.
* @param headers the Map of headers to enrich.
* @return the current {@link IntegrationFlowDefinition}.
*/
public B enrichHeaders(Map<String, Object> headers) {
return enrichHeaders(headers, null);
}
/**
* Accept a {@link Map} of values to be used for the
* {@link Message} header enrichment.
@@ -1908,7 +1920,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
return route(new RouterSpec<>(new MethodInvokingRouter(processor)), routerConfigurer);
}
private <R extends AbstractMessageRouter, S extends AbstractRouterSpec<S, R>> B route(S routerSpec,
protected <R extends AbstractMessageRouter, S extends AbstractRouterSpec<? super S, R>> B route(S routerSpec,
Consumer<S> routerConfigurer) {
if (routerConfigurer != null) {
@@ -2825,6 +2837,17 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
.addComponent(downstream);
}
/**
* Add a {@value IntegrationContextUtils#NULL_CHANNEL_BEAN_NAME} bean into this flow
* definition as a terminal operator.
* @return The {@link IntegrationFlow} instance based on this definition.
* @since 5.1
*/
public IntegrationFlow nullChannel() {
return channel(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME)
.get();
}
/**
* Represent an Integration Flow as a Reactive Streams {@link Publisher} bean.
* @param <T> the expected {@code payload} type
@@ -2858,19 +2881,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
return new PublisherIntegrationFlow<>(components, publisher);
}
/**
* Add a {@value IntegrationContextUtils#NULL_CHANNEL_BEAN_NAME} bean into this flow
* definition as a terminal operator.
* @return The {@link IntegrationFlow} instance based on this definition.
* @since 5.1
*/
public IntegrationFlow nullChannel() {
return channel(IntegrationContextUtils.NULL_CHANNEL_BEAN_NAME)
.get();
}
@SuppressWarnings(UNCHECKED)
private <S extends ConsumerEndpointSpec<S, ? extends MessageHandler>> B register(S endpointSpec,
protected <S extends ConsumerEndpointSpec<? super S, ? extends MessageHandler>> B register(S endpointSpec,
Consumer<S> endpointConfigurer) {
if (endpointConfigurer != null) {
@@ -2906,7 +2917,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
return addComponent(endpointSpec).currentComponent(factoryBeanTuple2.getT2());
}
private B registerOutputChannelIfCan(MessageChannel outputChannel) {
protected B registerOutputChannelIfCan(MessageChannel outputChannel) {
if (!(outputChannel instanceof FixedSubscriberChannelPrototype)) {
addComponent(outputChannel, null);
Object currComponent = getCurrentComponent();
@@ -2947,7 +2958,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
return _this();
}
private boolean isOutputChannelRequired() {
protected boolean isOutputChannelRequired() {
Object currentElement = getCurrentComponent();
if (currentElement != null) {
if (AopUtils.isAopProxy(currentElement)) {
@@ -3006,7 +3017,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
return this.integrationFlow;
}
private void checkReuse(MessageProducer replyHandler) {
protected void checkReuse(MessageProducer replyHandler) {
Assert.isTrue(!REFERENCED_REPLY_PRODUCERS.contains(replyHandler),
"A reply MessageProducer may only be referenced once ("
+ replyHandler
@@ -3014,19 +3025,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
REFERENCED_REPLY_PRODUCERS.add(replyHandler);
}
/**
* Accept a {@link Map} of values to be used for the
* {@link Message} header enrichment.
* {@code values} can apply an {@link Expression}
* to be evaluated against a request {@link Message}.
* @param headers the Map of headers to enrich.
* @return the current {@link IntegrationFlowDefinition}.
*/
public B enrichHeaders(Map<String, Object> headers) {
return enrichHeaders(headers, null);
}
private static Object extractProxyTarget(Object target) {
protected static Object extractProxyTarget(Object target) {
if (!(target instanceof Advised)) {
return target;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,11 +42,11 @@ import org.springframework.util.Assert;
*
* @since 5.0
*/
public final class DelayerEndpointSpec extends ConsumerEndpointSpec<DelayerEndpointSpec, DelayHandler> {
public class DelayerEndpointSpec extends ConsumerEndpointSpec<DelayerEndpointSpec, DelayHandler> {
private final List<Advice> delayedAdvice = new LinkedList<>();
DelayerEndpointSpec(DelayHandler delayHandler) {
protected DelayerEndpointSpec(DelayHandler delayHandler) {
super(delayHandler);
Assert.notNull(delayHandler, "'delayHandler' must not be null.");
this.handler.setDelayedAdviceChain(this.delayedAdvice);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,4 @@ public class DirectChannelSpec extends LoadBalancingChannelSpec<DirectChannelSpe
return super.doGet();
}
DirectChannelSpec() {
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -47,11 +47,11 @@ import reactor.util.function.Tuple2;
*/
public class EnricherSpec extends ConsumerEndpointSpec<EnricherSpec, ContentEnricher> {
private final Map<String, Expression> propertyExpressions = new HashMap<>();
protected final Map<String, Expression> propertyExpressions = new HashMap<>(); // NOSONAR - final
private final Map<String, HeaderValueMessageProcessor<?>> headerExpressions = new HashMap<>();
protected final Map<String, HeaderValueMessageProcessor<?>> headerExpressions = new HashMap<>(); // NOSONAR - final
EnricherSpec() {
protected EnricherSpec() {
super(new ContentEnricher());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ public class ExecutorChannelSpec extends LoadBalancingChannelSpec<ExecutorChanne
private final Executor executor;
ExecutorChannelSpec(Executor executor) {
protected ExecutorChannelSpec(Executor executor) {
this.executor = executor;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -26,9 +26,9 @@ import org.springframework.messaging.MessageChannel;
*
* @since 5.0
*/
public final class FilterEndpointSpec extends ConsumerEndpointSpec<FilterEndpointSpec, MessageFilter> {
public class FilterEndpointSpec extends ConsumerEndpointSpec<FilterEndpointSpec, MessageFilter> {
FilterEndpointSpec(MessageFilter messageFilter) {
protected FilterEndpointSpec(MessageFilter messageFilter) {
super(messageFilter);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2019 the original author or authors.
* Copyright 2017-2020 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.
@@ -26,7 +26,7 @@ import org.springframework.integration.channel.FluxMessageChannel;
*/
public class FluxMessageChannelSpec extends MessageChannelSpec<FluxMessageChannelSpec, FluxMessageChannel> {
FluxMessageChannelSpec() {
protected FluxMessageChannelSpec() {
this.channel = new FluxMessageChannel();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -26,43 +26,73 @@ import org.springframework.messaging.MessageChannel;
*
* @since 5.0
*/
public final class GatewayEndpointSpec extends ConsumerEndpointSpec<GatewayEndpointSpec, GatewayMessageHandler> {
public class GatewayEndpointSpec extends ConsumerEndpointSpec<GatewayEndpointSpec, GatewayMessageHandler> {
GatewayEndpointSpec(MessageChannel requestChannel) {
protected GatewayEndpointSpec(MessageChannel requestChannel) {
super(new GatewayMessageHandler());
this.handler.setRequestChannel(requestChannel);
}
GatewayEndpointSpec(String requestChannel) {
protected GatewayEndpointSpec(String requestChannel) {
super(new GatewayMessageHandler());
this.handler.setRequestChannelName(requestChannel);
}
/**
* Set a reply channel.
* @param replyChannel the reply channel
* @return the spec
*/
public GatewayEndpointSpec replyChannel(MessageChannel replyChannel) {
this.handler.setReplyChannel(replyChannel);
return this;
}
/**
* Set a reply channel.
* @param replyChannel the reply channel
* @return the spec
*/
public GatewayEndpointSpec replyChannel(String replyChannel) {
this.handler.setReplyChannelName(replyChannel);
return this;
}
/**
* Set an error channel.
* @param errorChannel the error channel
* @return the spec
*/
public GatewayEndpointSpec errorChannel(MessageChannel errorChannel) {
this.handler.setErrorChannel(errorChannel);
return this;
}
/**
* Set an error channel.
* @param errorChannel the error channel
* @return the spec
*/
public GatewayEndpointSpec errorChannel(String errorChannel) {
this.handler.setErrorChannelName(errorChannel);
return this;
}
/**
* Set a request timeout.
* @param requestTimeout the request timeout
* @return the spec
*/
public GatewayEndpointSpec requestTimeout(Long requestTimeout) {
this.handler.setRequestTimeout(requestTimeout);
return this;
}
/**
* Set a reply timeout.
* @param replyTimeout the reply timeout
* @return the spec
*/
public GatewayEndpointSpec replyTimeout(Long replyTimeout) {
this.handler.setReplyTimeout(replyTimeout);
return this;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 the original author or authors.
* Copyright 2019-2020 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.
@@ -45,19 +45,19 @@ import org.springframework.messaging.MessageChannel;
*/
public class GatewayProxySpec {
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
protected static final SpelExpressionParser PARSER = new SpelExpressionParser(); // NOSONAR - final
private final MessageChannel gatewayRequestChannel = new DirectChannel();
protected final MessageChannel gatewayRequestChannel = new DirectChannel(); // NOSONAR - final
private final GatewayProxyFactoryBean gatewayProxyFactoryBean;
protected final GatewayProxyFactoryBean gatewayProxyFactoryBean; // NOSONAR - final
private final GatewayMethodMetadata gatewayMethodMetadata = new GatewayMethodMetadata();
protected final GatewayMethodMetadata gatewayMethodMetadata = new GatewayMethodMetadata(); // NOSONAR - final
private final Map<String, Expression> headerExpressions = new HashMap<>();
protected final Map<String, Expression> headerExpressions = new HashMap<>(); // NOSONAR - final
private boolean populateGatewayMethodMetadata;
GatewayProxySpec(Class<?> serviceInterface) {
protected GatewayProxySpec(Class<?> serviceInterface) {
this.gatewayProxyFactoryBean = new AnnotationGatewayProxyFactoryBean(serviceInterface);
this.gatewayProxyFactoryBean.setDefaultRequestChannel(this.gatewayRequestChannel);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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,10 +27,10 @@ import org.springframework.messaging.MessageHandler;
*
* @since 5.0
*/
public final class GenericEndpointSpec<H extends MessageHandler>
public class GenericEndpointSpec<H extends MessageHandler>
extends ConsumerEndpointSpec<GenericEndpointSpec<H>, H> {
GenericEndpointSpec(H messageHandler) {
protected GenericEndpointSpec(H messageHandler) {
super(messageHandler);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -58,11 +58,11 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
private static final String HEADERS_MUST_NOT_BE_NULL = "'headers' must not be null";
private final Map<String, HeaderValueMessageProcessor<?>> headerToAdd = new HashMap<>();
protected final Map<String, HeaderValueMessageProcessor<?>> headerToAdd = new HashMap<>(); // NOSONAR - final
private final HeaderEnricher headerEnricher = new HeaderEnricher(this.headerToAdd);
protected final HeaderEnricher headerEnricher = new HeaderEnricher(this.headerToAdd); // NOSONAR - final
HeaderEnricherSpec() {
protected HeaderEnricherSpec() {
super(null);
this.handler = new MessageTransformingHandler(this.headerEnricher);
}

View File

@@ -0,0 +1,98 @@
/*
* Copyright 2020 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.dsl;
import java.util.Map;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.integration.channel.DirectChannel;
/**
* An {@link IntegrationFlowDefinition} extension for custom Java DSL operators
* and reusable solutions.
* For supporting method flow chain an implementation of this class has to return
* an extension class from new methods, e.g.:
* <pre class="code">
* {@code
* public class MyIntegrationFlowDefinition
* extends IntegrationFlowExtension<MyIntegrationFlowDefinition> {
*
* public MyIntegrationFlowDefinition upperCaseAfterSplit() {
* return split()
* .transform("payload.toUpperCase()");
* }
* }
* }
* </pre>
* This way it will be used in the target configuration as natural DSL definition:
* <pre class="code">
* {@code
* &#064;Bean
* public IntegrationFlow myFlowDefinition() {
* return
* new MyIntegrationFlowDefinition()
* .log()
* .upperCaseAfterSplit()
* .aggregate()
* .get();
* }
* }
* </pre>
* This {@link IntegrationFlowExtension} can also be used for overriding
* existing operators with extensions to any {@link IntegrationComponentSpec} extensions,
* e.g. adding new options for target component configuration.
*
* @param <B> the {@link IntegrationFlowDefinition} implementation type.
*
* @author Artem Bilan
*
* @since 5.3
*/
public abstract class IntegrationFlowExtension<B extends IntegrationFlowExtension<B>>
extends IntegrationFlowDefinition<B> {
private final DirectChannel inputChannel = new DirectChannel();
protected IntegrationFlowExtension() {
channel(this.inputChannel);
}
@Override
public StandardIntegrationFlow get() {
StandardIntegrationFlow targetIntegrationFlow = super.get();
return new StandardIntegrationFlowExtension(targetIntegrationFlow.getIntegrationComponents(),
this.inputChannel);
}
private static class StandardIntegrationFlowExtension extends StandardIntegrationFlow
implements BeanNameAware {
private final DirectChannel inputChannel;
StandardIntegrationFlowExtension(Map<Object, String> integrationComponents, DirectChannel inputChannel) {
super(integrationComponents);
this.inputChannel = inputChannel;
}
@Override
public void setBeanName(String name) {
this.inputChannel.setBeanName(name + ".input");
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ public class PriorityChannelSpec extends MessageChannelSpec<PriorityChannelSpec,
private MessageGroupQueue messageGroupQueue;
PriorityChannelSpec() {
protected PriorityChannelSpec() {
}
public PriorityChannelSpec capacity(int capacity) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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,10 +36,10 @@ public class PublishSubscribeSpec extends PublishSubscribeChannelSpec<PublishSub
private int order;
PublishSubscribeSpec() {
protected PublishSubscribeSpec() {
}
PublishSubscribeSpec(@Nullable Executor executor) {
protected PublishSubscribeSpec(@Nullable Executor executor) {
super(executor);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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,14 +35,14 @@ public class QueueChannelSpec extends MessageChannelSpec<QueueChannelSpec, Queue
protected Integer capacity; // NOSONAR
QueueChannelSpec() {
protected QueueChannelSpec() {
}
QueueChannelSpec(Queue<Message<?>> queue) {
protected QueueChannelSpec(Queue<Message<?>> queue) {
this.queue = queue;
}
QueueChannelSpec(Integer capacity) {
protected QueueChannelSpec(Integer capacity) {
this.capacity = capacity;
}
@@ -71,7 +71,7 @@ public class QueueChannelSpec extends MessageChannelSpec<QueueChannelSpec, Queue
private Lock storeLock;
MessageStoreSpec(ChannelMessageStore messageGroupStore, Object groupId) {
protected MessageStoreSpec(ChannelMessageStore messageGroupStore, Object groupId) {
this.messageGroupStore = messageGroupStore;
this.groupId = groupId;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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,7 @@ import org.springframework.util.StringUtils;
*/
public class RecipientListRouterSpec extends AbstractRouterSpec<RecipientListRouterSpec, RecipientListRouter> {
RecipientListRouterSpec() {
protected RecipientListRouterSpec() {
super(new RecipientListRouter());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -25,7 +25,7 @@ import org.springframework.integration.channel.RendezvousChannel;
*/
public class RendezvousChannelSpec extends MessageChannelSpec<RendezvousChannelSpec, RendezvousChannel> {
RendezvousChannelSpec() {
protected RendezvousChannelSpec() {
this.channel = new RendezvousChannel();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -26,7 +26,7 @@ import org.springframework.integration.aggregator.ResequencingMessageHandler;
*/
public class ResequencerSpec extends CorrelationHandlerSpec<ResequencerSpec, ResequencingMessageHandler> {
ResequencerSpec() {
protected ResequencerSpec() {
super(new ResequencingMessageHandler(new ResequencingMessageGroupProcessor()));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -52,7 +52,7 @@ public final class RouterSpec<K, R extends AbstractMappingMessageRouter>
private boolean mappingProviderRegistered;
RouterSpec(R router) {
protected RouterSpec(R router) {
super(router);
this.mappingProvider = new RouterMappingProvider(this.handler);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ import org.springframework.messaging.MessageChannel;
*/
public class ScatterGatherSpec extends ConsumerEndpointSpec<ScatterGatherSpec, ScatterGatherHandler> {
ScatterGatherSpec(ScatterGatherHandler messageHandler) {
protected ScatterGatherSpec(ScatterGatherHandler messageHandler) {
super(messageHandler);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -25,10 +25,10 @@ import org.springframework.integration.scheduling.PollerMetadata;
*
* @since 5.0
*/
public final class SourcePollingChannelAdapterSpec extends
public class SourcePollingChannelAdapterSpec extends
EndpointSpec<SourcePollingChannelAdapterSpec, SourcePollingChannelAdapterFactoryBean, MessageSource<?>> {
SourcePollingChannelAdapterSpec(MessageSource<?> messageSource) {
protected SourcePollingChannelAdapterSpec(MessageSource<?> messageSource) {
super(messageSource);
this.endpointFactoryBean.setSource(messageSource);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.messaging.MessageChannel;
*
* @since 5.0
*/
public final class SplitterEndpointSpec<S extends AbstractMessageSplitter>
public class SplitterEndpointSpec<S extends AbstractMessageSplitter>
extends ConsumerEndpointSpec<SplitterEndpointSpec<S>, S> {
SplitterEndpointSpec(S splitter) {
protected SplitterEndpointSpec(S splitter) {
super(splitter);
}

View File

@@ -0,0 +1,117 @@
/*
* Copyright 2020 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.integration.dsl.extensions;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Arrays;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.config.EnableIntegration;
import org.springframework.integration.dsl.AggregatorSpec;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.IntegrationFlowExtension;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
/**
* @author Artem Bilan
*
* @since 5.3
*/
@SpringJUnitConfig
@DirtiesContext
public class IntegrationFlowExtensionTests {
@Autowired
@Qualifier("customFlowDefinition.input")
SubscribableChannel customFlowDefinitionInput;
@Test
public void testCustomFlowDefinition() {
QueueChannel replyChannel = new QueueChannel();
Message<?> testMessage =
MessageBuilder.withPayload(Arrays.asList("one", "two", "three"))
.setReplyChannel(replyChannel)
.build();
this.customFlowDefinitionInput.send(testMessage);
Message<?> replyMessage = replyChannel.receive(10_000);
assertThat(replyMessage)
.isNotNull()
.extracting(Message::getPayload)
.isEqualTo("ONE, TWO, THREE");
}
@Configuration
@EnableIntegration
public static class ContextConfiguration {
@Bean
public IntegrationFlow customFlowDefinition() {
return
new CustomIntegrationFlowDefinition()
.log()
.upperCaseAfterSplit()
.channel("innerChannel")
.customAggregate(customAggregatorSpec ->
customAggregatorSpec.expireGroupsUponCompletion(true))
.logAndReply();
}
}
public static class CustomIntegrationFlowDefinition
extends IntegrationFlowExtension<CustomIntegrationFlowDefinition> {
public CustomIntegrationFlowDefinition upperCaseAfterSplit() {
return split()
.transform("payload.toUpperCase()");
}
public CustomIntegrationFlowDefinition customAggregate(Consumer<CustomAggregatorSpec> aggregator) {
return register(new CustomAggregatorSpec(), aggregator);
}
}
public static class CustomAggregatorSpec extends AggregatorSpec {
CustomAggregatorSpec() {
outputProcessor((group) ->
group.getMessages()
.stream()
.map(Message::getPayload)
.map(String.class::cast)
.collect(Collectors.joining(", ")));
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,11 +34,11 @@ import com.rometools.rome.io.SyndFeedInput;
*/
public class FeedEntryMessageSourceSpec extends MessageSourceSpec<FeedEntryMessageSourceSpec, FeedEntryMessageSource> {
FeedEntryMessageSourceSpec(URL feedUrl, String metadataKey) {
protected FeedEntryMessageSourceSpec(URL feedUrl, String metadataKey) {
this.target = new FeedEntryMessageSource(feedUrl, metadataKey);
}
FeedEntryMessageSourceSpec(Resource feedResource, String metadataKey) {
protected FeedEntryMessageSourceSpec(Resource feedResource, String metadataKey) {
this.target = new FeedEntryMessageSource(feedResource, metadataKey);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ public class FileInboundChannelAdapterSpec
extends MessageSourceSpec<FileInboundChannelAdapterSpec, FileReadingMessageSource>
implements ComponentsRegistration {
private final FileListFilterFactoryBean fileListFilterFactoryBean = new FileListFilterFactoryBean();
protected final FileListFilterFactoryBean fileListFilterFactoryBean = new FileListFilterFactoryBean(); // NOSONAR
private FileLocker locker;
@@ -56,11 +56,11 @@ public class FileInboundChannelAdapterSpec
private boolean filtersSet;
FileInboundChannelAdapterSpec() {
protected FileInboundChannelAdapterSpec() {
this.target = new FileReadingMessageSource();
}
FileInboundChannelAdapterSpec(Comparator<File> receptionOrderComparator) {
protected FileInboundChannelAdapterSpec(Comparator<File> receptionOrderComparator) {
this.target = new FileReadingMessageSource(receptionOrderComparator);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -45,15 +45,15 @@ public class FileSplitterSpec extends MessageHandlerSpec<FileSplitterSpec, FileS
private String firstLineHeaderName;
FileSplitterSpec() {
protected FileSplitterSpec() {
this(true);
}
FileSplitterSpec(boolean iterator) {
protected FileSplitterSpec(boolean iterator) {
this(iterator, false);
}
FileSplitterSpec(boolean iterator, boolean markers) {
protected FileSplitterSpec(boolean iterator, boolean markers) {
this.iterator = iterator;
this.markers = markers;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -49,19 +49,19 @@ public class FileWritingMessageHandlerSpec
private DefaultFileNameGenerator defaultFileNameGenerator;
FileWritingMessageHandlerSpec(File destinationDirectory) {
protected FileWritingMessageHandlerSpec(File destinationDirectory) {
this.target = new FileWritingMessageHandler(destinationDirectory);
}
FileWritingMessageHandlerSpec(String directoryExpression) {
protected FileWritingMessageHandlerSpec(String directoryExpression) {
this(PARSER.parseExpression(directoryExpression));
}
<P> FileWritingMessageHandlerSpec(Function<Message<P>, ?> directoryFunction) {
protected <P> FileWritingMessageHandlerSpec(Function<Message<P>, ?> directoryFunction) {
this(new FunctionExpression<>(directoryFunction));
}
FileWritingMessageHandlerSpec(Expression directoryExpression) {
protected FileWritingMessageHandlerSpec(Expression directoryExpression) {
this.target = new FileWritingMessageHandler(directoryExpression);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,12 +43,12 @@ public class TailAdapterSpec extends MessageProducerSpec<TailAdapterSpec, FileTa
private MessageChannel errorChannel;
TailAdapterSpec() {
protected TailAdapterSpec() {
super(null);
this.factoryBean.setBeanFactory(new DefaultListableBeanFactory());
}
TailAdapterSpec file(File file) {
protected TailAdapterSpec file(File file) {
Assert.notNull(file, "'file' cannot be null");
this.factoryBean.setFile(file);
return _this();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2020 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.
@@ -44,7 +44,7 @@ public class FtpInboundChannelAdapterSpec
extends RemoteFileInboundChannelAdapterSpec<FTPFile, FtpInboundChannelAdapterSpec,
FtpInboundFileSynchronizingMessageSource> {
FtpInboundChannelAdapterSpec(SessionFactory<FTPFile> sessionFactory, Comparator<File> comparator) {
protected FtpInboundChannelAdapterSpec(SessionFactory<FTPFile> sessionFactory, Comparator<File> comparator) {
super(new FtpInboundFileSynchronizer(sessionFactory));
this.target = new FtpInboundFileSynchronizingMessageSource(this.synchronizer, comparator);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,15 +34,15 @@ import org.springframework.integration.ftp.outbound.FtpMessageHandler;
*/
public class FtpMessageHandlerSpec extends FileTransferringMessageHandlerSpec<FTPFile, FtpMessageHandlerSpec> {
FtpMessageHandlerSpec(SessionFactory<FTPFile> sessionFactory) {
protected FtpMessageHandlerSpec(SessionFactory<FTPFile> sessionFactory) {
this.target = new FtpMessageHandler(sessionFactory);
}
FtpMessageHandlerSpec(RemoteFileTemplate<FTPFile> remoteFileTemplate) {
protected FtpMessageHandlerSpec(RemoteFileTemplate<FTPFile> remoteFileTemplate) {
this.target = new FtpMessageHandler(remoteFileTemplate.getSessionFactory());
}
FtpMessageHandlerSpec(RemoteFileTemplate<FTPFile> remoteFileTemplate, FileExistsMode fileExistsMode) {
protected FtpMessageHandlerSpec(RemoteFileTemplate<FTPFile> remoteFileTemplate, FileExistsMode fileExistsMode) {
this.target = new FtpMessageHandler(remoteFileTemplate, fileExistsMode);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ import org.springframework.messaging.Message;
*/
public class FtpOutboundGatewaySpec extends RemoteFileOutboundGatewaySpec<FTPFile, FtpOutboundGatewaySpec> {
FtpOutboundGatewaySpec(FtpOutboundGateway outboundGateway) {
protected FtpOutboundGatewaySpec(FtpOutboundGateway outboundGateway) {
super(outboundGateway);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,18 +31,20 @@ import org.springframework.integration.ftp.inbound.FtpStreamingMessageSource;
import org.springframework.integration.metadata.SimpleMetadataStore;
/**
* A {@link RemoteFileStreamingInboundChannelAdapterSpec} for a
* {@link FtpStreamingMessageSource}.
* A {@link RemoteFileStreamingInboundChannelAdapterSpec} for a {@link FtpStreamingMessageSource}.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*/
public class FtpStreamingInboundChannelAdapterSpec
extends RemoteFileStreamingInboundChannelAdapterSpec<FTPFile, FtpStreamingInboundChannelAdapterSpec,
FtpStreamingMessageSource> {
FtpStreamingInboundChannelAdapterSpec(RemoteFileTemplate<FTPFile> remoteFileTemplate,
protected FtpStreamingInboundChannelAdapterSpec(RemoteFileTemplate<FTPFile> remoteFileTemplate,
Comparator<FTPFile> comparator) {
this.target = new FtpStreamingMessageSource(remoteFileTemplate, comparator);
}
@@ -68,7 +70,6 @@ public class FtpStreamingInboundChannelAdapterSpec
return filter(composeFilters(new FtpRegexPatternFileListFilter(regex)));
}
@SuppressWarnings("unchecked")
private CompositeFileListFilter<FTPFile> composeFilters(FileListFilter<FTPFile> fileListFilter) {
CompositeFileListFilter<FTPFile> compositeFileListFilter = new CompositeFileListFilter<>();
compositeFileListFilter.addFilters(fileListFilter,

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ public abstract class BaseHttpInboundEndpointSpec<S extends BaseHttpInboundEndpo
E extends HttpRequestHandlingEndpointSupport>
extends HttpInboundEndpointSupportSpec<S, E> {
BaseHttpInboundEndpointSpec(E endpoint, String... path) {
protected BaseHttpInboundEndpointSpec(E endpoint, String... path) {
super(endpoint, path);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import org.springframework.integration.http.inbound.HttpRequestHandlingControlle
public class HttpControllerEndpointSpec
extends BaseHttpInboundEndpointSpec<HttpControllerEndpointSpec, HttpRequestHandlingController> {
HttpControllerEndpointSpec(HttpRequestHandlingController controller, String... path) {
protected HttpControllerEndpointSpec(HttpRequestHandlingController controller, String... path) {
super(controller, path);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -45,15 +45,15 @@ public class HttpMessageHandlerSpec
private final RestTemplate restTemplate;
HttpMessageHandlerSpec(URI uri, RestTemplate restTemplate) {
protected HttpMessageHandlerSpec(URI uri, RestTemplate restTemplate) {
this(new ValueExpression<>(uri), restTemplate);
}
HttpMessageHandlerSpec(String uri, RestTemplate restTemplate) {
protected HttpMessageHandlerSpec(String uri, RestTemplate restTemplate) {
this(new LiteralExpression(uri), restTemplate);
}
HttpMessageHandlerSpec(Expression uriExpression, RestTemplate restTemplate) {
protected HttpMessageHandlerSpec(Expression uriExpression, RestTemplate restTemplate) {
super(new HttpRequestExecutingMessageHandler(uriExpression, restTemplate));
this.restTemplate = restTemplate;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,7 +30,7 @@ import org.springframework.integration.http.inbound.HttpRequestHandlingMessaging
public class HttpRequestHandlerEndpointSpec
extends BaseHttpInboundEndpointSpec<HttpRequestHandlerEndpointSpec, HttpRequestHandlingMessagingGateway> {
HttpRequestHandlerEndpointSpec(HttpRequestHandlingMessagingGateway endpoint, String... path) {
protected HttpRequestHandlerEndpointSpec(HttpRequestHandlingMessagingGateway endpoint, String... path) {
super(endpoint, path);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -28,10 +28,13 @@ import org.springframework.integration.ip.tcp.connection.TcpSocketSupport;
/**
* An {@link IntegrationComponentSpec} for {@link AbstractConnectionFactory}s.
*
* @param <S> the target {@link AbstractConnectionFactorySpec} implementation type.
* @param <C> the target {@link AbstractConnectionFactory} implementation type.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*
*/
@@ -39,7 +42,7 @@ public abstract class AbstractConnectionFactorySpec
<S extends AbstractConnectionFactorySpec<S, C>, C extends AbstractConnectionFactory>
extends IntegrationComponentSpec<S, C> {
AbstractConnectionFactorySpec(C connectionFactory) {
protected AbstractConnectionFactorySpec(C connectionFactory) {
this.target = connectionFactory;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.Message;
* @param <S> the target {@link AbstractUdpOutboundChannelAdapterSpec} implementation type.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*
@@ -44,11 +45,11 @@ public abstract class AbstractUdpOutboundChannelAdapterSpec<S extends AbstractUd
this.target = new UnicastSendingMessageHandler(host, port);
}
AbstractUdpOutboundChannelAdapterSpec(String destinationExpression) {
protected AbstractUdpOutboundChannelAdapterSpec(String destinationExpression) {
this.target = new UnicastSendingMessageHandler(destinationExpression);
}
AbstractUdpOutboundChannelAdapterSpec(Function<Message<?>, ?> destinationFunction) {
protected AbstractUdpOutboundChannelAdapterSpec(Function<Message<?>, ?> destinationFunction) {
this.target = new UnicastSendingMessageHandler(new FunctionExpression<>(destinationFunction));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -22,7 +22,9 @@ import org.springframework.integration.ip.tcp.connection.TcpNioClientConnectionF
/**
* An {@link AbstractConnectionFactorySpec} for {@link AbstractClientConnectionFactory}s.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*
@@ -30,11 +32,11 @@ import org.springframework.integration.ip.tcp.connection.TcpNioClientConnectionF
public class TcpClientConnectionFactorySpec
extends AbstractConnectionFactorySpec<TcpClientConnectionFactorySpec, AbstractClientConnectionFactory> {
TcpClientConnectionFactorySpec(String host, int port) {
protected TcpClientConnectionFactorySpec(String host, int port) {
this(host, port, false);
}
TcpClientConnectionFactorySpec(String host, int port, boolean nio) {
protected TcpClientConnectionFactorySpec(String host, int port, boolean nio) {
super(nio ? new TcpNioClientConnectionFactory(host, port) : new TcpNetClientConnectionFactory(host, port));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,13 +38,13 @@ public class TcpInboundChannelAdapterSpec
extends MessageProducerSpec<TcpInboundChannelAdapterSpec, TcpReceivingChannelAdapter>
implements ComponentsRegistration {
private final AbstractConnectionFactory connectionFactory;
protected final AbstractConnectionFactory connectionFactory; // NOSONAR - final
/**
* Construct an instance using an existing spring-managed connection factory.
* @param connectionFactoryBean the spring-managed bean.
*/
TcpInboundChannelAdapterSpec(AbstractConnectionFactory connectionFactoryBean) {
protected TcpInboundChannelAdapterSpec(AbstractConnectionFactory connectionFactoryBean) {
super(new TcpReceivingChannelAdapter());
this.connectionFactory = null;
this.target.setConnectionFactory(connectionFactoryBean);
@@ -54,7 +54,7 @@ public class TcpInboundChannelAdapterSpec
* Construct an instance using the provided connection factory spec.
* @param connectionFactorySpec the spec.
*/
TcpInboundChannelAdapterSpec(AbstractConnectionFactorySpec<?, ?> connectionFactorySpec) {
protected TcpInboundChannelAdapterSpec(AbstractConnectionFactorySpec<?, ?> connectionFactorySpec) {
super(new TcpReceivingChannelAdapter());
this.connectionFactory = connectionFactorySpec.get();
this.target.setConnectionFactory(this.connectionFactory);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,13 +37,13 @@ import org.springframework.scheduling.TaskScheduler;
public class TcpInboundGatewaySpec extends MessagingGatewaySpec<TcpInboundGatewaySpec, TcpInboundGateway>
implements ComponentsRegistration {
private final AbstractConnectionFactory connectionFactory;
protected final AbstractConnectionFactory connectionFactory; // NOSONAR - final
/**
* Construct an instance using an existing spring-managed connection factory.
* @param connectionFactoryBean the spring-managed bean.
*/
TcpInboundGatewaySpec(AbstractConnectionFactory connectionFactoryBean) {
protected TcpInboundGatewaySpec(AbstractConnectionFactory connectionFactoryBean) {
super(new TcpInboundGateway());
this.connectionFactory = null;
this.target.setConnectionFactory(connectionFactoryBean);
@@ -53,7 +53,7 @@ public class TcpInboundGatewaySpec extends MessagingGatewaySpec<TcpInboundGatewa
* Construct an instance using a connection factory spec.
* @param connectionFactorySpec the spec.
*/
TcpInboundGatewaySpec(AbstractConnectionFactorySpec<?, ?> connectionFactorySpec) {
protected TcpInboundGatewaySpec(AbstractConnectionFactorySpec<?, ?> connectionFactorySpec) {
super(new TcpInboundGateway());
this.connectionFactory = connectionFactorySpec.get();
this.target.setConnectionFactory(this.connectionFactory);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,13 +38,13 @@ public class TcpOutboundChannelAdapterSpec
extends MessageHandlerSpec<TcpOutboundChannelAdapterSpec, TcpSendingMessageHandler>
implements ComponentsRegistration {
private final AbstractConnectionFactory connectionFactory;
protected final AbstractConnectionFactory connectionFactory; // NOSONAR - final
/**
* Construct an instance using an existing spring-managed connection factory.
* @param connectionFactoryBean the spring-managed bean.
*/
TcpOutboundChannelAdapterSpec(AbstractConnectionFactory connectionFactoryBean) {
protected TcpOutboundChannelAdapterSpec(AbstractConnectionFactory connectionFactoryBean) {
this.target = new TcpSendingMessageHandler();
this.connectionFactory = null;
this.target.setConnectionFactory(connectionFactoryBean);
@@ -54,7 +54,7 @@ public class TcpOutboundChannelAdapterSpec
* Construct an instance using the provided connection factory spec.
* @param connectionFactorySpec the spec.
*/
TcpOutboundChannelAdapterSpec(AbstractConnectionFactorySpec<?, ?> connectionFactorySpec) {
protected TcpOutboundChannelAdapterSpec(AbstractConnectionFactorySpec<?, ?> connectionFactorySpec) {
this.target = new TcpSendingMessageHandler();
this.connectionFactory = connectionFactorySpec.get();
this.target.setConnectionFactory(this.connectionFactory);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ import org.springframework.messaging.Message;
public class TcpOutboundGatewaySpec extends MessageHandlerSpec<TcpOutboundGatewaySpec, TcpOutboundGateway>
implements ComponentsRegistration {
private final AbstractClientConnectionFactory connectionFactory;
protected final AbstractClientConnectionFactory connectionFactory; // NOSONAR - final
/**
* Construct an instance using an existing spring-managed connection factory.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -22,7 +22,9 @@ import org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionF
/**
* An {@link AbstractConnectionFactorySpec} for {@link AbstractServerConnectionFactory}s.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*
@@ -30,11 +32,11 @@ import org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionF
public class TcpServerConnectionFactorySpec
extends AbstractConnectionFactorySpec<TcpServerConnectionFactorySpec, AbstractServerConnectionFactory> {
TcpServerConnectionFactorySpec(int port) {
protected TcpServerConnectionFactorySpec(int port) {
this(port, false);
}
TcpServerConnectionFactorySpec(int port, boolean nio) {
protected TcpServerConnectionFactorySpec(int port, boolean nio) {
super(nio ? new TcpNioServerConnectionFactory(port) : new TcpNetServerConnectionFactory(port));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -28,17 +28,18 @@ import org.springframework.scheduling.TaskScheduler;
* A {@link MessageProducerSpec} for {@link UnicastReceivingChannelAdapter}s.
*
* @author Gary Russell
*
* @since 5.0
*
*/
public class UdpInboundChannelAdapterSpec
extends MessageProducerSpec<UdpInboundChannelAdapterSpec, UnicastReceivingChannelAdapter> {
UdpInboundChannelAdapterSpec(int port) {
protected UdpInboundChannelAdapterSpec(int port) {
super(new UnicastReceivingChannelAdapter(port));
}
UdpInboundChannelAdapterSpec(int port, String multicastGroup) {
protected UdpInboundChannelAdapterSpec(int port, String multicastGroup) {
super(new MulticastReceivingChannelAdapter(multicastGroup, port));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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,21 +27,23 @@ import org.springframework.messaging.Message;
* {@link MulticastSendingMessageHandler}s.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*
*/
public class UdpMulticastOutboundChannelAdapterSpec
extends AbstractUdpOutboundChannelAdapterSpec<UdpMulticastOutboundChannelAdapterSpec> {
UdpMulticastOutboundChannelAdapterSpec(String host, int port) {
protected UdpMulticastOutboundChannelAdapterSpec(String host, int port) {
this.target = new MulticastSendingMessageHandler(host, port);
}
UdpMulticastOutboundChannelAdapterSpec(String destinationExpression) {
protected UdpMulticastOutboundChannelAdapterSpec(String destinationExpression) {
this.target = new MulticastSendingMessageHandler(destinationExpression);
}
UdpMulticastOutboundChannelAdapterSpec(Function<Message<?>, ?> destinationFunction) {
protected UdpMulticastOutboundChannelAdapterSpec(Function<Message<?>, ?> destinationFunction) {
this.target = new MulticastSendingMessageHandler(new FunctionExpression<>(destinationFunction));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -25,21 +25,23 @@ import org.springframework.messaging.Message;
* {@link org.springframework.integration.ip.udp.UnicastSendingMessageHandler}s.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.0
*
*/
public class UdpUnicastOutboundChannelAdapterSpec
extends AbstractUdpOutboundChannelAdapterSpec<UdpUnicastOutboundChannelAdapterSpec> {
UdpUnicastOutboundChannelAdapterSpec(String host, int port) {
protected UdpUnicastOutboundChannelAdapterSpec(String host, int port) {
super(host, port);
}
UdpUnicastOutboundChannelAdapterSpec(Function<Message<?>, ?> destinationFunction) {
protected UdpUnicastOutboundChannelAdapterSpec(Function<Message<?>, ?> destinationFunction) {
super(destinationFunction);
}
UdpUnicastOutboundChannelAdapterSpec(String destinationExpression) {
protected UdpUnicastOutboundChannelAdapterSpec(String destinationExpression) {
super(destinationExpression);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +31,7 @@ import org.springframework.util.backoff.BackOff;
public class JmsDefaultListenerContainerSpec
extends JmsListenerContainerSpec<JmsDefaultListenerContainerSpec, DefaultMessageListenerContainer> {
JmsDefaultListenerContainerSpec() {
protected JmsDefaultListenerContainerSpec() {
super(DefaultMessageListenerContainer.class);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ public abstract class JmsDestinationAccessorSpec<S extends JmsDestinationAccesso
this.target = accessor;
}
S connectionFactory(ConnectionFactory connectionFactory) {
protected S connectionFactory(ConnectionFactory connectionFactory) {
this.target.setConnectionFactory(connectionFactory);
return _this();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -44,7 +44,7 @@ public class JmsInboundChannelAdapterSpec<S extends JmsInboundChannelAdapterSpec
protected final JmsTemplateSpec jmsTemplateSpec = new JmsTemplateSpec(); // NOSONAR final
JmsInboundChannelAdapterSpec(JmsTemplate jmsTemplate) {
protected JmsInboundChannelAdapterSpec(JmsTemplate jmsTemplate) {
this.target = new JmsDestinationPollingSource(jmsTemplate);
}
@@ -100,7 +100,7 @@ public class JmsInboundChannelAdapterSpec<S extends JmsInboundChannelAdapterSpec
extends JmsInboundChannelAdapterSpec<JmsInboundChannelSpecTemplateAware>
implements ComponentsRegistration {
JmsInboundChannelSpecTemplateAware(ConnectionFactory connectionFactory) {
protected JmsInboundChannelSpecTemplateAware(ConnectionFactory connectionFactory) {
super(connectionFactory);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +42,7 @@ import org.springframework.util.Assert;
public class JmsInboundGatewaySpec<S extends JmsInboundGatewaySpec<S>>
extends MessagingGatewaySpec<S, JmsInboundGateway> {
JmsInboundGatewaySpec(AbstractMessageListenerContainer listenerContainer) {
protected JmsInboundGatewaySpec(AbstractMessageListenerContainer listenerContainer) {
super(new JmsInboundGateway(listenerContainer, new ChannelPublishingJmsMessageListener()));
this.target.getListener().setExpectReply(true);
}
@@ -202,7 +202,7 @@ public class JmsInboundGatewaySpec<S extends JmsInboundGatewaySpec<S>>
private final S spec;
JmsInboundGatewayListenerContainerSpec(S spec) {
protected JmsInboundGatewayListenerContainerSpec(S spec) {
super(spec.get());
this.spec = spec;
this.spec.get().setAutoStartup(false);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ import org.springframework.util.ErrorHandler;
public class JmsListenerContainerSpec<S extends JmsListenerContainerSpec<S, C>, C extends AbstractMessageListenerContainer>
extends JmsDestinationAccessorSpec<S, C> {
JmsListenerContainerSpec(Class<C> aClass) {
protected JmsListenerContainerSpec(Class<C> aClass) {
super(newInstance(aClass));
if (DefaultMessageListenerContainer.class.isAssignableFrom(aClass)) {
this.target.setSessionTransacted(true);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@ import org.springframework.util.ErrorHandler;
*/
public class JmsMessageChannelSpec<S extends JmsMessageChannelSpec<S>> extends JmsPollableMessageChannelSpec<S> {
JmsMessageChannelSpec(ConnectionFactory connectionFactory) {
protected JmsMessageChannelSpec(ConnectionFactory connectionFactory) {
super(new JmsChannelFactoryBean(true), connectionFactory);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -44,7 +44,7 @@ import org.springframework.util.Assert;
public class JmsMessageDrivenChannelAdapterSpec<S extends JmsMessageDrivenChannelAdapterSpec<S>>
extends MessageProducerSpec<S, JmsMessageDrivenEndpoint> {
JmsMessageDrivenChannelAdapterSpec(AbstractMessageListenerContainer listenerContainer) {
protected JmsMessageDrivenChannelAdapterSpec(AbstractMessageListenerContainer listenerContainer) {
super(new JmsMessageDrivenEndpoint(listenerContainer, new ChannelPublishingJmsMessageListener()));
this.target.getListener().setExpectReply(false);
}
@@ -105,7 +105,7 @@ public class JmsMessageDrivenChannelAdapterSpec<S extends JmsMessageDrivenChanne
private final S spec;
JmsMessageDrivenChannelAdapterListenerContainerSpec(S spec) {
protected JmsMessageDrivenChannelAdapterListenerContainerSpec(S spec) {
super(spec.get());
this.spec = spec;
this.spec.get().setAutoStartup(false);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,7 @@ public class JmsOutboundChannelAdapterSpec<S extends JmsOutboundChannelAdapterSp
protected final JmsTemplateSpec jmsTemplateSpec = new JmsTemplateSpec(); // NOSONAR final
JmsOutboundChannelAdapterSpec(JmsTemplate jmsTemplate) {
protected JmsOutboundChannelAdapterSpec(JmsTemplate jmsTemplate) {
this.target = new JmsSendingMessageHandler(jmsTemplate);
}
@@ -182,7 +182,7 @@ public class JmsOutboundChannelAdapterSpec<S extends JmsOutboundChannelAdapterSp
extends JmsOutboundChannelAdapterSpec<JmsOutboundChannelSpecTemplateAware>
implements ComponentsRegistration {
JmsOutboundChannelSpecTemplateAware(ConnectionFactory connectionFactory) {
protected JmsOutboundChannelSpecTemplateAware(ConnectionFactory connectionFactory) {
super(connectionFactory);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ import org.springframework.util.Assert;
*/
public class JmsOutboundGatewaySpec extends MessageHandlerSpec<JmsOutboundGatewaySpec, JmsOutboundGateway> {
JmsOutboundGatewaySpec(ConnectionFactory connectionFactory) {
protected JmsOutboundGatewaySpec(ConnectionFactory connectionFactory) {
this.target = new JmsOutboundGateway();
this.target.setConnectionFactory(connectionFactory);
this.target.setRequiresReply(true);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,13 +41,15 @@ import org.springframework.lang.Nullable;
public class JmsPollableMessageChannelSpec<S extends JmsPollableMessageChannelSpec<S>>
extends MessageChannelSpec<S, AbstractJmsChannel> {
protected final JmsChannelFactoryBean jmsChannelFactoryBean; // NOSONAR final
protected final JmsChannelFactoryBean jmsChannelFactoryBean; // NOSONAR - final
JmsPollableMessageChannelSpec(ConnectionFactory connectionFactory) {
protected JmsPollableMessageChannelSpec(ConnectionFactory connectionFactory) {
this(new JmsChannelFactoryBean(false), connectionFactory);
}
JmsPollableMessageChannelSpec(JmsChannelFactoryBean jmsChannelFactoryBean, ConnectionFactory connectionFactory) {
protected JmsPollableMessageChannelSpec(JmsChannelFactoryBean jmsChannelFactoryBean,
ConnectionFactory connectionFactory) {
this.jmsChannelFactoryBean = jmsChannelFactoryBean;
this.jmsChannelFactoryBean.setConnectionFactory(connectionFactory);
this.jmsChannelFactoryBean.setSingleton(false);
@@ -95,9 +97,8 @@ public class JmsPollableMessageChannelSpec<S extends JmsPollableMessageChannelSp
/**
* Configure a message selector in the
* {@link org.springframework.jms.listener.DefaultMessageListenerContainer} (when
* message driven) or the {@link org.springframework.jms.core.JmsTemplate} (when
* polled).
* {@link org.springframework.jms.listener.DefaultMessageListenerContainer} (when message driven)
* or the {@link org.springframework.jms.core.JmsTemplate} (when polled).
* @param messageSelector the messageSelector.
* @return the current {@link MessageChannelSpec}.
* @see org.springframework.jms.listener.DefaultMessageListenerContainer#setMessageSelector(String)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -28,7 +28,7 @@ import javax.jms.ConnectionFactory;
public class JmsPublishSubscribeMessageChannelSpec
extends JmsMessageChannelSpec<JmsPublishSubscribeMessageChannelSpec> {
JmsPublishSubscribeMessageChannelSpec(ConnectionFactory connectionFactory) {
protected JmsPublishSubscribeMessageChannelSpec(ConnectionFactory connectionFactory) {
super(connectionFactory);
this.jmsChannelFactoryBean.setPubSubDomain(true);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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,7 +27,7 @@ import org.springframework.jms.support.converter.MessageConverter;
*/
public class JmsTemplateSpec extends JmsDestinationAccessorSpec<JmsTemplateSpec, DynamicJmsTemplate> {
JmsTemplateSpec() {
protected JmsTemplateSpec() {
super(new DynamicJmsTemplate());
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,9 +38,9 @@ public class JpaInboundChannelAdapterSpec
extends MessageSourceSpec<JpaInboundChannelAdapterSpec, JpaPollingChannelAdapter>
implements ComponentsRegistration {
private final JpaExecutor jpaExecutor;
protected final JpaExecutor jpaExecutor; // NOSONAR - final
JpaInboundChannelAdapterSpec(JpaExecutor jpaExecutor) {
protected JpaInboundChannelAdapterSpec(JpaExecutor jpaExecutor) {
this.jpaExecutor = jpaExecutor;
this.target = new JpaPollingChannelAdapter(this.jpaExecutor);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -32,7 +32,7 @@ import org.springframework.integration.jpa.support.OutboundGatewayType;
*/
public class JpaRetrievingOutboundGatewaySpec extends JpaBaseOutboundEndpointSpec<JpaRetrievingOutboundGatewaySpec> {
JpaRetrievingOutboundGatewaySpec(JpaExecutor jpaExecutor) {
protected JpaRetrievingOutboundGatewaySpec(JpaExecutor jpaExecutor) {
super(jpaExecutor);
this.target.setGatewayType(OutboundGatewayType.RETRIEVING);
this.target.setRequiresReply(true);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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,11 +30,11 @@ import org.springframework.integration.jpa.support.PersistMode;
*/
public class JpaUpdatingOutboundEndpointSpec extends JpaBaseOutboundEndpointSpec<JpaUpdatingOutboundEndpointSpec> {
JpaUpdatingOutboundEndpointSpec(JpaExecutor jpaExecutor) {
protected JpaUpdatingOutboundEndpointSpec(JpaExecutor jpaExecutor) {
super(jpaExecutor);
}
JpaUpdatingOutboundEndpointSpec producesReply(boolean producesReply) {
protected JpaUpdatingOutboundEndpointSpec producesReply(boolean producesReply) {
this.target.setProducesReply(producesReply);
if (producesReply) {
this.target.setRequiresReply(true);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -59,9 +59,9 @@ public class ImapIdleChannelAdapterSpec
extends MessageProducerSpec<ImapIdleChannelAdapterSpec, ImapIdleChannelAdapter>
implements ComponentsRegistration {
private final ImapMailReceiver receiver;
protected final ImapMailReceiver receiver; // NOSONAR - final
private final Map<Object, String> componentsToRegister = new LinkedHashMap<>();
protected final Map<Object, String> componentsToRegister = new LinkedHashMap<>(); // NOSONAR - final
private final List<Advice> adviceChain = new LinkedList<>();
@@ -69,11 +69,11 @@ public class ImapIdleChannelAdapterSpec
private boolean sessionProvided;
ImapIdleChannelAdapterSpec(ImapMailReceiver receiver) {
protected ImapIdleChannelAdapterSpec(ImapMailReceiver receiver) {
this(receiver, false);
}
ImapIdleChannelAdapterSpec(ImapMailReceiver receiver, boolean externalReceiver) {
protected ImapIdleChannelAdapterSpec(ImapMailReceiver receiver, boolean externalReceiver) {
super(new ImapIdleChannelAdapter(receiver));
this.target.setAdviceChain(this.adviceChain);
this.receiver = receiver;

View File

@@ -30,15 +30,15 @@ import org.springframework.integration.mail.SearchTermStrategy;
public class ImapMailInboundChannelAdapterSpec
extends MailInboundChannelAdapterSpec<ImapMailInboundChannelAdapterSpec, ImapMailReceiver> {
ImapMailInboundChannelAdapterSpec() {
protected ImapMailInboundChannelAdapterSpec() {
super(new ImapMailReceiver());
}
ImapMailInboundChannelAdapterSpec(ImapMailReceiver imapMailReceiver) {
protected ImapMailInboundChannelAdapterSpec(ImapMailReceiver imapMailReceiver) {
super(imapMailReceiver, true);
}
ImapMailInboundChannelAdapterSpec(String url) {
protected ImapMailInboundChannelAdapterSpec(String url) {
super(new ImapMailReceiver(url), false);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2020 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,9 +36,9 @@ import org.springframework.mail.javamail.JavaMailSenderImpl;
public class MailSendingMessageHandlerSpec
extends MessageHandlerSpec<MailSendingMessageHandlerSpec, MailSendingMessageHandler> {
private final JavaMailSenderImpl sender = new JavaMailSenderImpl();
protected final JavaMailSenderImpl sender = new JavaMailSenderImpl(); // NOSONAR - final
MailSendingMessageHandlerSpec(@Nullable String host) {
protected MailSendingMessageHandlerSpec(@Nullable String host) {
this.sender.setHost(host);
this.target = new MailSendingMessageHandler(this.sender);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2020 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.
@@ -28,23 +28,23 @@ import org.springframework.integration.mail.Pop3MailReceiver;
public class Pop3MailInboundChannelAdapterSpec
extends MailInboundChannelAdapterSpec<Pop3MailInboundChannelAdapterSpec, Pop3MailReceiver> {
Pop3MailInboundChannelAdapterSpec() {
protected Pop3MailInboundChannelAdapterSpec() {
super(new Pop3MailReceiver());
}
Pop3MailInboundChannelAdapterSpec(Pop3MailReceiver receiver) {
protected Pop3MailInboundChannelAdapterSpec(Pop3MailReceiver receiver) {
super(receiver, true);
}
Pop3MailInboundChannelAdapterSpec(String url) {
protected Pop3MailInboundChannelAdapterSpec(String url) {
super(new Pop3MailReceiver(url));
}
Pop3MailInboundChannelAdapterSpec(String host, String username, String password) {
protected Pop3MailInboundChannelAdapterSpec(String host, String username, String password) {
super(new Pop3MailReceiver(host, username, password));
}
Pop3MailInboundChannelAdapterSpec(String host, int port, String username, String password) {
protected Pop3MailInboundChannelAdapterSpec(String host, int port, String username, String password) {
super(new Pop3MailReceiver(host, port, username, password));
}

View File

@@ -40,12 +40,12 @@ import org.springframework.messaging.Message;
public class MongoDbOutboundGatewaySpec
extends MessageHandlerSpec<MongoDbOutboundGatewaySpec, MongoDbOutboundGateway> {
MongoDbOutboundGatewaySpec(MongoDatabaseFactory mongoDbFactory, MongoConverter mongoConverter) {
protected MongoDbOutboundGatewaySpec(MongoDatabaseFactory mongoDbFactory, MongoConverter mongoConverter) {
this.target = new MongoDbOutboundGateway(mongoDbFactory, mongoConverter);
this.target.setRequiresReply(true);
}
MongoDbOutboundGatewaySpec(MongoOperations mongoTemplate) {
protected MongoDbOutboundGatewaySpec(MongoOperations mongoTemplate) {
this.target = new MongoDbOutboundGateway(mongoTemplate);
this.target.setRequiresReply(true);
}

View File

@@ -44,13 +44,13 @@ public class ReactiveMongoDbMessageHandlerSpec
extends MessageHandlerSpec<ReactiveMongoDbMessageHandlerSpec, ReactiveMessageHandlerAdapter>
implements ComponentsRegistration {
private final ReactiveMongoDbStoringMessageHandler messageHandler;
protected final ReactiveMongoDbStoringMessageHandler messageHandler; // NOSONAR - final
ReactiveMongoDbMessageHandlerSpec(ReactiveMongoDatabaseFactory mongoDbFactory) {
protected ReactiveMongoDbMessageHandlerSpec(ReactiveMongoDatabaseFactory mongoDbFactory) {
this(new ReactiveMongoDbStoringMessageHandler(mongoDbFactory));
}
ReactiveMongoDbMessageHandlerSpec(ReactiveMongoOperations reactiveMongoOperations) {
protected ReactiveMongoDbMessageHandlerSpec(ReactiveMongoOperations reactiveMongoOperations) {
this(new ReactiveMongoDbStoringMessageHandler(reactiveMongoOperations));
}

View File

@@ -37,12 +37,15 @@ import org.springframework.integration.mongodb.inbound.ReactiveMongoDbMessageSou
public class ReactiveMongoDbMessageSourceSpec
extends MessageSourceSpec<ReactiveMongoDbMessageSourceSpec, ReactiveMongoDbMessageSource> {
ReactiveMongoDbMessageSourceSpec(ReactiveMongoDatabaseFactory reactiveMongoDatabaseFactory,
protected ReactiveMongoDbMessageSourceSpec(ReactiveMongoDatabaseFactory reactiveMongoDatabaseFactory,
Expression queryExpression) {
this.target = new ReactiveMongoDbMessageSource(reactiveMongoDatabaseFactory, queryExpression);
}
ReactiveMongoDbMessageSourceSpec(ReactiveMongoOperations reactiveMongoTemplate, Expression queryExpression) {
protected ReactiveMongoDbMessageSourceSpec(ReactiveMongoOperations reactiveMongoTemplate,
Expression queryExpression) {
this.target = new ReactiveMongoDbMessageSource(reactiveMongoTemplate, queryExpression);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 the original author or authors.
* Copyright 2019-2020 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.
@@ -32,7 +32,7 @@ import org.springframework.messaging.rsocket.RSocketStrategies;
*/
public class RSocketInboundGatewaySpec extends MessagingGatewaySpec<RSocketInboundGatewaySpec, RSocketInboundGateway> {
RSocketInboundGatewaySpec(String... path) {
protected RSocketInboundGatewaySpec(String... path) {
super(new RSocketInboundGateway(path));
}

View File

@@ -38,11 +38,11 @@ import org.springframework.util.MimeType;
*/
public class RSocketOutboundGatewaySpec extends MessageHandlerSpec<RSocketOutboundGatewaySpec, RSocketOutboundGateway> {
RSocketOutboundGatewaySpec(String route, Object... routeVariables) {
protected RSocketOutboundGatewaySpec(String route, Object... routeVariables) {
this.target = new RSocketOutboundGateway(route, routeVariables);
}
RSocketOutboundGatewaySpec(Expression routeExpression) {
protected RSocketOutboundGatewaySpec(Expression routeExpression) {
this.target = new RSocketOutboundGateway(routeExpression);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,7 +42,9 @@ public class SftpInboundChannelAdapterSpec
extends RemoteFileInboundChannelAdapterSpec<ChannelSftp.LsEntry, SftpInboundChannelAdapterSpec,
SftpInboundFileSynchronizingMessageSource> {
SftpInboundChannelAdapterSpec(SessionFactory<ChannelSftp.LsEntry> sessionFactory, Comparator<File> comparator) {
protected SftpInboundChannelAdapterSpec(SessionFactory<ChannelSftp.LsEntry> sessionFactory,
Comparator<File> comparator) {
super(new SftpInboundFileSynchronizer(sessionFactory));
this.target = new SftpInboundFileSynchronizingMessageSource(this.synchronizer, comparator);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -34,16 +34,20 @@ import com.jcraft.jsch.ChannelSftp;
public class SftpMessageHandlerSpec
extends FileTransferringMessageHandlerSpec<ChannelSftp.LsEntry, SftpMessageHandlerSpec> {
SftpMessageHandlerSpec(SessionFactory<ChannelSftp.LsEntry> sessionFactory) {
protected SftpMessageHandlerSpec(SessionFactory<ChannelSftp.LsEntry> sessionFactory) {
this.target = new SftpMessageHandler(sessionFactory);
}
SftpMessageHandlerSpec(RemoteFileTemplate<ChannelSftp.LsEntry> remoteFileTemplate) {
protected SftpMessageHandlerSpec(RemoteFileTemplate<ChannelSftp.LsEntry> remoteFileTemplate) {
this.target = new SftpMessageHandler(remoteFileTemplate.getSessionFactory());
}
SftpMessageHandlerSpec(RemoteFileTemplate<ChannelSftp.LsEntry> remoteFileTemplate, FileExistsMode fileExistsMode) {
this.target = new SftpMessageHandler(new SftpRemoteFileTemplate(remoteFileTemplate.getSessionFactory()), fileExistsMode);
protected SftpMessageHandlerSpec(RemoteFileTemplate<ChannelSftp.LsEntry> remoteFileTemplate,
FileExistsMode fileExistsMode) {
this.target =
new SftpMessageHandler(new SftpRemoteFileTemplate(remoteFileTemplate.getSessionFactory()),
fileExistsMode);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2020 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.
@@ -26,13 +26,14 @@ import com.jcraft.jsch.ChannelSftp;
/**
* @author Artem Bilan
* @author Gary Russell
*
* @since 5.0
*/
public class SftpOutboundGatewaySpec
extends RemoteFileOutboundGatewaySpec<ChannelSftp.LsEntry, SftpOutboundGatewaySpec> {
SftpOutboundGatewaySpec(AbstractRemoteFileOutboundGateway<ChannelSftp.LsEntry> outboundGateway) {
protected SftpOutboundGatewaySpec(AbstractRemoteFileOutboundGateway<ChannelSftp.LsEntry> outboundGateway) {
super(outboundGateway);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2019 the original author or authors.
* Copyright 2016-2020 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.
@@ -32,6 +32,7 @@ import com.jcraft.jsch.ChannelSftp.LsEntry;
/**
* @author Gary Russell
*
* @since 5.0
*
*/
@@ -39,8 +40,9 @@ public class SftpStreamingInboundChannelAdapterSpec
extends RemoteFileStreamingInboundChannelAdapterSpec<LsEntry, SftpStreamingInboundChannelAdapterSpec,
SftpStreamingMessageSource> {
SftpStreamingInboundChannelAdapterSpec(RemoteFileTemplate<LsEntry> remoteFileTemplate,
protected SftpStreamingInboundChannelAdapterSpec(RemoteFileTemplate<LsEntry> remoteFileTemplate,
Comparator<LsEntry> comparator) {
this.target = new SftpStreamingMessageSource(remoteFileTemplate, comparator);
}
@@ -66,7 +68,6 @@ public class SftpStreamingInboundChannelAdapterSpec
return filter(composeFilters(new SftpRegexPatternFileListFilter(regex)));
}
@SuppressWarnings("unchecked")
private CompositeFileListFilter<LsEntry> composeFilters(FileListFilter<LsEntry> fileListFilter) {
CompositeFileListFilter<LsEntry> compositeFileListFilter = new CompositeFileListFilter<>();
compositeFileListFilter.addFilters(fileListFilter,

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2019 the original author or authors.
* Copyright 2017-2020 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.
@@ -32,7 +32,7 @@ import org.springframework.web.reactive.accept.RequestedContentTypeResolver;
public class WebFluxInboundEndpointSpec
extends HttpInboundEndpointSupportSpec<WebFluxInboundEndpointSpec, WebFluxInboundEndpoint> {
WebFluxInboundEndpointSpec(WebFluxInboundEndpoint gateway, String... path) {
protected WebFluxInboundEndpointSpec(WebFluxInboundEndpoint gateway, String... path) {
super(gateway, path);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2019 the original author or authors.
* Copyright 2017-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,17 +46,17 @@ import org.springframework.web.reactive.function.client.WebClient;
public class WebFluxMessageHandlerSpec
extends BaseHttpMessageHandlerSpec<WebFluxMessageHandlerSpec, WebFluxRequestExecutingMessageHandler> {
private final WebClient webClient;
protected final WebClient webClient; // NOSONAR - final
WebFluxMessageHandlerSpec(URI uri, WebClient webClient) {
protected WebFluxMessageHandlerSpec(URI uri, WebClient webClient) {
this(new ValueExpression<>(uri), webClient);
}
WebFluxMessageHandlerSpec(String uri, WebClient webClient) {
protected WebFluxMessageHandlerSpec(String uri, WebClient webClient) {
this(new LiteralExpression(uri), webClient);
}
WebFluxMessageHandlerSpec(Expression uriExpression, WebClient webClient) {
protected WebFluxMessageHandlerSpec(Expression uriExpression, WebClient webClient) {
super(new WebFluxRequestExecutingMessageHandler(uriExpression, webClient));
this.webClient = webClient;
}

View File

@@ -1202,3 +1202,63 @@ That `errorRecovererFlow` can be used as follows:
private Function<String, String> errorRecovererFlowGateway;
----
====
[[java-dsl-extensions]]
=== DSL Extensions
Starting with version 5.3, an `IntegrationFlowExtension` has been introduced to allow extension of the existing Java DSL with custom or composed EIP-operators.
All that is needed is an extension of this class that provides methods which can be used in the `IntegrationFlow` bean definitions.
The extension class can also be used for custom `IntegrationComponentSpec` configuration; for example, missed or default options can be implemented in the existing `IntegrationComponentSpec` extension.
The sample below demonstrates a composite custom operator and usage of an `AggregatorSpec` extension for a default custom `outputProcessor`:
====
[source,java]
----
public class CustomIntegrationFlowDefinition
extends IntegrationFlowExtension<CustomIntegrationFlowDefinition> {
public CustomIntegrationFlowDefinition upperCaseAfterSplit() {
return split()
.transform("payload.toUpperCase()");
}
public CustomIntegrationFlowDefinition customAggregate(Consumer<CustomAggregatorSpec> aggregator) {
return register(new CustomAggregatorSpec(), aggregator);
}
}
public class CustomAggregatorSpec extends AggregatorSpec {
CustomAggregatorSpec() {
outputProcessor(group ->
group.getMessages()
.stream()
.map(Message::getPayload)
.map(String.class::cast)
.collect(Collectors.joining(", ")));
}
}
----
====
For a method chain flow the new DSL operator in these extensions must return the extension class.
This way a target `IntegrationFlow` definition will work with new and existing DSL operators:
====
[source,java]
----
@Bean
public IntegrationFlow customFlowDefinition() {
return
new CustomIntegrationFlowDefinition()
.log()
.upperCaseAfterSplit()
.channel("innerChannel")
.customAggregate(customAggregatorSpec ->
customAggregatorSpec.expireGroupsUponCompletion(true))
.logAndReply();
}
----
====

View File

@@ -27,18 +27,20 @@ See its JavaDocs and <<./graph.adoc#integration-graph,Integration Graph>> for mo
The `ReactiveMessageHandler` is now natively supported in the framework.
See <<./reactive-streams.adoc/reactive-message-handler,ReactiveMessageHandler>> for more information.
[[x5.3-java-dsl-extensions]]
==== Java DSL Extensions
A new `IntegrationFlowExtension` API has been introduced to allow extension of the existing Java DSL with custom or composed EIP-operators.
This also can be used to introduce customizers for any out-of-the-box `IntegrationComponentSpec` extensions.
See <<./dsl.adoc/java-dsl-extensions,DSL Extensions>> for more information.
[[x5.3-mongodb-reactive-channel-adapters]]
==== MongoDB Reactive Channel Adapters
`spring-integration-mongodb` module now provides channel adapter implementations for Reactive MongoDB driver support in Spring Data.
See <<./mongodb.adoc#mongodb-reactive-channel-adapters,MongoDB Reactive Channel Adapters>> for more information.
[[x5.3-AbstractCorrelatingMessageHandler]]
==== Aggregator Changes
If the `MessageGroupProcessor` returns a `Message`, the `MessageBuilder.popSequenceDetails()` is performed on the output message if the `sequenceDetails` matches with first message of group.
See <<./aggregator.adoc#aggregator-api,Aggregator Programming Model>> for more information.
[[x5.3-general]]
=== General Changes
@@ -48,6 +50,9 @@ See <<./gateway.adoc/gateway-calling-default-methods,Invoking `default` Methods>
Internal components (such as `_org.springframework.integration.errorLogger`) now have a shortened name when they are represented in the integration graph.
See <<./graph.adoc#integration-graph,Integration Graph>> for more information.
In the aggregator, when the `MessageGroupProcessor` returns a `Message`, the `MessageBuilder.popSequenceDetails()` is performed on the output message if the `sequenceDetails` matches the header in the first message of the group.
See <<./aggregator.adoc#aggregator-api,Aggregator Programming Model>> for more information.
[[x5.3-amqp]]
=== AMQP Changes