GH-3656: Fix package tangles

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

* Move `JavaUtils` from `util` package to the root one to break any possible
tangling to/from other packages.
* Deprecate an existing `JavaUtils` for backward compatibility
* Remove `@IntegrationConverter` from the `JsonNodeWrapperToJsonNodeConverter`
and register it manually in the `ConverterRegistrar`.
The bean registration for the `JsonNodeWrapperToJsonNodeConverter` must be removed
in the next `6.0`
* Remove usage of `IntegrationContextUtils` from the `support` package
This commit is contained in:
Artem Bilan
2021-11-01 14:13:01 -04:00
committed by Gary Russell
parent f520156053
commit fc7d338302
25 changed files with 292 additions and 113 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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,13 +39,13 @@ import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.context.Lifecycle;
import org.springframework.context.SmartLifecycle;
import org.springframework.integration.JavaUtils;
import org.springframework.integration.amqp.channel.AbstractAmqpChannel;
import org.springframework.integration.amqp.channel.PointToPointSubscribableAmqpChannel;
import org.springframework.integration.amqp.channel.PollableAmqpChannel;
import org.springframework.integration.amqp.channel.PublishSubscribeAmqpChannel;
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
import org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper;
import org.springframework.integration.util.JavaUtils;
import org.springframework.lang.Nullable;
import org.springframework.messaging.support.ChannelInterceptor;
import org.springframework.transaction.PlatformTransactionManager;

View File

@@ -0,0 +1,174 @@
/*
* Copyright 2019-2021 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;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
* Chained utility methods to simplify some Java repetitive code. Obtain a reference to
* the singleton {@link #INSTANCE} and then chain calls to the utility methods.
*
* @author Gary Russell
* @author Artem Bilan
*
* @since 5.1.3
*/
public final class JavaUtils {
/**
* The singleton instance of this utility class.
*/
public static final JavaUtils INSTANCE = new JavaUtils();
private JavaUtils() {
}
/**
* Invoke {@link Consumer#accept(Object)} with the value if the condition is true.
* @param condition the condition.
* @param value the value.
* @param consumer the consumer.
* @param <T> the value type.
* @return this.
*/
public <T> JavaUtils acceptIfCondition(boolean condition, T value, Consumer<T> consumer) {
if (condition) {
consumer.accept(value);
}
return this;
}
/**
* Invoke {@link Consumer#accept(Object)} with the value if it is not null.
* @param value the value.
* @param consumer the consumer.
* @param <T> the value type.
* @return this.
*/
public <T> JavaUtils acceptIfNotNull(T value, Consumer<T> consumer) {
if (value != null) {
consumer.accept(value);
}
return this;
}
/**
* Invoke {@link Consumer#accept(Object)} with the value if it is not null or empty.
* @param value the value.
* @param consumer the consumer.
* @return this.
* @since 5.2
*/
public JavaUtils acceptIfHasText(String value, Consumer<String> consumer) {
if (StringUtils.hasText(value)) {
consumer.accept(value);
}
return this;
}
/**
* Invoke {@link Consumer#accept(Object)} with the value if it is not null or empty.
* @param value the value.
* @param consumer the consumer.
* @param <T> the value type.
* @return this.
* @since 5.2
*/
public <T> JavaUtils acceptIfNotEmpty(List<T> value, Consumer<List<T>> consumer) {
if (!CollectionUtils.isEmpty(value)) {
consumer.accept(value);
}
return this;
}
/**
* Invoke {@link Consumer#accept(Object)} with the value if it is not null or empty.
* @param value the value.
* @param consumer the consumer.
* @param <T> the value type.
* @return this.
* @since 5.2
*/
public <T> JavaUtils acceptIfNotEmpty(T[] value, Consumer<T[]> consumer) {
if (!ObjectUtils.isEmpty(value)) {
consumer.accept(value);
}
return this;
}
/**
* Invoke {@link BiConsumer#accept(Object, Object)} with the arguments if the
* condition is true.
* @param condition the condition.
* @param t1 the first consumer argument
* @param t2 the second consumer argument
* @param consumer the consumer.
* @param <T1> the first argument type.
* @param <T2> the second argument type.
* @return this.
* @since 5.2
*/
public <T1, T2> JavaUtils acceptIfCondition(boolean condition, T1 t1, T2 t2, BiConsumer<T1, T2> consumer) {
if (condition) {
consumer.accept(t1, t2);
}
return this;
}
/**
* Invoke {@link BiConsumer#accept(Object, Object)} with the arguments if the t2
* argument is not null.
* @param t1 the first argument
* @param t2 the second consumer argument
* @param consumer the consumer.
* @param <T1> the first argument type.
* @param <T2> the second argument type.
* @return this.
* @since 5.2
*/
public <T1, T2> JavaUtils acceptIfNotNull(T1 t1, T2 t2, BiConsumer<T1, T2> consumer) {
if (t2 != null) {
consumer.accept(t1, t2);
}
return this;
}
/**
* Invoke {@link BiConsumer#accept(Object, Object)} with the arguments if the value
* argument is not null or empty.
* @param t1 the first consumer argument.
* @param value the second consumer argument
* @param <T> the first argument type.
* @param consumer the consumer.
* @return this.
* @since 5.2
*/
public <T> JavaUtils acceptIfHasText(T t1, String value, BiConsumer<T, String> consumer) {
if (StringUtils.hasText(value)) {
consumer.accept(t1, value);
}
return this;
}
}

View File

@@ -35,13 +35,13 @@ import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.integration.JavaUtils;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.context.Orderable;
import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.handler.AbstractMessageProducingHandler;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
import org.springframework.integration.support.context.NamedComponent;
import org.springframework.integration.util.JavaUtils;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.core.DestinationResolver;
@@ -199,19 +199,19 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageH
}
this.handler = createHandler();
JavaUtils.INSTANCE
.acceptIfCondition(this.handler instanceof ApplicationContextAware && this.applicationContext != null,
this.applicationContext,
context -> ((ApplicationContextAware) this.handler).setApplicationContext(this.applicationContext))
.acceptIfCondition(this.handler instanceof BeanFactoryAware && getBeanFactory() != null,
getBeanFactory(),
factory -> ((BeanFactoryAware) this.handler).setBeanFactory(factory))
.acceptIfCondition(this.handler instanceof BeanNameAware && this.beanName != null, this.beanName,
name -> ((BeanNameAware) this.handler).setBeanName(this.beanName))
.acceptIfCondition(this.handler instanceof ApplicationEventPublisherAware
&& this.applicationEventPublisher != null,
this.applicationEventPublisher,
publisher -> ((ApplicationEventPublisherAware) this.handler)
.setApplicationEventPublisher(publisher));
.acceptIfCondition(this.handler instanceof ApplicationContextAware && this.applicationContext != null,
this.applicationContext,
context -> ((ApplicationContextAware) this.handler).setApplicationContext(this.applicationContext))
.acceptIfCondition(this.handler instanceof BeanFactoryAware && getBeanFactory() != null,
getBeanFactory(),
factory -> ((BeanFactoryAware) this.handler).setBeanFactory(factory))
.acceptIfCondition(this.handler instanceof BeanNameAware && this.beanName != null, this.beanName,
name -> ((BeanNameAware) this.handler).setBeanName(this.beanName))
.acceptIfCondition(this.handler instanceof ApplicationEventPublisherAware
&& this.applicationEventPublisher != null,
this.applicationEventPublisher,
publisher -> ((ApplicationEventPublisherAware) this.handler)
.setApplicationEventPublisher(publisher));
configureOutputChannelIfAny();
Object actualHandler = extractTarget(this.handler);
if (actualHandler == null) {
@@ -221,11 +221,11 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageH
integrationObjectSupport(actualHandler, handlerToConfigure);
adviceChain(actualHandler);
JavaUtils.INSTANCE
.acceptIfCondition(this.async != null && actualHandler instanceof AbstractMessageProducingHandler,
this.async,
asyncValue -> ((AbstractMessageProducingHandler) handlerToConfigure).setAsync(asyncValue))
.acceptIfCondition(this.handler instanceof Orderable && this.order != null,
this.order, theOrder -> ((Orderable) this.handler).setOrder(theOrder));
.acceptIfCondition(this.async != null && actualHandler instanceof AbstractMessageProducingHandler,
this.async,
asyncValue -> ((AbstractMessageProducingHandler) handlerToConfigure).setAsync(asyncValue))
.acceptIfCondition(this.handler instanceof Orderable && this.order != null,
this.order, theOrder -> ((Orderable) this.handler).setOrder(theOrder));
this.initialized = true;
}
initializingBean();
@@ -235,10 +235,10 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageH
private void integrationObjectSupport(Object actualHandler, final Object handlerToConfigure) {
if (actualHandler instanceof IntegrationObjectSupport) {
JavaUtils.INSTANCE
.acceptIfNotNull(this.componentName,
name -> ((IntegrationObjectSupport) handlerToConfigure).setComponentName(name))
.acceptIfNotNull(this.channelResolver,
resolver -> ((IntegrationObjectSupport) handlerToConfigure).setChannelResolver(resolver));
.acceptIfNotNull(this.componentName,
name -> ((IntegrationObjectSupport) handlerToConfigure).setComponentName(name))
.acceptIfNotNull(this.channelResolver,
resolver -> ((IntegrationObjectSupport) handlerToConfigure).setChannelResolver(resolver));
}
}

View File

@@ -26,6 +26,7 @@ import org.aopalliance.aop.Advice;
import org.jetbrains.annotations.Nullable;
import org.springframework.expression.Expression;
import org.springframework.integration.JavaUtils;
import org.springframework.integration.aggregator.AbstractAggregatingMessageGroupProcessor;
import org.springframework.integration.aggregator.AggregatingMessageHandler;
import org.springframework.integration.aggregator.CorrelationStrategy;
@@ -36,7 +37,6 @@ import org.springframework.integration.aggregator.ReleaseStrategy;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.MessageGroupStore;
import org.springframework.integration.support.locks.LockRegistry;
import org.springframework.integration.util.JavaUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;

View File

@@ -26,6 +26,8 @@ import org.springframework.context.ApplicationContextAware;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.ConversionServiceFactory;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.integration.json.JsonNodeWrapperToJsonNodeConverter;
import org.springframework.integration.support.json.JacksonPresent;
import org.springframework.integration.support.utils.IntegrationUtils;
import org.springframework.util.Assert;
@@ -74,6 +76,9 @@ class ConverterRegistrar implements InitializingBean, ApplicationContextAware {
private void registerConverters(GenericConversionService conversionService) {
this.converters.addAll(this.applicationContext.getBeansWithAnnotation(IntegrationConverter.class).values());
if (JacksonPresent.isJackson2Present()) {
this.converters.add(new JsonNodeWrapperToJsonNodeConverter());
}
ConversionServiceFactory.registerConverters(this.converters, conversionService);
}

View File

@@ -385,6 +385,7 @@ public class DefaultConfiguringBeanFactoryPostProcessor
}
}
// TODO Remove in 6.0
private void jsonNodeToString(int registryId) {
if (!this.beanFactory.containsBean(
IntegrationContextUtils.JSON_NODE_WRAPPER_TO_JSON_NODE_CONVERTER) &&

View File

@@ -19,7 +19,7 @@ package org.springframework.integration.context;
import java.util.Arrays;
import java.util.Properties;
import org.springframework.integration.util.JavaUtils;
import org.springframework.integration.JavaUtils;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017-2020 the original author or authors.
* Copyright 2017-2021 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,9 +28,9 @@ import org.springframework.core.annotation.AnnotationAttributes;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.expression.Expression;
import org.springframework.expression.common.LiteralExpression;
import org.springframework.integration.JavaUtils;
import org.springframework.integration.annotation.AnnotationConstants;
import org.springframework.integration.annotation.MessagingGateway;
import org.springframework.integration.util.JavaUtils;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;

View File

@@ -58,6 +58,7 @@ import org.springframework.expression.Expression;
import org.springframework.expression.common.LiteralExpression;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.JavaUtils;
import org.springframework.integration.annotation.Gateway;
import org.springframework.integration.annotation.GatewayHeader;
import org.springframework.integration.context.IntegrationContextUtils;
@@ -68,7 +69,6 @@ import org.springframework.integration.support.channel.ChannelResolverUtils;
import org.springframework.integration.support.management.IntegrationManagement;
import org.springframework.integration.support.management.TrackableComponent;
import org.springframework.integration.support.management.metrics.MetricsCaptor;
import org.springframework.integration.util.JavaUtils;
import org.springframework.lang.Nullable;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
@@ -865,7 +865,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
String gatewayMethodBeanName =
getComponentName() + '#' + method.getName() +
'(' + Arrays.stream(method.getParameterTypes())
'(' + Arrays.stream(method.getParameterTypes())
.map(Class::getSimpleName)
.collect(Collectors.joining(", ")) + ')';

View File

@@ -21,7 +21,6 @@ import java.util.Set;
import org.springframework.core.convert.TypeDescriptor;
import org.springframework.core.convert.converter.GenericConverter;
import org.springframework.integration.config.IntegrationConverter;
import org.springframework.integration.json.JsonPropertyAccessor.JsonNodeWrapper;
import org.springframework.lang.Nullable;
@@ -38,7 +37,6 @@ import com.fasterxml.jackson.databind.JsonNode;
*
* @since 5.5
*/
@IntegrationConverter
public class JsonNodeWrapperToJsonNodeConverter implements GenericConverter {
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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.
@@ -23,7 +23,6 @@ import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.core.DestinationResolutionException;
import org.springframework.messaging.core.DestinationResolver;
@@ -97,9 +96,9 @@ public class BeanFactoryChannelResolver implements DestinationResolver<MessageCh
synchronized (this) {
if (!this.initialized) {
try {
this.replyChannelRegistry = this.beanFactory.getBean(
IntegrationContextUtils.INTEGRATION_HEADER_CHANNEL_REGISTRY_BEAN_NAME,
HeaderChannelRegistry.class);
this.replyChannelRegistry =
this.beanFactory.getBean("integrationHeaderChannelRegistry",
HeaderChannelRegistry.class);
}
catch (Exception ex) {
LOGGER.debug("No HeaderChannelRegistry found");

View File

@@ -24,7 +24,6 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.core.convert.ConversionService;
import org.springframework.integration.context.IntegrationContextUtils;
import org.springframework.integration.support.DefaultMessageBuilderFactory;
import org.springframework.integration.support.MessageBuilderFactory;
import org.springframework.integration.support.context.NamedComponent;
@@ -49,7 +48,7 @@ public final class IntegrationUtils {
private static final Log LOGGER = LogFactory.getLog(IntegrationUtils.class);
private static final String INTERNAL_COMPONENT_PREFIX = '_' + IntegrationContextUtils.BASE_PACKAGE;
private static final String INTERNAL_COMPONENT_PREFIX = "_org.springframework.integration";
public static final String INTEGRATION_CONVERSION_SERVICE_BEAN_NAME = "integrationConversionService";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2021 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.
@@ -24,7 +24,7 @@ import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.util.JavaUtils;
import org.springframework.integration.JavaUtils;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.core.BeanFactoryMessageChannelDestinationResolver;
import org.springframework.messaging.core.DestinationResolver;

View File

@@ -31,6 +31,7 @@ import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.integration.IntegrationPatternType;
import org.springframework.integration.JavaUtils;
import org.springframework.integration.expression.ExpressionUtils;
import org.springframework.integration.gateway.MessagingGatewaySupport;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
@@ -38,7 +39,6 @@ import org.springframework.integration.support.AbstractIntegrationMessageBuilder
import org.springframework.integration.support.DefaultMessageBuilderFactory;
import org.springframework.integration.support.management.ManageableLifecycle;
import org.springframework.integration.transformer.support.HeaderValueMessageProcessor;
import org.springframework.integration.util.JavaUtils;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandlingException;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2019 the original author or authors.
* Copyright 2019-2021 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,10 @@ import org.springframework.util.StringUtils;
* @author Artem Bilan
*
* @since 5.1.3
*
* @deprecated since 5.5.6 in favor of {@link org.springframework.integration.JavaUtils}.
*/
@Deprecated
public final class JavaUtils {
/**

View File

@@ -25,10 +25,10 @@ import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.SmartLifecycle;
import org.springframework.core.task.TaskExecutor;
import org.springframework.integration.JavaUtils;
import org.springframework.integration.file.tail.ApacheCommonsFileTailingMessageProducer;
import org.springframework.integration.file.tail.FileTailingMessageProducerSupport;
import org.springframework.integration.file.tail.OSDelegatingFileTailingMessageProducer;
import org.springframework.integration.util.JavaUtils;
import org.springframework.messaging.MessageChannel;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.util.Assert;
@@ -232,9 +232,9 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea
"'native-options' is not allowed with 'delay', 'end', or 'reopen'");
ApacheCommonsFileTailingMessageProducer apache = new ApacheCommonsFileTailingMessageProducer();
JavaUtils.INSTANCE
.acceptIfNotNull(this.delay, apache::setPollingDelay)
.acceptIfNotNull(this.end, apache::setEnd)
.acceptIfNotNull(this.reopen, apache::setReopen);
.acceptIfNotNull(this.delay, apache::setPollingDelay)
.acceptIfNotNull(this.end, apache::setEnd)
.acceptIfNotNull(this.reopen, apache::setReopen);
adapter = apache;
}
adapter.setFile(this.file);
@@ -243,16 +243,16 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea
adapter.setBeanName(this.beanName);
BeanFactory beanFactory = getBeanFactory();
JavaUtils.INSTANCE
.acceptIfNotNull(this.taskExecutor, adapter::setTaskExecutor)
.acceptIfNotNull(this.taskScheduler, adapter::setTaskScheduler)
.acceptIfNotNull(this.fileDelay, adapter::setTailAttemptsDelay)
.acceptIfNotNull(this.idleEventInterval, adapter::setIdleEventInterval)
.acceptIfNotNull(this.autoStartup, adapter::setAutoStartup)
.acceptIfNotNull(this.phase, adapter::setPhase)
.acceptIfNotNull(this.applicationEventPublisher, adapter::setApplicationEventPublisher)
.acceptIfNotNull(this.outputChannelName, adapter::setOutputChannelName)
.acceptIfNotNull(this.errorChannelName, adapter::setErrorChannelName)
.acceptIfNotNull(beanFactory, adapter::setBeanFactory);
.acceptIfNotNull(this.taskExecutor, adapter::setTaskExecutor)
.acceptIfNotNull(this.taskScheduler, adapter::setTaskScheduler)
.acceptIfNotNull(this.fileDelay, adapter::setTailAttemptsDelay)
.acceptIfNotNull(this.idleEventInterval, adapter::setIdleEventInterval)
.acceptIfNotNull(this.autoStartup, adapter::setAutoStartup)
.acceptIfNotNull(this.phase, adapter::setPhase)
.acceptIfNotNull(this.applicationEventPublisher, adapter::setApplicationEventPublisher)
.acceptIfNotNull(this.outputChannelName, adapter::setOutputChannelName)
.acceptIfNotNull(this.errorChannelName, adapter::setErrorChannelName)
.acceptIfNotNull(beanFactory, adapter::setBeanFactory);
adapter.afterPropertiesSet();
this.tailAdapter = adapter;
return adapter;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
@@ -19,12 +19,12 @@ package org.springframework.integration.file.config;
import java.io.File;
import org.springframework.expression.Expression;
import org.springframework.integration.JavaUtils;
import org.springframework.integration.config.AbstractSimpleMessageHandlerFactoryBean;
import org.springframework.integration.file.FileNameGenerator;
import org.springframework.integration.file.FileWritingMessageHandler;
import org.springframework.integration.file.FileWritingMessageHandler.MessageFlushPredicate;
import org.springframework.integration.file.support.FileExistsMode;
import org.springframework.integration.util.JavaUtils;
/**
* Factory bean used to create {@link FileWritingMessageHandler}s.
@@ -170,21 +170,21 @@ public class FileWritingMessageHandlerFactoryBean
handler.setExpectReply(this.expectReply);
JavaUtils.INSTANCE
.acceptIfNotNull(this.charset, handler::setCharset)
.acceptIfNotNull(this.fileNameGenerator, handler::setFileNameGenerator)
.acceptIfNotNull(this.deleteSourceFiles, handler::setDeleteSourceFiles)
.acceptIfNotNull(this.autoCreateDirectory, handler::setAutoCreateDirectory)
.acceptIfNotNull(this.requiresReply, handler::setRequiresReply)
.acceptIfNotNull(this.sendTimeout, handler::setSendTimeout)
.acceptIfNotNull(this.temporaryFileSuffix, handler::setTemporaryFileSuffix)
.acceptIfNotNull(this.appendNewLine, handler::setAppendNewLine)
.acceptIfNotNull(this.fileExistsMode, handler::setFileExistsMode)
.acceptIfNotNull(this.bufferSize, handler::setBufferSize)
.acceptIfNotNull(this.flushInterval, handler::setFlushInterval)
.acceptIfNotNull(this.flushWhenIdle, handler::setFlushWhenIdle)
.acceptIfNotNull(this.flushPredicate, handler::setFlushPredicate)
.acceptIfNotNull(this.chmod, handler::setChmodOctal)
.acceptIfNotNull(this.preserveTimestamp, handler::setPreserveTimestamp);
.acceptIfNotNull(this.charset, handler::setCharset)
.acceptIfNotNull(this.fileNameGenerator, handler::setFileNameGenerator)
.acceptIfNotNull(this.deleteSourceFiles, handler::setDeleteSourceFiles)
.acceptIfNotNull(this.autoCreateDirectory, handler::setAutoCreateDirectory)
.acceptIfNotNull(this.requiresReply, handler::setRequiresReply)
.acceptIfNotNull(this.sendTimeout, handler::setSendTimeout)
.acceptIfNotNull(this.temporaryFileSuffix, handler::setTemporaryFileSuffix)
.acceptIfNotNull(this.appendNewLine, handler::setAppendNewLine)
.acceptIfNotNull(this.fileExistsMode, handler::setFileExistsMode)
.acceptIfNotNull(this.bufferSize, handler::setBufferSize)
.acceptIfNotNull(this.flushInterval, handler::setFlushInterval)
.acceptIfNotNull(this.flushWhenIdle, handler::setFlushWhenIdle)
.acceptIfNotNull(this.flushPredicate, handler::setFlushPredicate)
.acceptIfNotNull(this.chmod, handler::setChmodOctal)
.acceptIfNotNull(this.preserveTimestamp, handler::setPreserveTimestamp);
return handler;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2021 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.
@@ -24,7 +24,7 @@ import javax.net.ssl.TrustManager;
import org.apache.commons.net.ftp.FTPSClient;
import org.springframework.integration.util.JavaUtils;
import org.springframework.integration.JavaUtils;
import org.springframework.util.StringUtils;
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 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,6 +47,7 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.core.convert.ConversionService;
import org.springframework.expression.Expression;
import org.springframework.integration.JavaUtils;
import org.springframework.integration.MessageTimeoutException;
import org.springframework.integration.StaticMessageHeaderAccessor;
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
@@ -54,7 +55,6 @@ import org.springframework.integration.handler.ExpressionEvaluatingMessageProces
import org.springframework.integration.jms.util.JmsAdapterUtils;
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
import org.springframework.integration.support.management.ManageableLifecycle;
import org.springframework.integration.util.JavaUtils;
import org.springframework.jms.connection.ConnectionFactoryUtils;
import org.springframework.jms.listener.DefaultMessageListenerContainer;
import org.springframework.jms.support.JmsUtils;

View File

@@ -29,11 +29,11 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.context.SmartLifecycle;
import org.springframework.integration.JavaUtils;
import org.springframework.integration.jms.AbstractJmsChannel;
import org.springframework.integration.jms.DynamicJmsTemplate;
import org.springframework.integration.jms.PollableJmsChannel;
import org.springframework.integration.jms.SubscribableJmsChannel;
import org.springframework.integration.util.JavaUtils;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.listener.AbstractMessageListenerContainer;
import org.springframework.jms.listener.DefaultMessageListenerContainer;
@@ -385,7 +385,7 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
"A JMS Topic-backed 'publish-subscribe-channel' must be message-driven.");
PollableJmsChannel pollableJmschannel = new PollableJmsChannel(this.jmsTemplate);
JavaUtils.INSTANCE
.acceptIfNotNull(this.messageSelector, pollableJmschannel::setMessageSelector);
.acceptIfNotNull(this.messageSelector, pollableJmschannel::setMessageSelector);
this.channel = pollableJmschannel;
}
if (!CollectionUtils.isEmpty(this.interceptors)) {
@@ -394,7 +394,7 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
this.channel.setBeanName(this.beanName);
BeanFactory beanFactory = this.getBeanFactory();
JavaUtils.INSTANCE
.acceptIfNotNull(beanFactory, this.channel::setBeanFactory);
.acceptIfNotNull(beanFactory, this.channel::setBeanFactory);
this.channel.afterPropertiesSet();
return this.channel;
}
@@ -403,8 +403,8 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
Assert.isTrue(this.destination != null ^ this.destinationName != null,
"Exactly one of destination or destinationName is required.");
JavaUtils.INSTANCE
.acceptIfNotNull(this.destination, this.jmsTemplate::setDefaultDestination)
.acceptIfNotNull(this.destinationName, this.jmsTemplate::setDefaultDestinationName);
.acceptIfNotNull(this.destination, this.jmsTemplate::setDefaultDestination)
.acceptIfNotNull(this.destinationName, this.jmsTemplate::setDefaultDestinationName);
}
private AbstractMessageListenerContainer createContainer() {
@@ -418,18 +418,18 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
container.setClientId(this.clientId);
container.setConnectionFactory(this.connectionFactory);
JavaUtils.INSTANCE
.acceptIfNotNull(this.destination, container::setDestination)
.acceptIfNotNull(this.destinationName, container::setDestinationName)
.acceptIfNotNull(this.destinationResolver, container::setDestinationResolver);
.acceptIfNotNull(this.destination, container::setDestination)
.acceptIfNotNull(this.destinationName, container::setDestinationName)
.acceptIfNotNull(this.destinationResolver, container::setDestinationResolver);
container.setDurableSubscriptionName(this.durableSubscriptionName);
container.setErrorHandler(this.errorHandler);
container.setExceptionListener(this.exceptionListener);
JavaUtils.INSTANCE
.acceptIfNotNull(this.exposeListenerSession, container::setExposeListenerSession);
.acceptIfNotNull(this.exposeListenerSession, container::setExposeListenerSession);
container.setMessageSelector(this.messageSelector);
JavaUtils.INSTANCE
.acceptIfNotNull(this.phase, container::setPhase)
.acceptIfNotNull(this.pubSubDomain, container::setPubSubDomain);
.acceptIfNotNull(this.phase, container::setPhase)
.acceptIfNotNull(this.pubSubDomain, container::setPubSubDomain);
container.setSessionAcknowledgeMode(this.sessionAcknowledgeMode);
container.setSessionTransacted(this.sessionTransacted);
container.setSubscriptionDurable(this.subscriptionDurable);
@@ -438,28 +438,28 @@ public class JmsChannelFactoryBean extends AbstractFactoryBean<AbstractJmsChanne
if (container instanceof DefaultMessageListenerContainer) {
DefaultMessageListenerContainer dmlc = (DefaultMessageListenerContainer) container;
JavaUtils.INSTANCE
.acceptIfNotNull(this.cacheLevelName, dmlc::setCacheLevelName)
.acceptIfNotNull(this.cacheLevel, dmlc::setCacheLevel)
.acceptIfHasText(this.concurrency, dmlc::setConcurrency)
.acceptIfNotNull(this.concurrentConsumers, dmlc::setConcurrentConsumers)
.acceptIfNotNull(this.maxConcurrentConsumers, dmlc::setMaxConcurrentConsumers)
.acceptIfNotNull(this.idleTaskExecutionLimit, dmlc::setIdleTaskExecutionLimit)
.acceptIfNotNull(this.maxMessagesPerTask, dmlc::setMaxMessagesPerTask);
.acceptIfNotNull(this.cacheLevelName, dmlc::setCacheLevelName)
.acceptIfNotNull(this.cacheLevel, dmlc::setCacheLevel)
.acceptIfHasText(this.concurrency, dmlc::setConcurrency)
.acceptIfNotNull(this.concurrentConsumers, dmlc::setConcurrentConsumers)
.acceptIfNotNull(this.maxConcurrentConsumers, dmlc::setMaxConcurrentConsumers)
.acceptIfNotNull(this.idleTaskExecutionLimit, dmlc::setIdleTaskExecutionLimit)
.acceptIfNotNull(this.maxMessagesPerTask, dmlc::setMaxMessagesPerTask);
dmlc.setPubSubNoLocal(this.pubSubNoLocal);
JavaUtils.INSTANCE
.acceptIfNotNull(this.receiveTimeout, dmlc::setReceiveTimeout)
.acceptIfNotNull(this.recoveryInterval, dmlc::setRecoveryInterval);
.acceptIfNotNull(this.receiveTimeout, dmlc::setReceiveTimeout)
.acceptIfNotNull(this.recoveryInterval, dmlc::setRecoveryInterval);
dmlc.setTaskExecutor(this.taskExecutor);
dmlc.setTransactionManager(this.transactionManager);
JavaUtils.INSTANCE
.acceptIfNotNull(this.transactionName, dmlc::setTransactionName)
.acceptIfNotNull(this.transactionTimeout, dmlc::setTransactionTimeout);
.acceptIfNotNull(this.transactionName, dmlc::setTransactionName)
.acceptIfNotNull(this.transactionTimeout, dmlc::setTransactionTimeout);
}
else if (container instanceof SimpleMessageListenerContainer) {
SimpleMessageListenerContainer smlc = (SimpleMessageListenerContainer) container;
JavaUtils.INSTANCE
.acceptIfHasText(this.concurrency, smlc::setConcurrency)
.acceptIfNotNull(this.concurrentConsumers, smlc::setConcurrentConsumers);
.acceptIfHasText(this.concurrency, smlc::setConcurrency)
.acceptIfNotNull(this.concurrentConsumers, smlc::setConcurrentConsumers);
smlc.setPubSubNoLocal(this.pubSubNoLocal);
smlc.setTaskExecutor(this.taskExecutor);
}

View File

@@ -29,9 +29,9 @@ import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.integration.JavaUtils;
import org.springframework.integration.file.remote.session.SessionFactory;
import org.springframework.integration.file.remote.session.SharedSessionCapable;
import org.springframework.integration.util.JavaUtils;
import org.springframework.util.Assert;
import org.springframework.util.FileCopyUtils;
import org.springframework.util.StringUtils;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2020 the original author or authors.
* Copyright 2014-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.springframework.integration.util.JavaUtils;
import org.springframework.integration.JavaUtils;
import org.springframework.util.Assert;
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,13 +21,13 @@ import org.springframework.beans.factory.config.AbstractFactoryBean;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.ApplicationEventPublisherAware;
import org.springframework.context.SmartLifecycle;
import org.springframework.integration.JavaUtils;
import org.springframework.integration.ip.tcp.connection.AbstractServerConnectionFactory;
import org.springframework.integration.ip.udp.UnicastReceivingChannelAdapter;
import org.springframework.integration.syslog.MessageConverter;
import org.springframework.integration.syslog.inbound.SyslogReceivingChannelAdapterSupport;
import org.springframework.integration.syslog.inbound.TcpSyslogReceivingChannelAdapter;
import org.springframework.integration.syslog.inbound.UdpSyslogReceivingChannelAdapter;
import org.springframework.integration.util.JavaUtils;
import org.springframework.messaging.MessageChannel;
import org.springframework.util.Assert;

View File

@@ -20,7 +20,7 @@ import java.util.Arrays;
import org.springframework.context.Lifecycle;
import org.springframework.context.SmartLifecycle;
import org.springframework.integration.util.JavaUtils;
import org.springframework.integration.JavaUtils;
import org.springframework.scheduling.TaskScheduler;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2020 the original author or authors.
* Copyright 2020-2021 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.
@@ -20,8 +20,8 @@ import java.util.HashMap;
import java.util.Map;
import org.springframework.expression.Expression;
import org.springframework.integration.JavaUtils;
import org.springframework.integration.dsl.MessageHandlerSpec;
import org.springframework.integration.util.JavaUtils;
import org.springframework.integration.ws.AbstractWebServiceOutboundGateway;
import org.springframework.integration.ws.SoapHeaderMapper;
import org.springframework.web.util.DefaultUriBuilderFactory;
@@ -47,7 +47,7 @@ import org.springframework.ws.transport.WebServiceMessageSender;
*/
public abstract class BaseWsOutboundGatewaySpec<
S extends BaseWsOutboundGatewaySpec<S, E>, E extends AbstractWebServiceOutboundGateway>
extends MessageHandlerSpec<S, E> {
extends MessageHandlerSpec<S, E> {
private final Map<String, Expression> uriVariableExpressions = new HashMap<>();
@@ -158,7 +158,7 @@ public abstract class BaseWsOutboundGatewaySpec<
protected E assemble(E gateway) {
gateway.setUriVariableExpressions(this.uriVariableExpressions);
JavaUtils.INSTANCE
.acceptIfNotNull(this.headerMapper, gateway::setHeaderMapper);
.acceptIfNotNull(this.headerMapper, gateway::setHeaderMapper);
gateway.setEncodingMode(this.encodingMode);
gateway.setIgnoreEmptyResponses(this.ignoreEmptyResponses);
gateway.setRequestCallback(this.requestCallback);