Fix new Sonar smells

This commit is contained in:
abilan
2023-04-15 20:00:38 -04:00
parent d5181bf0d7
commit 869c5c7088
7 changed files with 69 additions and 70 deletions

View File

@@ -450,7 +450,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
* @param wireTapConfigurer the {@link Consumer} to accept options for the {@link WireTap}. * @param wireTapConfigurer the {@link Consumer} to accept options for the {@link WireTap}.
* @return the current {@link BaseIntegrationFlowDefinition}. * @return the current {@link BaseIntegrationFlowDefinition}.
*/ */
public B wireTap(String wireTapChannel, Consumer<WireTapSpec> wireTapConfigurer) { public B wireTap(String wireTapChannel, @Nullable Consumer<WireTapSpec> wireTapConfigurer) {
DirectChannel internalWireTapChannel = new DirectChannel(); DirectChannel internalWireTapChannel = new DirectChannel();
addComponent(IntegrationFlow.from(internalWireTapChannel).channel(wireTapChannel).get()); addComponent(IntegrationFlow.from(internalWireTapChannel).channel(wireTapChannel).get());
return wireTap(internalWireTapChannel, wireTapConfigurer); return wireTap(internalWireTapChannel, wireTapConfigurer);
@@ -639,7 +639,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
* @see MethodInvokingTransformer * @see MethodInvokingTransformer
*/ */
public B transform(MessageProcessorSpec<?> messageProcessorSpec, public B transform(MessageProcessorSpec<?> messageProcessorSpec,
Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) { @Nullable Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) {
Assert.notNull(messageProcessorSpec, MESSAGE_PROCESSOR_SPEC_MUST_NOT_BE_NULL); Assert.notNull(messageProcessorSpec, MESSAGE_PROCESSOR_SPEC_MUST_NOT_BE_NULL);
MessageProcessor<?> processor = messageProcessorSpec.getObject(); MessageProcessor<?> processor = messageProcessorSpec.getObject();
@@ -1087,7 +1087,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
* @return the current {@link BaseIntegrationFlowDefinition}. * @return the current {@link BaseIntegrationFlowDefinition}.
*/ */
public B handle(MessageProcessorSpec<?> messageProcessorSpec, public B handle(MessageProcessorSpec<?> messageProcessorSpec,
Consumer<GenericEndpointSpec<ServiceActivatingHandler>> endpointConfigurer) { @Nullable Consumer<GenericEndpointSpec<ServiceActivatingHandler>> endpointConfigurer) {
Assert.notNull(messageProcessorSpec, MESSAGE_PROCESSOR_SPEC_MUST_NOT_BE_NULL); Assert.notNull(messageProcessorSpec, MESSAGE_PROCESSOR_SPEC_MUST_NOT_BE_NULL);
MessageProcessor<?> processor = messageProcessorSpec.getObject(); MessageProcessor<?> processor = messageProcessorSpec.getObject();
@@ -2362,7 +2362,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
* @return the current {@link BaseIntegrationFlowDefinition}. * @return the current {@link BaseIntegrationFlowDefinition}.
* @see #wireTap(WireTapSpec) * @see #wireTap(WireTapSpec)
*/ */
public <P> B log(LoggingHandler.Level level, String category, Function<Message<P>, Object> function) { public <P> B log(LoggingHandler.Level level, @Nullable String category, Function<Message<P>, Object> function) {
Assert.notNull(function, FUNCTION_MUST_NOT_BE_NULL); Assert.notNull(function, FUNCTION_MUST_NOT_BE_NULL);
return log(level, category, new FunctionExpression<>(function)); return log(level, category, new FunctionExpression<>(function));
} }
@@ -2650,7 +2650,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
* @see #bridge() * @see #bridge()
*/ */
@Deprecated @Deprecated
public <P> IntegrationFlow logAndReply(LoggingHandler.Level level, String category, public <P> IntegrationFlow logAndReply(LoggingHandler.Level level, @Nullable String category,
Function<Message<P>, Object> function) { Function<Message<P>, Object> function) {
Assert.notNull(function, FUNCTION_MUST_NOT_BE_NULL); Assert.notNull(function, FUNCTION_MUST_NOT_BE_NULL);

View File

@@ -61,8 +61,10 @@ public abstract class EndpointSpec<S extends EndpointSpec<S, F, H>, F extends Be
} }
@Override @Override
public S id(String id) { public S id(@Nullable String id) {
this.endpointFactoryBean.setBeanName(id); if (id != null) {
this.endpointFactoryBean.setBeanName(id);
}
return super.id(id); return super.id(id);
} }

View File

@@ -216,7 +216,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @param overwrite true to overwrite existing headers. * @param overwrite true to overwrite existing headers.
* @return the header enricher spec. * @return the header enricher spec.
*/ */
public HeaderEnricherSpec headerExpressions(MapBuilder<?, String, String> headers, Boolean overwrite) { public HeaderEnricherSpec headerExpressions(MapBuilder<?, String, String> headers, @Nullable Boolean overwrite) {
Assert.notNull(headers, HEADERS_MUST_NOT_BE_NULL); Assert.notNull(headers, HEADERS_MUST_NOT_BE_NULL);
return headerExpressions(headers.get(), overwrite); return headerExpressions(headers.get(), overwrite);
} }
@@ -285,7 +285,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @param overwrite true to overwrite existing headers. * @param overwrite true to overwrite existing headers.
* @return the header enricher spec. * @return the header enricher spec.
*/ */
public HeaderEnricherSpec headerExpressions(Map<String, String> headers, Boolean overwrite) { public HeaderEnricherSpec headerExpressions(Map<String, String> headers, @Nullable Boolean overwrite) {
Assert.notNull(headers, HEADERS_MUST_NOT_BE_NULL); Assert.notNull(headers, HEADERS_MUST_NOT_BE_NULL);
for (Entry<String, String> entry : headers.entrySet()) { for (Entry<String, String> entry : headers.entrySet()) {
AbstractHeaderValueMessageProcessor<Object> processor = AbstractHeaderValueMessageProcessor<Object> processor =
@@ -314,7 +314,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec. * @return the header enricher spec.
* @since 5.2 * @since 5.2
*/ */
public HeaderEnricherSpec correlationId(Object correlationId, Boolean overwrite) { public HeaderEnricherSpec correlationId(Object correlationId, @Nullable Boolean overwrite) {
return header(IntegrationMessageHeaderAccessor.CORRELATION_ID, correlationId, overwrite); return header(IntegrationMessageHeaderAccessor.CORRELATION_ID, correlationId, overwrite);
} }
@@ -341,7 +341,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec. * @return the header enricher spec.
* @since 5.2 * @since 5.2
*/ */
public HeaderEnricherSpec correlationIdExpression(String correlationIdExpression, Boolean overwrite) { public HeaderEnricherSpec correlationIdExpression(String correlationIdExpression, @Nullable Boolean overwrite) {
return headerExpression(IntegrationMessageHeaderAccessor.CORRELATION_ID, correlationIdExpression, overwrite); return headerExpression(IntegrationMessageHeaderAccessor.CORRELATION_ID, correlationIdExpression, overwrite);
} }
@@ -371,7 +371,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @see FunctionExpression * @see FunctionExpression
*/ */
public <P> HeaderEnricherSpec correlationIdFunction(Function<Message<P>, ?> correlationIdFunction, public <P> HeaderEnricherSpec correlationIdFunction(Function<Message<P>, ?> correlationIdFunction,
Boolean overwrite) { @Nullable Boolean overwrite) {
return headerFunction(IntegrationMessageHeaderAccessor.CORRELATION_ID, correlationIdFunction, overwrite); return headerFunction(IntegrationMessageHeaderAccessor.CORRELATION_ID, correlationIdFunction, overwrite);
} }
@@ -394,7 +394,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec. * @return the header enricher spec.
* @since 5.2 * @since 5.2
*/ */
public HeaderEnricherSpec replyChannel(Object replyChannel, Boolean overwrite) { public HeaderEnricherSpec replyChannel(Object replyChannel, @Nullable Boolean overwrite) {
return header(MessageHeaders.REPLY_CHANNEL, replyChannel, overwrite); return header(MessageHeaders.REPLY_CHANNEL, replyChannel, overwrite);
} }
@@ -419,7 +419,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec. * @return the header enricher spec.
* @since 5.2 * @since 5.2
*/ */
public HeaderEnricherSpec replyChannelExpression(String replyChannelExpression, Boolean overwrite) { public HeaderEnricherSpec replyChannelExpression(String replyChannelExpression, @Nullable Boolean overwrite) {
return headerExpression(MessageHeaders.REPLY_CHANNEL, replyChannelExpression, overwrite); return headerExpression(MessageHeaders.REPLY_CHANNEL, replyChannelExpression, overwrite);
} }
@@ -449,7 +449,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @see FunctionExpression * @see FunctionExpression
*/ */
public <P> HeaderEnricherSpec replyChannelFunction(Function<Message<P>, ?> replyChannelFunction, public <P> HeaderEnricherSpec replyChannelFunction(Function<Message<P>, ?> replyChannelFunction,
Boolean overwrite) { @Nullable Boolean overwrite) {
return headerFunction(MessageHeaders.REPLY_CHANNEL, replyChannelFunction, overwrite); return headerFunction(MessageHeaders.REPLY_CHANNEL, replyChannelFunction, overwrite);
} }
@@ -472,7 +472,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec. * @return the header enricher spec.
* @since 5.2 * @since 5.2
*/ */
public HeaderEnricherSpec errorChannel(Object errorChannel, Boolean overwrite) { public HeaderEnricherSpec errorChannel(Object errorChannel, @Nullable Boolean overwrite) {
return header(MessageHeaders.ERROR_CHANNEL, errorChannel, overwrite); return header(MessageHeaders.ERROR_CHANNEL, errorChannel, overwrite);
} }
@@ -497,7 +497,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec. * @return the header enricher spec.
* @since 5.2 * @since 5.2
*/ */
public HeaderEnricherSpec errorChannelExpression(String errorChannelExpression, Boolean overwrite) { public HeaderEnricherSpec errorChannelExpression(String errorChannelExpression, @Nullable Boolean overwrite) {
return headerExpression(MessageHeaders.ERROR_CHANNEL, errorChannelExpression, overwrite); return headerExpression(MessageHeaders.ERROR_CHANNEL, errorChannelExpression, overwrite);
} }
@@ -527,7 +527,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @see FunctionExpression * @see FunctionExpression
*/ */
public <P> HeaderEnricherSpec errorChannelFunction(Function<Message<P>, ?> errorChannelFunction, public <P> HeaderEnricherSpec errorChannelFunction(Function<Message<P>, ?> errorChannelFunction,
Boolean overwrite) { @Nullable Boolean overwrite) {
return headerFunction(MessageHeaders.ERROR_CHANNEL, errorChannelFunction, overwrite); return headerFunction(MessageHeaders.ERROR_CHANNEL, errorChannelFunction, overwrite);
} }
@@ -550,7 +550,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec. * @return the header enricher spec.
* @since 5.2 * @since 5.2
*/ */
public HeaderEnricherSpec priority(Number priority, Boolean overwrite) { public HeaderEnricherSpec priority(Number priority, @Nullable Boolean overwrite) {
return header(IntegrationMessageHeaderAccessor.PRIORITY, priority, overwrite); return header(IntegrationMessageHeaderAccessor.PRIORITY, priority, overwrite);
} }
@@ -575,7 +575,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec. * @return the header enricher spec.
* @since 5.2 * @since 5.2
*/ */
public HeaderEnricherSpec priorityExpression(String priorityExpression, Boolean overwrite) { public HeaderEnricherSpec priorityExpression(String priorityExpression, @Nullable Boolean overwrite) {
return headerExpression(IntegrationMessageHeaderAccessor.PRIORITY, priorityExpression, overwrite); return headerExpression(IntegrationMessageHeaderAccessor.PRIORITY, priorityExpression, overwrite);
} }
@@ -604,7 +604,9 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @since 5.2 * @since 5.2
* @see FunctionExpression * @see FunctionExpression
*/ */
public <P> HeaderEnricherSpec priorityFunction(Function<Message<P>, ?> priorityFunction, Boolean overwrite) { public <P> HeaderEnricherSpec priorityFunction(Function<Message<P>, ?> priorityFunction,
@Nullable Boolean overwrite) {
return headerFunction(IntegrationMessageHeaderAccessor.PRIORITY, priorityFunction, overwrite); return headerFunction(IntegrationMessageHeaderAccessor.PRIORITY, priorityFunction, overwrite);
} }
@@ -626,7 +628,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec. * @return the header enricher spec.
* @since 5.2 * @since 5.2
*/ */
public HeaderEnricherSpec expirationDate(Object expirationDate, Boolean overwrite) { public HeaderEnricherSpec expirationDate(Object expirationDate, @Nullable Boolean overwrite) {
return header(IntegrationMessageHeaderAccessor.EXPIRATION_DATE, expirationDate, overwrite); return header(IntegrationMessageHeaderAccessor.EXPIRATION_DATE, expirationDate, overwrite);
} }
@@ -653,7 +655,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec. * @return the header enricher spec.
* @since 5.2 * @since 5.2
*/ */
public HeaderEnricherSpec expirationDateExpression(String expirationDateExpression, Boolean overwrite) { public HeaderEnricherSpec expirationDateExpression(String expirationDateExpression, @Nullable Boolean overwrite) {
return headerExpression(IntegrationMessageHeaderAccessor.EXPIRATION_DATE, expirationDateExpression, overwrite); return headerExpression(IntegrationMessageHeaderAccessor.EXPIRATION_DATE, expirationDateExpression, overwrite);
} }
@@ -683,7 +685,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @see FunctionExpression * @see FunctionExpression
*/ */
public <P> HeaderEnricherSpec expirationDateFunction(Function<Message<P>, ?> expirationDateFunction, public <P> HeaderEnricherSpec expirationDateFunction(Function<Message<P>, ?> expirationDateFunction,
Boolean overwrite) { @Nullable Boolean overwrite) {
return headerFunction(IntegrationMessageHeaderAccessor.EXPIRATION_DATE, expirationDateFunction, overwrite); return headerFunction(IntegrationMessageHeaderAccessor.EXPIRATION_DATE, expirationDateFunction, overwrite);
} }
@@ -726,7 +728,7 @@ public class HeaderEnricherSpec extends ConsumerEndpointSpec<HeaderEnricherSpec,
* @return the header enricher spec. * @return the header enricher spec.
* @since 5.2 * @since 5.2
*/ */
public HeaderEnricherSpec routingSlip(Boolean overwrite, Object... routingSlipPath) { public HeaderEnricherSpec routingSlip(@Nullable Boolean overwrite, Object... routingSlipPath) {
RoutingSlipHeaderValueMessageProcessor routingSlipHeaderValueMessageProcessor = RoutingSlipHeaderValueMessageProcessor routingSlipHeaderValueMessageProcessor =
new RoutingSlipHeaderValueMessageProcessor(routingSlipPath); new RoutingSlipHeaderValueMessageProcessor(routingSlipPath);
routingSlipHeaderValueMessageProcessor.setOverwrite(overwrite); routingSlipHeaderValueMessageProcessor.setOverwrite(overwrite);

View File

@@ -42,7 +42,7 @@ public class RecipientListRouterSpec extends AbstractRouterSpec<RecipientListRou
} }
/** /**
* Adds a recipient channel that always will be selected. * Adds a recipient channel that is always selected.
* @param channelName the channel name. * @param channelName the channel name.
* @return the router spec. * @return the router spec.
*/ */
@@ -51,12 +51,12 @@ public class RecipientListRouterSpec extends AbstractRouterSpec<RecipientListRou
} }
/** /**
* Adds a recipient channel that will be selected if the the expression evaluates to 'true'. * Adds a recipient channel that will be selected if the expression evaluates to 'true'.
* @param channelName the channel name. * @param channelName the channel name.
* @param expression the expression. * @param expression the expression.
* @return the router spec. * @return the router spec.
*/ */
public RecipientListRouterSpec recipient(String channelName, String expression) { public RecipientListRouterSpec recipient(String channelName, @Nullable String expression) {
if (StringUtils.hasText(expression)) { if (StringUtils.hasText(expression)) {
return recipient(channelName, PARSER.parseExpression(expression)); return recipient(channelName, PARSER.parseExpression(expression));
} }
@@ -67,7 +67,7 @@ public class RecipientListRouterSpec extends AbstractRouterSpec<RecipientListRou
} }
/** /**
* Adds a recipient channel that will be selected if the the expression evaluates to 'true'. * Adds a recipient channel that will be selected if the expression evaluates to 'true'.
* @param channelName the channel name. * @param channelName the channel name.
* @param expression the expression. * @param expression the expression.
* @return the router spec. * @return the router spec.
@@ -80,7 +80,7 @@ public class RecipientListRouterSpec extends AbstractRouterSpec<RecipientListRou
} }
/** /**
* Adds a recipient channel that will be selected if the the selector's accept method returns 'true'. * Adds a recipient channel that will be selected if the selector's accept method returns 'true'.
* @param channelName the channel name. * @param channelName the channel name.
* @param selector the selector. * @param selector the selector.
* @return the router spec. * @return the router spec.
@@ -129,7 +129,13 @@ public class RecipientListRouterSpec extends AbstractRouterSpec<RecipientListRou
* @return the router spec. * @return the router spec.
*/ */
public RecipientListRouterSpec recipient(MessageChannel channel, @Nullable String expression) { public RecipientListRouterSpec recipient(MessageChannel channel, @Nullable String expression) {
return recipient(channel, StringUtils.hasText(expression) ? PARSER.parseExpression(expression) : null); if (StringUtils.hasText(expression)) {
return recipient(channel, PARSER.parseExpression(expression));
}
else {
this.handler.addRecipient(channel);
return this;
}
} }
/** /**
@@ -138,16 +144,11 @@ public class RecipientListRouterSpec extends AbstractRouterSpec<RecipientListRou
* @param expression the expression. * @param expression the expression.
* @return the router spec. * @return the router spec.
*/ */
public RecipientListRouterSpec recipient(MessageChannel channel, @Nullable Expression expression) { public RecipientListRouterSpec recipient(MessageChannel channel, Expression expression) {
if (expression != null) { ExpressionEvaluatingSelector selector = new ExpressionEvaluatingSelector(expression);
ExpressionEvaluatingSelector selector = new ExpressionEvaluatingSelector(expression); this.handler.addRecipient(channel, selector);
this.handler.addRecipient(channel, selector); this.componentsToRegister.put(selector, null);
this.componentsToRegister.put(selector, null); return this;
}
else {
this.handler.addRecipient(channel);
}
return _this();
} }
/** /**
@@ -170,7 +171,7 @@ public class RecipientListRouterSpec extends AbstractRouterSpec<RecipientListRou
public <P> RecipientListRouterSpec recipient(MessageChannel channel, GenericSelector<P> selector) { public <P> RecipientListRouterSpec recipient(MessageChannel channel, GenericSelector<P> selector) {
MessageSelector messageSelector = wrapToMessageSelectorIfNecessary(selector); MessageSelector messageSelector = wrapToMessageSelectorIfNecessary(selector);
this.handler.addRecipient(channel, messageSelector); this.handler.addRecipient(channel, messageSelector);
return _this(); return this;
} }
/** /**
@@ -212,7 +213,13 @@ public class RecipientListRouterSpec extends AbstractRouterSpec<RecipientListRou
* @return the router spec. * @return the router spec.
*/ */
public RecipientListRouterSpec recipientFlow(@Nullable String expression, IntegrationFlow subFlow) { public RecipientListRouterSpec recipientFlow(@Nullable String expression, IntegrationFlow subFlow) {
return recipientFlow(StringUtils.hasText(expression) ? PARSER.parseExpression(expression) : null, subFlow); if (StringUtils.hasText(expression)) {
return recipientFlow(PARSER.parseExpression(expression), subFlow);
}
else {
MessageChannel channel = obtainInputChannelFromFlow(subFlow);
return recipient(channel);
}
} }
/** /**
@@ -221,7 +228,7 @@ public class RecipientListRouterSpec extends AbstractRouterSpec<RecipientListRou
* @param subFlow the subflow. * @param subFlow the subflow.
* @return the router spec. * @return the router spec.
*/ */
public RecipientListRouterSpec recipientFlow(@Nullable Expression expression, IntegrationFlow subFlow) { public RecipientListRouterSpec recipientFlow(Expression expression, IntegrationFlow subFlow) {
MessageChannel channel = obtainInputChannelFromFlow(subFlow); MessageChannel channel = obtainInputChannelFromFlow(subFlow);
return recipient(channel, expression); return recipient(channel, expression);
} }

View File

@@ -136,8 +136,8 @@ public class StandardIntegrationFlow
ListIterator<Object> iterator = components.listIterator(this.integrationComponents.size()); ListIterator<Object> iterator = components.listIterator(this.integrationComponents.size());
while (iterator.hasPrevious()) { while (iterator.hasPrevious()) {
Object component = iterator.previous(); Object component = iterator.previous();
if (component instanceof SmartLifecycle) { if (component instanceof SmartLifecycle lifecycle) {
((SmartLifecycle) component).start(); lifecycle.start();
} }
} }
this.running = true; this.running = true;
@@ -148,11 +148,9 @@ public class StandardIntegrationFlow
public void stop(Runnable callback) { public void stop(Runnable callback) {
AggregatingCallback aggregatingCallback = new AggregatingCallback(this.integrationComponents.size(), callback); AggregatingCallback aggregatingCallback = new AggregatingCallback(this.integrationComponents.size(), callback);
for (Object component : this.integrationComponents.keySet()) { for (Object component : this.integrationComponents.keySet()) {
if (component instanceof SmartLifecycle lifecycle) { if (component instanceof SmartLifecycle lifecycle && lifecycle.isRunning()) {
if (lifecycle.isRunning()) { lifecycle.stop(aggregatingCallback);
lifecycle.stop(aggregatingCallback); continue;
continue;
}
} }
aggregatingCallback.run(); aggregatingCallback.run();
} }
@@ -162,10 +160,8 @@ public class StandardIntegrationFlow
@Override @Override
public void stop() { public void stop() {
for (Object component : this.integrationComponents.keySet()) { for (Object component : this.integrationComponents.keySet()) {
if (component instanceof SmartLifecycle lifecycle) { if (component instanceof SmartLifecycle lifecycle && lifecycle.isRunning()) {
if (lifecycle.isRunning()) { lifecycle.stop();
lifecycle.stop();
}
} }
} }
this.running = false; this.running = false;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2020 the original author or authors. * Copyright 2020-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -35,11 +35,7 @@ import org.springframework.messaging.MessageChannel
class KotlinRecipientListRouterSpec(override val delegate: RecipientListRouterSpec) class KotlinRecipientListRouterSpec(override val delegate: RecipientListRouterSpec)
: AbstractKotlinRouterSpec<RecipientListRouterSpec, RecipientListRouter>(delegate) { : AbstractKotlinRouterSpec<RecipientListRouterSpec, RecipientListRouter>(delegate) {
fun recipient(channelName: String) { fun recipient(channelName: String, expression: String? = null) {
this.delegate.recipient(channelName)
}
fun recipient(channelName: String, expression: String) {
this.delegate.recipient(channelName, expression) this.delegate.recipient(channelName, expression)
} }
@@ -54,11 +50,7 @@ class KotlinRecipientListRouterSpec(override val delegate: RecipientListRouterSp
this.delegate.recipient<P>(channelName) { selector(it) } this.delegate.recipient<P>(channelName) { selector(it) }
} }
fun recipient(channel: MessageChannel) { fun recipient(channel: MessageChannel, expression: String? = null) {
this.delegate.recipient(channel)
}
fun recipient(channel: MessageChannel, expression: String) {
this.delegate.recipient(channel, expression) this.delegate.recipient(channel, expression)
} }
@@ -68,9 +60,9 @@ class KotlinRecipientListRouterSpec(override val delegate: RecipientListRouterSp
inline fun <reified P> recipient(channel: MessageChannel, crossinline selector: (P) -> Boolean) { inline fun <reified P> recipient(channel: MessageChannel, crossinline selector: (P) -> Boolean) {
if (Message::class.java.isAssignableFrom(P::class.java)) if (Message::class.java.isAssignableFrom(P::class.java))
this.delegate.recipientMessageSelector(channel, MessageSelector { selector(it as P) }) this.delegate.recipientMessageSelector(channel) { selector(it as P) }
else else
this.delegate.recipient<P>(channel, GenericSelector { selector(it) }) this.delegate.recipient<P>(channel) { selector(it) }
} }
inline fun <reified P> recipientFlow(crossinline selector: (P) -> Boolean, inline fun <reified P> recipientFlow(crossinline selector: (P) -> Boolean,

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2022 the original author or authors. * Copyright 2022-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -126,7 +126,7 @@ class GroovyIntegrationFlowDefinition {
* at the current {@link IntegrationFlow} chain position using the {@link MessageChannelSpec} * at the current {@link IntegrationFlow} chain position using the {@link MessageChannelSpec}
* fluent API. * fluent API.
* @param messageChannelSpec the {@link MessageChannelSpec} to use. * @param messageChannelSpec the {@link MessageChannelSpec} to use.
* @see MessageChannels * @see org.springframework.integration.dsl.MessageChannels
*/ */
GroovyIntegrationFlowDefinition channel(MessageChannelSpec messageChannelSpec) { GroovyIntegrationFlowDefinition channel(MessageChannelSpec messageChannelSpec) {
this.delegate.channel messageChannelSpec this.delegate.channel messageChannelSpec