Modernize code for diamond, isEmpty & pattern matching
This commit is contained in:
@@ -102,6 +102,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Enrique Rodriguez
|
||||
* @author Meherzad Lahewala
|
||||
* @author Jayadev Sirimamilla
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -387,14 +388,14 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
"'discardChannelName' and 'discardChannel' are mutually exclusive.");
|
||||
BeanFactory beanFactory = getBeanFactory();
|
||||
if (beanFactory != null) {
|
||||
if (this.outputProcessor instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.outputProcessor).setBeanFactory(beanFactory);
|
||||
if (this.outputProcessor instanceof BeanFactoryAware beanFactoryAware) {
|
||||
beanFactoryAware.setBeanFactory(beanFactory);
|
||||
}
|
||||
if (this.correlationStrategy instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.correlationStrategy).setBeanFactory(beanFactory);
|
||||
if (this.correlationStrategy instanceof BeanFactoryAware beanFactoryAware) {
|
||||
beanFactoryAware.setBeanFactory(beanFactory);
|
||||
}
|
||||
if (this.releaseStrategy instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.releaseStrategy).setBeanFactory(beanFactory);
|
||||
if (this.releaseStrategy instanceof BeanFactoryAware beanFactoryAware) {
|
||||
beanFactoryAware.setBeanFactory(beanFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -422,8 +423,8 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
this.lockRegistrySet = true;
|
||||
this.forceReleaseProcessor = createGroupTimeoutProcessor();
|
||||
|
||||
if (this.releaseStrategy instanceof GroupConditionProvider) {
|
||||
this.groupConditionSupplier = ((GroupConditionProvider) this.releaseStrategy).getGroupConditionSupplier();
|
||||
if (this.releaseStrategy instanceof GroupConditionProvider groupConditionProvider) {
|
||||
this.groupConditionSupplier = groupConditionProvider.getGroupConditionSupplier();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,8 +672,8 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
*/
|
||||
if (groupTimeout != null) {
|
||||
Date startTime = null;
|
||||
if (groupTimeout instanceof Date) {
|
||||
startTime = (Date) groupTimeout;
|
||||
if (groupTimeout instanceof Date date) {
|
||||
startTime = date;
|
||||
}
|
||||
else if ((Long) groupTimeout > 0) {
|
||||
startTime = new Date(System.currentTimeMillis() + (Long) groupTimeout);
|
||||
@@ -976,11 +977,11 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
public void start() {
|
||||
if (!this.running) {
|
||||
this.running = true;
|
||||
if (this.outputProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.outputProcessor).start();
|
||||
if (this.outputProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.start();
|
||||
}
|
||||
if (this.releaseStrategy instanceof Lifecycle) {
|
||||
((Lifecycle) this.releaseStrategy).start();
|
||||
if (this.releaseStrategy instanceof Lifecycle lifecycle) {
|
||||
lifecycle.start();
|
||||
}
|
||||
if (this.expireTimeout > 0) {
|
||||
purgeOrphanedGroups();
|
||||
@@ -996,11 +997,11 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
public void stop() {
|
||||
if (this.running) {
|
||||
this.running = false;
|
||||
if (this.outputProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.outputProcessor).stop();
|
||||
if (this.outputProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
if (this.releaseStrategy instanceof Lifecycle) {
|
||||
((Lifecycle) this.releaseStrategy).stop();
|
||||
if (this.releaseStrategy instanceof Lifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1033,8 +1034,8 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
||||
*/
|
||||
super(messageGroup.getMessages(), null, messageGroup.getGroupId(), messageGroup.getTimestamp(),
|
||||
messageGroup.isComplete(), true);
|
||||
if (messageGroup instanceof SimpleMessageGroup) {
|
||||
this.sourceGroup = (SimpleMessageGroup) messageGroup;
|
||||
if (messageGroup instanceof SimpleMessageGroup simpleMessageGroup) {
|
||||
this.sourceGroup = simpleMessageGroup;
|
||||
}
|
||||
else {
|
||||
this.sourceGroup = null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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 org.springframework.messaging.Message;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -103,8 +104,8 @@ public class AggregatingMessageHandler extends AbstractCorrelatingMessageHandler
|
||||
remove(messageGroup);
|
||||
}
|
||||
else {
|
||||
if (messageStore instanceof SimpleMessageStore) {
|
||||
((SimpleMessageStore) messageStore).clearMessageGroup(groupId);
|
||||
if (messageStore instanceof SimpleMessageStore simpleMessageStore) {
|
||||
simpleMessageStore.clearMessageGroup(groupId);
|
||||
}
|
||||
else {
|
||||
messageStore.removeMessagesFromGroup(groupId, messageGroup.getMessages());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 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 org.springframework.messaging.Message;
|
||||
* @author Dave Syer
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -42,7 +43,7 @@ public class ResequencingMessageGroupProcessor implements MessageGroupProcessor
|
||||
public Object processMessageGroup(MessageGroup group) {
|
||||
Collection<Message<?>> messages = group.getMessages();
|
||||
|
||||
if (messages.size() > 0) {
|
||||
if (!messages.isEmpty()) {
|
||||
List<Message<?>> sorted = new ArrayList<>(messages);
|
||||
sorted.sort(this.comparator);
|
||||
ArrayList<Message<?>> partialSequence = new ArrayList<>();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2021 the original author or authors.
|
||||
* Copyright 2015-2024 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.springframework.util.CollectionUtils;
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.2
|
||||
*
|
||||
@@ -185,8 +186,7 @@ public abstract class AbstractExecutorChannel extends AbstractSubscribableChanne
|
||||
private Message<?> applyBeforeHandle(Message<?> message, Deque<ExecutorChannelInterceptor> interceptorStack) {
|
||||
Message<?> theMessage = message;
|
||||
for (ChannelInterceptor interceptor : AbstractExecutorChannel.this.interceptors.interceptors) {
|
||||
if (interceptor instanceof ExecutorChannelInterceptor) {
|
||||
ExecutorChannelInterceptor executorInterceptor = (ExecutorChannelInterceptor) interceptor;
|
||||
if (interceptor instanceof ExecutorChannelInterceptor executorInterceptor) {
|
||||
theMessage = executorInterceptor.beforeHandle(theMessage, AbstractExecutorChannel.this,
|
||||
this.delegate.getMessageHandler());
|
||||
if (theMessage == null) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2022 the original author or authors.
|
||||
* Copyright 2015-2024 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,6 +35,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author David Turanski
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
@@ -63,7 +64,7 @@ public abstract class AbstractKryoCodec implements Codec {
|
||||
Assert.notNull(outputStream, "'outputSteam' cannot be null");
|
||||
|
||||
Kryo kryo = this.pool.obtain();
|
||||
try (Output output = (outputStream instanceof Output ? (Output) outputStream : new Output(outputStream))) {
|
||||
try (Output output = (outputStream instanceof Output castOutput ? castOutput : new Output(outputStream))) {
|
||||
doEncode(kryo, object, output);
|
||||
}
|
||||
finally {
|
||||
@@ -86,7 +87,7 @@ public abstract class AbstractKryoCodec implements Codec {
|
||||
Assert.notNull(type, "'type' cannot be null");
|
||||
|
||||
Kryo kryo = this.pool.obtain();
|
||||
try (Input input = (inputStream instanceof Input ? (Input) inputStream : new Input(inputStream))) {
|
||||
try (Input input = (inputStream instanceof Input castInput ? castInput : new Input(inputStream))) {
|
||||
return doDecode(kryo, input, type);
|
||||
}
|
||||
finally {
|
||||
|
||||
@@ -118,6 +118,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Chris Bono
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation>
|
||||
implements MethodAnnotationPostProcessor<T>, BeanFactoryAware {
|
||||
@@ -447,8 +448,8 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
&& StringUtils.hasText(MessagingAnnotationUtils.endpointIdValue(method))) {
|
||||
handlerBeanName = handlerBeanName + ".wrapper";
|
||||
}
|
||||
if (handler instanceof IntegrationObjectSupport) {
|
||||
((IntegrationObjectSupport) handler).setComponentName(
|
||||
if (handler instanceof IntegrationObjectSupport integrationObjectSupport) {
|
||||
integrationObjectSupport.setComponentName(
|
||||
handlerBeanName.substring(0,
|
||||
handlerBeanName.indexOf(IntegrationConfigUtils.HANDLER_ALIAS_SUFFIX)));
|
||||
}
|
||||
@@ -464,8 +465,8 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
String resolvedValue = this.beanFactory.resolveEmbeddedValue(sendTimeout);
|
||||
if (resolvedValue != null) {
|
||||
long value = Long.parseLong(resolvedValue);
|
||||
if (handler instanceof AbstractMessageProducingHandler) {
|
||||
((AbstractMessageProducingHandler) handler).setSendTimeout(value);
|
||||
if (handler instanceof AbstractMessageProducingHandler abstractMessageProducingHandler) {
|
||||
abstractMessageProducingHandler.setSendTimeout(value);
|
||||
}
|
||||
else {
|
||||
((AbstractMessageRouter) handler).setSendTimeout(value);
|
||||
@@ -490,8 +491,8 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
advisor.setPointcut(pointcut);
|
||||
advisor.setBeanFactory(this.beanFactory);
|
||||
|
||||
if (handler instanceof Advised) {
|
||||
((Advised) handler).addAdvisor(advisor);
|
||||
if (handler instanceof Advised advised) {
|
||||
advised.addAdvisor(advisor);
|
||||
}
|
||||
else {
|
||||
ProxyFactory proxyFactory = new ProxyFactory(handler);
|
||||
@@ -507,8 +508,8 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
MessageHandler handler = handlerArg;
|
||||
List<Advice> adviceChain = extractAdviceChain(beanName, annotations);
|
||||
|
||||
if (!CollectionUtils.isEmpty(adviceChain) && handler instanceof AbstractReplyProducingMessageHandler) {
|
||||
((AbstractReplyProducingMessageHandler) handler).setAdviceChain(adviceChain);
|
||||
if (!CollectionUtils.isEmpty(adviceChain) && handler instanceof AbstractReplyProducingMessageHandler abstractReplyProducingMessageHandler) {
|
||||
abstractReplyProducingMessageHandler.setAdviceChain(adviceChain);
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(adviceChain)) {
|
||||
@@ -516,8 +517,8 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
if (advice instanceof HandleMessageAdvice) {
|
||||
NameMatchMethodPointcutAdvisor handlerAdvice = new NameMatchMethodPointcutAdvisor(advice);
|
||||
handlerAdvice.addMethodName("handleMessage");
|
||||
if (handler instanceof Advised) {
|
||||
((Advised) handler).addAdvisor(handlerAdvice);
|
||||
if (handler instanceof Advised advised) {
|
||||
advised.addAdvisor(handlerAdvice);
|
||||
}
|
||||
else {
|
||||
ProxyFactory proxyFactory = new ProxyFactory(handler);
|
||||
@@ -543,11 +544,11 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
adviceChain = new ArrayList<>();
|
||||
for (String adviceChainName : adviceChainNames) {
|
||||
Object adviceChainBean = this.beanFactory.getBean(adviceChainName);
|
||||
if (adviceChainBean instanceof Advice) {
|
||||
adviceChain.add((Advice) adviceChainBean);
|
||||
if (adviceChainBean instanceof Advice advice) {
|
||||
adviceChain.add(advice);
|
||||
}
|
||||
else if (adviceChainBean instanceof Advice[]) {
|
||||
Collections.addAll(adviceChain, (Advice[]) adviceChainBean);
|
||||
else if (adviceChainBean instanceof Advice[] advices) {
|
||||
Collections.addAll(adviceChain, advices);
|
||||
}
|
||||
else if (adviceChainBean instanceof Collection) {
|
||||
@SuppressWarnings(UNCHECKED)
|
||||
@@ -604,11 +605,11 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
if (inputChannel instanceof Publisher || handler instanceof ReactiveMessageHandlerAdapter || reactive != null) {
|
||||
return reactiveStreamsConsumer(inputChannel, handler, reactive);
|
||||
}
|
||||
else if (inputChannel instanceof SubscribableChannel) {
|
||||
else if (inputChannel instanceof SubscribableChannel subscribableChannel) {
|
||||
Assert.state(poller == null, () ->
|
||||
"A '@Poller' should not be specified for Annotation-based " +
|
||||
"endpoint, since '" + inputChannel + "' is a SubscribableChannel (not pollable).");
|
||||
return new EventDrivenConsumer((SubscribableChannel) inputChannel, handler);
|
||||
return new EventDrivenConsumer(subscribableChannel, handler);
|
||||
}
|
||||
else if (inputChannel instanceof PollableChannel) {
|
||||
return pollingConsumer(inputChannel, handler, poller);
|
||||
@@ -624,9 +625,9 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
Reactive reactive) {
|
||||
|
||||
ReactiveStreamsConsumer reactiveStreamsConsumer;
|
||||
if (handler instanceof ReactiveMessageHandlerAdapter) {
|
||||
if (handler instanceof ReactiveMessageHandlerAdapter reactiveMessageHandlerAdapter) {
|
||||
reactiveStreamsConsumer = new ReactiveStreamsConsumer(channel,
|
||||
((ReactiveMessageHandlerAdapter) handler).getDelegate());
|
||||
reactiveMessageHandlerAdapter.getDelegate());
|
||||
}
|
||||
else {
|
||||
reactiveStreamsConsumer = new ReactiveStreamsConsumer(channel, handler);
|
||||
@@ -696,8 +697,8 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
}
|
||||
pollingEndpoint.setMaxMessagesPerPoll(maxMessagesPerPoll);
|
||||
pollingEndpoint.setErrorHandler(pollerMetadata.getErrorHandler());
|
||||
if (pollingEndpoint instanceof PollingConsumer) {
|
||||
((PollingConsumer) pollingEndpoint).setReceiveTimeout(pollerMetadata.getReceiveTimeout());
|
||||
if (pollingEndpoint instanceof PollingConsumer pollingConsumer) {
|
||||
pollingConsumer.setReceiveTimeout(pollerMetadata.getReceiveTimeout());
|
||||
}
|
||||
pollingEndpoint.setTransactionSynchronizationFactory(pollerMetadata.getTransactionSynchronizationFactory());
|
||||
}
|
||||
@@ -834,10 +835,10 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
}
|
||||
|
||||
private static void orderable(Method method, MessageHandler handler) {
|
||||
if (handler instanceof Orderable) {
|
||||
if (handler instanceof Orderable orderable) {
|
||||
Order orderAnnotation = AnnotationUtils.findAnnotation(method, Order.class);
|
||||
if (orderAnnotation != null) {
|
||||
((Orderable) handler).setOrder(orderAnnotation.value());
|
||||
orderable.setOrder(orderAnnotation.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -61,6 +61,7 @@ import org.springframework.util.CollectionUtils;
|
||||
* @author Artem Bilan
|
||||
* @author David Liu
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageHandler>
|
||||
implements FactoryBean<MessageHandler>, ApplicationContextAware, BeanFactoryAware, BeanNameAware,
|
||||
@@ -251,13 +252,13 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageH
|
||||
|
||||
private void adviceChain(Object actualHandler) {
|
||||
if (!CollectionUtils.isEmpty(this.adviceChain)) {
|
||||
if (actualHandler instanceof AbstractReplyProducingMessageHandler) {
|
||||
((AbstractReplyProducingMessageHandler) actualHandler).setAdviceChain(this.adviceChain);
|
||||
if (actualHandler instanceof AbstractReplyProducingMessageHandler abstractReplyProducingMessageHandler) {
|
||||
abstractReplyProducingMessageHandler.setAdviceChain(this.adviceChain);
|
||||
}
|
||||
else if (this.logger.isDebugEnabled()) {
|
||||
String name = this.componentName;
|
||||
if (name == null && actualHandler instanceof NamedComponent) {
|
||||
name = ((NamedComponent) actualHandler).getBeanName();
|
||||
if (name == null && actualHandler instanceof NamedComponent namedComponent) {
|
||||
name = namedComponent.getBeanName();
|
||||
}
|
||||
this.logger.debug("adviceChain can only be set on an AbstractReplyProducingMessageHandler"
|
||||
+ (name == null ? "" : (", " + name)) + ".");
|
||||
@@ -266,9 +267,9 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageH
|
||||
}
|
||||
|
||||
private void initializingBean() {
|
||||
if (this.handler instanceof InitializingBean) {
|
||||
if (this.handler instanceof InitializingBean initializingBean) {
|
||||
try {
|
||||
((InitializingBean) this.handler).afterPropertiesSet();
|
||||
initializingBean.afterPropertiesSet();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new BeanInitializationException("failed to initialize MessageHandler", e);
|
||||
@@ -277,8 +278,7 @@ public abstract class AbstractSimpleMessageHandlerFactoryBean<H extends MessageH
|
||||
}
|
||||
|
||||
private void configureOutputChannelIfAny() {
|
||||
if (this.handler instanceof MessageProducer) {
|
||||
MessageProducer messageProducer = (MessageProducer) this.handler;
|
||||
if (this.handler instanceof MessageProducer messageProducer) {
|
||||
if (this.outputChannel != null) {
|
||||
messageProducer.setOutputChannel(this.outputChannel);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 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,6 +39,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author David Liu
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractStandardMessageHandlerFactoryBean
|
||||
extends AbstractSimpleMessageHandlerFactoryBean<MessageHandler> implements DisposableBean {
|
||||
@@ -207,8 +208,8 @@ public abstract class AbstractStandardMessageHandlerFactoryBean
|
||||
}
|
||||
|
||||
if (this.requiresReply != null) {
|
||||
if (handler instanceof AbstractReplyProducingMessageHandler) {
|
||||
((AbstractReplyProducingMessageHandler) handler).setRequiresReply(this.requiresReply);
|
||||
if (handler instanceof AbstractReplyProducingMessageHandler abstractReplyProducingMessageHandler) {
|
||||
abstractReplyProducingMessageHandler.setRequiresReply(this.requiresReply);
|
||||
}
|
||||
else {
|
||||
if (this.requiresReply && logger.isDebugEnabled()) {
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.2
|
||||
*
|
||||
@@ -197,8 +198,8 @@ public class AggregatorFactoryBean extends AbstractSimpleMessageHandlerFactoryBe
|
||||
@Override
|
||||
protected AggregatingMessageHandler createHandler() {
|
||||
MessageGroupProcessor outputProcessor;
|
||||
if (this.processorBean instanceof MessageGroupProcessor) {
|
||||
outputProcessor = (MessageGroupProcessor) this.processorBean;
|
||||
if (this.processorBean instanceof MessageGroupProcessor messageGroupProcessor) {
|
||||
outputProcessor = messageGroupProcessor;
|
||||
}
|
||||
else {
|
||||
if (!StringUtils.hasText(this.methodName)) {
|
||||
@@ -210,8 +211,8 @@ public class AggregatorFactoryBean extends AbstractSimpleMessageHandlerFactoryBe
|
||||
}
|
||||
|
||||
if (this.headersFunction != null) {
|
||||
if (outputProcessor instanceof AbstractAggregatingMessageGroupProcessor) {
|
||||
((AbstractAggregatingMessageGroupProcessor) outputProcessor).setHeadersFunction(this.headersFunction);
|
||||
if (outputProcessor instanceof AbstractAggregatingMessageGroupProcessor abstractAggregatingMessageGroupProcessor) {
|
||||
abstractAggregatingMessageGroupProcessor.setHeadersFunction(this.headersFunction);
|
||||
}
|
||||
else {
|
||||
outputProcessor = new DelegatingMessageGroupProcessor(outputProcessor, this.headersFunction);
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.springframework.util.Assert;
|
||||
* Used to post process candidates for {@link FixedSubscriberChannel}
|
||||
* {@link org.springframework.messaging.MessageHandler}s.
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
* @since 4.0
|
||||
*
|
||||
*/
|
||||
@@ -47,7 +48,7 @@ public final class FixedSubscriberChannelBeanFactoryPostProcessor implements Bea
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
if (beanFactory instanceof BeanDefinitionRegistry) {
|
||||
BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory;
|
||||
if (this.candidateFixedChannelHandlerMap.size() > 0) {
|
||||
if (!this.candidateFixedChannelHandlerMap.isEmpty()) {
|
||||
for (Entry<String, String> entry : this.candidateFixedChannelHandlerMap.entrySet()) {
|
||||
String handlerName = entry.getKey();
|
||||
String channelName = entry.getValue();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -33,6 +33,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Gary Russell
|
||||
* @author David Liu
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class TransformerFactoryBean extends AbstractStandardMessageHandlerFactoryBean {
|
||||
|
||||
@@ -44,8 +45,8 @@ public class TransformerFactoryBean extends AbstractStandardMessageHandlerFactor
|
||||
protected MessageHandler createMethodInvokingHandler(Object targetObject, String targetMethodName) {
|
||||
Assert.notNull(targetObject, "targetObject must not be null");
|
||||
Transformer transformer = null;
|
||||
if (targetObject instanceof Transformer) {
|
||||
transformer = (Transformer) targetObject;
|
||||
if (targetObject instanceof Transformer castTransformer) {
|
||||
transformer = castTransformer;
|
||||
}
|
||||
else {
|
||||
this.checkForIllegalTarget(targetObject, targetMethodName);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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,6 +42,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractOutboundChannelAdapterParser extends AbstractChannelAdapterParser {
|
||||
|
||||
@@ -99,8 +100,7 @@ public abstract class AbstractOutboundChannelAdapterParser extends AbstractChann
|
||||
boolean isReplyProducer = this.isUsingReplyProducer();
|
||||
if (!isReplyProducer) {
|
||||
Class<?> beanClass = null;
|
||||
if (handlerBeanDefinition instanceof AbstractBeanDefinition) {
|
||||
AbstractBeanDefinition abstractBeanDefinition = (AbstractBeanDefinition) handlerBeanDefinition;
|
||||
if (handlerBeanDefinition instanceof AbstractBeanDefinition abstractBeanDefinition) {
|
||||
if (abstractBeanDefinition.hasBeanClass()) {
|
||||
beanClass = abstractBeanDefinition.getBeanClass();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 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,6 +34,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* @author Gary Russell
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractPollingInboundChannelAdapterParser extends AbstractChannelAdapterParser {
|
||||
|
||||
@@ -48,13 +49,13 @@ public abstract class AbstractPollingInboundChannelAdapterParser extends Abstrac
|
||||
|
||||
String sourceBeanName = null;
|
||||
|
||||
if (source instanceof BeanDefinition) {
|
||||
if (source instanceof BeanDefinition beanDefinition) {
|
||||
String channelAdapterId = this.resolveId(element, adapterBuilder.getRawBeanDefinition(), parserContext);
|
||||
sourceBeanName = channelAdapterId + ".source";
|
||||
parserContext.getRegistry().registerBeanDefinition(sourceBeanName, (BeanDefinition) source);
|
||||
parserContext.getRegistry().registerBeanDefinition(sourceBeanName, beanDefinition);
|
||||
}
|
||||
else if (source instanceof RuntimeBeanReference) {
|
||||
sourceBeanName = ((RuntimeBeanReference) source).getBeanName();
|
||||
else if (source instanceof RuntimeBeanReference runtimeBeanReference) {
|
||||
sourceBeanName = runtimeBeanReference.getBeanName();
|
||||
}
|
||||
else {
|
||||
parserContext.getReaderContext().error("Wrong 'source' type: must be 'BeanDefinition' or 'RuntimeBeanReference'", source);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 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,6 +34,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractRouterParser extends AbstractConsumerEndpointParser {
|
||||
|
||||
@@ -61,7 +62,7 @@ public abstract class AbstractRouterParser extends AbstractConsumerEndpointParse
|
||||
// check if mapping is provided otherwise returned values will be treated as channel names
|
||||
List<Element> mappingElements = DomUtils.getChildElementsByTagName(element, "mapping");
|
||||
if (!CollectionUtils.isEmpty(mappingElements)) {
|
||||
ManagedMap<String, String> channelMappings = new ManagedMap<String, String>();
|
||||
ManagedMap<String, String> channelMappings = new ManagedMap<>();
|
||||
for (Element mappingElement : mappingElements) {
|
||||
String key = mappingElement.getAttribute(this.getMappingKeyAttributeName());
|
||||
channelMappings.put(key, mappingElement.getAttribute("channel"));
|
||||
|
||||
@@ -51,6 +51,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* @author Artem Bilan
|
||||
* @author Gunnar Hillert
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class ChainParser extends AbstractConsumerEndpointParser {
|
||||
|
||||
@@ -73,8 +74,8 @@ public class ChainParser extends AbstractConsumerEndpointParser {
|
||||
}
|
||||
|
||||
String chainHandlerId = this.resolveId(element, builder.getRawBeanDefinition(), parserContext);
|
||||
List<BeanMetadataElement> handlerList = new ManagedList<BeanMetadataElement>();
|
||||
Set<String> handlerBeanNameSet = new HashSet<String>();
|
||||
List<BeanMetadataElement> handlerList = new ManagedList<>();
|
||||
Set<String> handlerBeanNameSet = new HashSet<>();
|
||||
NodeList children = element.getChildNodes();
|
||||
|
||||
int childOrder = 0;
|
||||
@@ -83,8 +84,8 @@ public class ChainParser extends AbstractConsumerEndpointParser {
|
||||
if (child.getNodeType() == Node.ELEMENT_NODE && !"poller".equals(child.getLocalName())) {
|
||||
BeanMetadataElement childBeanMetadata = this.parseChild(chainHandlerId, (Element) child, childOrder++,
|
||||
parserContext, builder.getBeanDefinition());
|
||||
if (childBeanMetadata instanceof RuntimeBeanReference) {
|
||||
String handlerBeanName = ((RuntimeBeanReference) childBeanMetadata).getBeanName();
|
||||
if (childBeanMetadata instanceof RuntimeBeanReference runtimeBeanReference) {
|
||||
String handlerBeanName = runtimeBeanReference.getBeanName();
|
||||
if (!handlerBeanNameSet.add(handlerBeanName)) {
|
||||
parserContext.getReaderContext().error("A bean definition is already registered for " +
|
||||
"beanName: '" + handlerBeanName + "' within the current <chain>.",
|
||||
|
||||
@@ -37,13 +37,14 @@ import org.springframework.beans.factory.xml.ParserContext;
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class ChannelInterceptorParser {
|
||||
|
||||
private final Map<String, BeanDefinitionRegisteringParser> parsers;
|
||||
|
||||
public ChannelInterceptorParser() {
|
||||
this.parsers = new HashMap<String, BeanDefinitionRegisteringParser>();
|
||||
this.parsers = new HashMap<>();
|
||||
this.parsers.put("wire-tap", new WireTapParser());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 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,6 +43,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* @author Liujiong
|
||||
* @author Kris Jacyna
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
* @since 2.1
|
||||
*/
|
||||
public class EnricherParser extends AbstractConsumerEndpointParser {
|
||||
@@ -107,10 +108,10 @@ public class EnricherParser extends AbstractConsumerEndpointParser {
|
||||
nullResultExpression, hasAttributeValue, hasAttributeExpression,
|
||||
hasAttributeNullResultExpression);
|
||||
}
|
||||
if (expressions.size() > 0) {
|
||||
if (!expressions.isEmpty()) {
|
||||
builder.addPropertyValue("propertyExpressions", expressions);
|
||||
}
|
||||
if (nullResultExpressions.size() > 0) {
|
||||
if (!nullResultExpressions.isEmpty()) {
|
||||
builder.addPropertyValue("nullResultPropertyExpressions", nullResultExpressions);
|
||||
}
|
||||
}
|
||||
@@ -183,10 +184,10 @@ public class EnricherParser extends AbstractConsumerEndpointParser {
|
||||
headerExpression(parserContext, expressions, nullResultHeaderExpressions, subElement, name,
|
||||
valueElementValue, hasAttributeValue, hasAttributeExpression, hasAttributeNullResultExpression);
|
||||
}
|
||||
if (expressions.size() > 0) {
|
||||
if (!expressions.isEmpty()) {
|
||||
builder.addPropertyValue("headerExpressions", expressions);
|
||||
}
|
||||
if (nullResultHeaderExpressions.size() > 0) {
|
||||
if (!nullResultHeaderExpressions.isEmpty()) {
|
||||
builder.addPropertyValue("nullResultHeaderExpressions", nullResultHeaderExpressions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2024 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,6 +42,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
* @since 2.0
|
||||
*/
|
||||
public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
|
||||
@@ -89,7 +90,7 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
|
||||
|
||||
// set headersMap
|
||||
Map<String, String> headerExpressions = headerExpressions(parserContext, mapping);
|
||||
if (headerExpressions.size() > 0) {
|
||||
if (!headerExpressions.isEmpty()) {
|
||||
headersExpressionMap.put(methodPattern, headerExpressions);
|
||||
}
|
||||
|
||||
@@ -100,14 +101,14 @@ public class PublishingInterceptorParser extends AbstractBeanDefinitionParser {
|
||||
resolvableChannelMap.put(channel, new RuntimeBeanReference(channel));
|
||||
}
|
||||
}
|
||||
if (payloadExpressionMap.size() == 0) {
|
||||
if (payloadExpressionMap.isEmpty()) {
|
||||
payloadExpressionMap.put("*", "#return");
|
||||
}
|
||||
interceptorMappings.put(PAYLOAD, payloadExpressionMap);
|
||||
if (headersExpressionMap.size() > 0) {
|
||||
if (!headersExpressionMap.isEmpty()) {
|
||||
interceptorMappings.put("headers", headersExpressionMap);
|
||||
}
|
||||
if (channelMap.size() > 0) {
|
||||
if (!channelMap.isEmpty()) {
|
||||
interceptorMappings.put("channels", channelMap);
|
||||
interceptorMappings.put("resolvableChannels", resolvableChannelMap);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.util.xml.DomUtils;
|
||||
*
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Mark Fisher
|
||||
* @author Ngoc Nhan
|
||||
* @since 1.0.3
|
||||
*/
|
||||
public class RecipientListRouterParser extends AbstractRouterParser {
|
||||
@@ -58,7 +59,7 @@ public class RecipientListRouterParser extends AbstractRouterParser {
|
||||
}
|
||||
recipientList.add(recipientBuilder.getBeanDefinition());
|
||||
}
|
||||
if (recipientList.size() > 0) {
|
||||
if (!recipientList.isEmpty()) {
|
||||
recipientListRouterBuilder.addPropertyValue("recipients", recipientList);
|
||||
}
|
||||
return recipientListRouterBuilder.getBeanDefinition();
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.springframework.util.Assert;
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
* @since 2.0
|
||||
*/
|
||||
public class AsyncMessagingTemplate extends MessagingTemplate implements AsyncMessagingOperations {
|
||||
@@ -41,8 +42,8 @@ public class AsyncMessagingTemplate extends MessagingTemplate implements AsyncMe
|
||||
|
||||
public void setExecutor(Executor executor) {
|
||||
Assert.notNull(executor, "executor must not be null");
|
||||
this.executor = (executor instanceof AsyncTaskExecutor) ?
|
||||
(AsyncTaskExecutor) executor : new TaskExecutorAdapter(executor);
|
||||
this.executor = (executor instanceof AsyncTaskExecutor asyncTaskExecutor) ?
|
||||
asyncTaskExecutor : new TaskExecutorAdapter(executor);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.lang.Nullable;
|
||||
* A {@link CorrelationHandlerSpec} for an {@link AggregatingMessageHandler}.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@@ -71,8 +72,8 @@ public class AggregatorSpec extends CorrelationHandlerSpec<AggregatorSpec, Aggre
|
||||
.outputProcessor(methodName != null
|
||||
? new MethodInvokingMessageGroupProcessor(target, methodName)
|
||||
:
|
||||
(target instanceof MessageGroupProcessor
|
||||
? (MessageGroupProcessor) target
|
||||
(target instanceof MessageGroupProcessor messageGroupProcessor
|
||||
? messageGroupProcessor
|
||||
: new MethodInvokingMessageGroupProcessor(target)));
|
||||
}
|
||||
|
||||
@@ -124,8 +125,8 @@ public class AggregatorSpec extends CorrelationHandlerSpec<AggregatorSpec, Aggre
|
||||
public Map<Object, String> getComponentsToRegister() {
|
||||
if (this.headersFunction != null) {
|
||||
MessageGroupProcessor outputProcessor = this.handler.getOutputProcessor();
|
||||
if (outputProcessor instanceof AbstractAggregatingMessageGroupProcessor) {
|
||||
((AbstractAggregatingMessageGroupProcessor) outputProcessor).setHeadersFunction(this.headersFunction);
|
||||
if (outputProcessor instanceof AbstractAggregatingMessageGroupProcessor abstractAggregatingMessageGroupProcessor) {
|
||||
abstractAggregatingMessageGroupProcessor.setHeadersFunction(this.headersFunction);
|
||||
}
|
||||
else {
|
||||
this.handler.setOutputProcessor(
|
||||
|
||||
@@ -111,6 +111,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Gary Russell
|
||||
* @author Gabriele Del Prete
|
||||
* @author Tim Feuerbach
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.2.1
|
||||
*
|
||||
@@ -728,7 +729,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
|
||||
@Nullable Consumer<GenericEndpointSpec<MessageTransformingHandler>> endpointConfigurer) {
|
||||
|
||||
Assert.notNull(genericTransformer, "'genericTransformer' must not be null");
|
||||
Transformer transformer = genericTransformer instanceof Transformer ? (Transformer) genericTransformer :
|
||||
Transformer transformer = genericTransformer instanceof Transformer castTransformer ? castTransformer :
|
||||
(ClassUtils.isLambda(genericTransformer.getClass())
|
||||
? new MethodInvokingTransformer(new LambdaMessageProcessor(genericTransformer, expectedType))
|
||||
: new MethodInvokingTransformer(genericTransformer, ClassUtils.TRANSFORMER_TRANSFORM_METHOD));
|
||||
@@ -900,7 +901,7 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
|
||||
@Nullable Consumer<FilterEndpointSpec> endpointConfigurer) {
|
||||
|
||||
Assert.notNull(genericSelector, "'genericSelector' must not be null");
|
||||
MessageSelector selector = genericSelector instanceof MessageSelector ? (MessageSelector) genericSelector :
|
||||
MessageSelector selector = genericSelector instanceof MessageSelector messageSelector ? messageSelector :
|
||||
(ClassUtils.isLambda(genericSelector.getClass())
|
||||
? new MethodInvokingSelector(new LambdaMessageProcessor(genericSelector, expectedType))
|
||||
: new MethodInvokingSelector(genericSelector, ClassUtils.SELECTOR_ACCEPT_METHOD));
|
||||
@@ -1136,8 +1137,8 @@ public abstract class BaseIntegrationFlowDefinition<B extends BaseIntegrationFlo
|
||||
@Nullable Consumer<GenericEndpointSpec<H>> endpointConfigurer) {
|
||||
|
||||
Assert.notNull(messageHandlerSpec, "'messageHandlerSpec' must not be null");
|
||||
if (messageHandlerSpec instanceof ComponentsRegistration) {
|
||||
addComponents(((ComponentsRegistration) messageHandlerSpec).getComponentsToRegister());
|
||||
if (messageHandlerSpec instanceof ComponentsRegistration componentsRegistration) {
|
||||
addComponents(componentsRegistration.getComponentsToRegister());
|
||||
}
|
||||
return handle(messageHandlerSpec.getObject(), endpointConfigurer);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2023-2023 the original author or authors.
|
||||
* Copyright 2023-2024 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,6 +38,7 @@ import org.springframework.util.Assert;
|
||||
* {@link #processor(MessageProcessorSpec)} or {@link #transformer(GenericTransformer)} must be provided.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 6.2
|
||||
*/
|
||||
@@ -218,7 +219,7 @@ public class TransformerEndpointSpec extends ConsumerEndpointSpec<TransformerEnd
|
||||
}
|
||||
|
||||
private Transformer wrapToTransformerIfAny() {
|
||||
return this.transformer instanceof Transformer ? (Transformer) this.transformer :
|
||||
return this.transformer instanceof Transformer castTransformer ? castTransformer :
|
||||
(ClassUtils.isLambda(this.transformer)
|
||||
? new MethodInvokingTransformer(new LambdaMessageProcessor(this.transformer, this.expectedType))
|
||||
: new MethodInvokingTransformer(this.transformer, ClassUtils.TRANSFORMER_TRANSFORM_METHOD));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -81,6 +81,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Artem Bilan
|
||||
* @author Andreas Baer
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractPollingEndpoint extends AbstractEndpoint implements BeanClassLoaderAware {
|
||||
|
||||
@@ -187,8 +188,8 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement
|
||||
* @since 4.3
|
||||
*/
|
||||
public MessageChannel getDefaultErrorChannel() {
|
||||
if (!this.errorHandlerIsDefault && this.errorHandler instanceof MessagePublishingErrorHandler) {
|
||||
return ((MessagePublishingErrorHandler) this.errorHandler).getDefaultErrorChannel();
|
||||
if (!this.errorHandlerIsDefault && this.errorHandler instanceof MessagePublishingErrorHandler messagePublishingErrorHandler) {
|
||||
return messagePublishingErrorHandler.getDefaultErrorChannel();
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
|
||||
@@ -34,6 +34,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractMessageProcessingSelector
|
||||
implements MessageSelector, BeanFactoryAware, ManageableLifecycle {
|
||||
@@ -53,8 +54,8 @@ public abstract class AbstractMessageProcessingSelector
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
if (this.messageProcessor instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.messageProcessor).setBeanFactory(beanFactory);
|
||||
if (this.messageProcessor instanceof BeanFactoryAware beanFactoryAware) {
|
||||
beanFactoryAware.setBeanFactory(beanFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,21 +73,21 @@ public abstract class AbstractMessageProcessingSelector
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (this.messageProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.messageProcessor).start();
|
||||
if (this.messageProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (this.messageProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.messageProcessor).stop();
|
||||
if (this.messageProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return !(this.messageProcessor instanceof Lifecycle) || ((Lifecycle) this.messageProcessor).isRunning();
|
||||
return !(this.messageProcessor instanceof Lifecycle lifecycle) || lifecycle.isRunning();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Marius Bogoevici
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* since 4.1
|
||||
*/
|
||||
@@ -462,8 +463,8 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
|
||||
Object path = routingSlip.get(routingSlipIndex.get());
|
||||
Object routingSlipPathValue = null;
|
||||
|
||||
if (path instanceof String) {
|
||||
routingSlipPathValue = getBeanFactory().getBean((String) path);
|
||||
if (path instanceof String string) {
|
||||
routingSlipPathValue = getBeanFactory().getBean(string);
|
||||
}
|
||||
else if (path instanceof RoutingSlipRouteStrategy) {
|
||||
routingSlipPathValue = path;
|
||||
@@ -479,7 +480,7 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
|
||||
}
|
||||
else {
|
||||
Object nextPath = ((RoutingSlipRouteStrategy) routingSlipPathValue).getNextPath(requestMessage, reply);
|
||||
if (nextPath != null && (!(nextPath instanceof String) || StringUtils.hasText((String) nextPath))) {
|
||||
if (nextPath != null && (!(nextPath instanceof String string) || StringUtils.hasText(string))) {
|
||||
return nextPath;
|
||||
}
|
||||
else {
|
||||
@@ -540,20 +541,20 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
|
||||
throw new DestinationResolutionException("no output-channel or replyChannel header available");
|
||||
}
|
||||
|
||||
if (replyChannel instanceof MessageChannel) {
|
||||
if (replyChannel instanceof MessageChannel messageChannel) {
|
||||
if (output instanceof Message<?>) {
|
||||
this.messagingTemplate.send((MessageChannel) replyChannel, (Message<?>) output);
|
||||
this.messagingTemplate.send(messageChannel, (Message<?>) output);
|
||||
}
|
||||
else {
|
||||
this.messagingTemplate.convertAndSend((MessageChannel) replyChannel, output);
|
||||
this.messagingTemplate.convertAndSend(messageChannel, output);
|
||||
}
|
||||
}
|
||||
else if (replyChannel instanceof String) {
|
||||
else if (replyChannel instanceof String string) {
|
||||
if (output instanceof Message<?>) {
|
||||
this.messagingTemplate.send((String) replyChannel, (Message<?>) output);
|
||||
this.messagingTemplate.send(string, (Message<?>) output);
|
||||
}
|
||||
else {
|
||||
this.messagingTemplate.convertAndSend((String) replyChannel, output);
|
||||
this.messagingTemplate.convertAndSend(string, output);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -44,6 +44,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @author David Liu
|
||||
* @author Trung Pham
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractReplyProducingMessageHandler extends AbstractMessageProducingHandler
|
||||
implements BeanClassLoaderAware {
|
||||
@@ -91,7 +92,7 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
|
||||
}
|
||||
|
||||
protected boolean hasAdviceChain() {
|
||||
return this.adviceChain.size() > 0;
|
||||
return !this.adviceChain.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,6 +46,7 @@ import org.springframework.util.CollectionUtils;
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
@@ -136,8 +137,8 @@ public class ExpressionCommandMessageProcessor extends AbstractMessageProcessor<
|
||||
}
|
||||
}
|
||||
List<Method> supportedMethods = this.methodFilter.filter(candidates);
|
||||
if (supportedMethods.size() == 0) {
|
||||
String methodDescription = (candidates.size() > 0) ? candidates.get(0).toString() : name;
|
||||
if (supportedMethods.isEmpty()) {
|
||||
String methodDescription = (!candidates.isEmpty()) ? candidates.get(0).toString() : name;
|
||||
throw new EvaluationException("The method '" + methodDescription +
|
||||
"' is not supported by this command processor. " +
|
||||
"If using the Control Bus, consider adding @ManagedOperation or @ManagedAttribute.");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2024 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,6 +36,7 @@ import org.springframework.messaging.MessagingException;
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
* @since 2.2
|
||||
*/
|
||||
public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupport
|
||||
@@ -162,8 +163,8 @@ public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupp
|
||||
* If we don't copy the invocation carefully it won't keep a reference to the other
|
||||
* interceptors in the chain.
|
||||
*/
|
||||
if (this.invocation instanceof ProxyMethodInvocation) {
|
||||
return ((ProxyMethodInvocation) this.invocation).invocableClone().proceed();
|
||||
if (this.invocation instanceof ProxyMethodInvocation proxyMethodInvocation) {
|
||||
return proxyMethodInvocation.invocableClone().proceed();
|
||||
}
|
||||
else {
|
||||
throw new IllegalStateException(
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* The default cache {@code key} is {@code payload} of the request message.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 5.2
|
||||
*
|
||||
@@ -198,8 +199,7 @@ public class CacheRequestHandlerAdvice extends AbstractRequestHandlerAdvice
|
||||
.filter((operation) -> ObjectUtils.isEmpty(operation.getCacheNames()))
|
||||
.map((operation) -> {
|
||||
CacheOperation.Builder builder;
|
||||
if (operation instanceof CacheableOperation) {
|
||||
CacheableOperation cacheableOperation = (CacheableOperation) operation;
|
||||
if (operation instanceof CacheableOperation cacheableOperation) {
|
||||
CacheableOperation.Builder cacheableBuilder = new CacheableOperation.Builder();
|
||||
cacheableBuilder.setSync(cacheableOperation.isSync());
|
||||
String unless = cacheableOperation.getUnless();
|
||||
@@ -208,9 +208,8 @@ public class CacheRequestHandlerAdvice extends AbstractRequestHandlerAdvice
|
||||
}
|
||||
builder = cacheableBuilder;
|
||||
}
|
||||
else if (operation instanceof CacheEvictOperation) {
|
||||
else if (operation instanceof CacheEvictOperation cacheEvictOperation) {
|
||||
CacheEvictOperation.Builder cacheEvictBuilder = new CacheEvictOperation.Builder();
|
||||
CacheEvictOperation cacheEvictOperation = (CacheEvictOperation) operation;
|
||||
cacheEvictBuilder.setBeforeInvocation(cacheEvictOperation.isBeforeInvocation());
|
||||
cacheEvictBuilder.setCacheWide(cacheEvictOperation.isCacheWide());
|
||||
builder = cacheEvictBuilder;
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Trung Pham
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -372,25 +373,25 @@ public abstract class AbstractMappingMessageRouter extends AbstractMessageRouter
|
||||
|
||||
private void addChannelKeyToCollection(Collection<MessageChannel> channels, Message<?> message, Object channelKey) {
|
||||
ConversionService conversionService = getRequiredConversionService();
|
||||
if (channelKey instanceof MessageChannel) {
|
||||
channels.add((MessageChannel) channelKey);
|
||||
if (channelKey instanceof MessageChannel messageChannel) {
|
||||
channels.add(messageChannel);
|
||||
}
|
||||
else if (channelKey instanceof MessageChannel[]) {
|
||||
channels.addAll(Arrays.asList((MessageChannel[]) channelKey));
|
||||
else if (channelKey instanceof MessageChannel[] messageChannels) {
|
||||
channels.addAll(Arrays.asList(messageChannels));
|
||||
}
|
||||
else if (channelKey instanceof String) {
|
||||
addChannelFromString(channels, (String) channelKey, message);
|
||||
else if (channelKey instanceof String string) {
|
||||
addChannelFromString(channels, string, message);
|
||||
}
|
||||
else if (channelKey instanceof Class) {
|
||||
addChannelFromString(channels, ((Class<?>) channelKey).getName(), message);
|
||||
else if (channelKey instanceof Class<?> cls) {
|
||||
addChannelFromString(channels, cls.getName(), message);
|
||||
}
|
||||
else if (channelKey instanceof String[]) {
|
||||
for (String indicatorName : (String[]) channelKey) {
|
||||
else if (channelKey instanceof String[] strings) {
|
||||
for (String indicatorName : strings) {
|
||||
addChannelFromString(channels, indicatorName, message);
|
||||
}
|
||||
}
|
||||
else if (channelKey instanceof Collection) {
|
||||
addToCollection(channels, (Collection<?>) channelKey, message);
|
||||
else if (channelKey instanceof Collection<?> collection) {
|
||||
addToCollection(channels, collection, message);
|
||||
}
|
||||
else if (conversionService.canConvert(channelKey.getClass(), String.class)) {
|
||||
String converted = conversionService.convert(channelKey, String.class);
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.util.Assert;
|
||||
* {@link MessageProcessor} instance.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Ngoc Nhan
|
||||
* @since 2.0
|
||||
*/
|
||||
class AbstractMessageProcessingRouter extends AbstractMappingMessageRouter
|
||||
@@ -54,28 +55,28 @@ class AbstractMessageProcessingRouter extends AbstractMappingMessageRouter
|
||||
((AbstractMessageProcessor<?>) this.messageProcessor).setConversionService(conversionService);
|
||||
}
|
||||
}
|
||||
if (this.messageProcessor instanceof BeanFactoryAware && this.getBeanFactory() != null) {
|
||||
((BeanFactoryAware) this.messageProcessor).setBeanFactory(this.getBeanFactory());
|
||||
if (this.messageProcessor instanceof BeanFactoryAware beanFactoryAware && this.getBeanFactory() != null) {
|
||||
beanFactoryAware.setBeanFactory(this.getBeanFactory());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (this.messageProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.messageProcessor).start();
|
||||
if (this.messageProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (this.messageProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.messageProcessor).stop();
|
||||
if (this.messageProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return !(this.messageProcessor instanceof Lifecycle) || ((Lifecycle) this.messageProcessor).isRunning();
|
||||
return !(this.messageProcessor instanceof Lifecycle lifecycle) || lifecycle.isRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@@ -67,7 +68,7 @@ abstract class AbstractMessageProcessingSplitter extends AbstractMessageSplitter
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return !(this.processor instanceof Lifecycle) || ((Lifecycle) this.processor).isRunning();
|
||||
return !(this.processor instanceof Lifecycle lifecycle) || lifecycle.isRunning();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Artem Bilan
|
||||
* @author Ruslan Stelmachenko
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractMessageSplitter extends AbstractReplyProducingMessageHandler
|
||||
implements DiscardingMessageHandler {
|
||||
@@ -223,7 +224,7 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess
|
||||
Function<Object, ?> messageBuilderFunction = prepareMessageBuilderFunction(message, sequenceSize);
|
||||
|
||||
return new FunctionIterator<>(
|
||||
result instanceof AutoCloseable && !result.equals(iterator) ? (AutoCloseable) result : null,
|
||||
result instanceof AutoCloseable autoCloseable && !result.equals(iterator) ? autoCloseable : null,
|
||||
iterator, messageBuilderFunction);
|
||||
}
|
||||
|
||||
@@ -314,17 +315,16 @@ public abstract class AbstractMessageSplitter extends AbstractReplyProducingMess
|
||||
|
||||
@Override
|
||||
protected void produceOutput(Object result, Message<?> requestMessage) {
|
||||
if (result instanceof Iterator<?>) {
|
||||
Iterator<?> iterator = (Iterator<?>) result;
|
||||
if (result instanceof Iterator<?> iterator) {
|
||||
try {
|
||||
while (iterator.hasNext()) {
|
||||
super.produceOutput(iterator.next(), requestMessage);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (iterator instanceof AutoCloseable) {
|
||||
if (iterator instanceof AutoCloseable autoCloseable) {
|
||||
try {
|
||||
((AutoCloseable) iterator).close();
|
||||
autoCloseable.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
// ignored
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.util.Assert;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -107,11 +108,11 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
|
||||
}
|
||||
|
||||
private Message<?> extractMessage(Object object) {
|
||||
if (object instanceof MessageHolder) {
|
||||
return ((MessageHolder) object).getMessage();
|
||||
if (object instanceof MessageHolder messageHolder) {
|
||||
return messageHolder.getMessage();
|
||||
}
|
||||
else if (object instanceof Message) {
|
||||
return (Message<?>) object;
|
||||
else if (object instanceof Message<?> message) {
|
||||
return message;
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(
|
||||
@@ -126,8 +127,8 @@ public abstract class AbstractKeyValueMessageStore extends AbstractMessageGroupS
|
||||
Object object = doRetrieve(this.messagePrefix + messageId);
|
||||
if (object != null) {
|
||||
extractMessage(object);
|
||||
if (object instanceof MessageHolder) {
|
||||
return ((MessageHolder) object).getMessageMetadata();
|
||||
if (object instanceof MessageHolder messageHolder) {
|
||||
return messageHolder.getMessageMetadata();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2024 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.
|
||||
@@ -33,6 +33,7 @@ import org.springframework.util.Assert;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Laszlo Szabo
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@@ -91,7 +92,7 @@ public class MessageGroupMetadata implements Serializable {
|
||||
}
|
||||
|
||||
public UUID firstId() {
|
||||
if (this.messageIds.size() > 0) {
|
||||
if (!this.messageIds.isEmpty()) {
|
||||
return this.messageIds.get(0);
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2023 the original author or authors.
|
||||
* Copyright 2015-2024 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -55,6 +55,7 @@ import org.springframework.util.MultiValueMap;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.2
|
||||
*
|
||||
@@ -169,7 +170,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
|
||||
* @param role the role.
|
||||
*/
|
||||
public void startLifecyclesInRole(String role) {
|
||||
if (this.lazyLifecycles.size() > 0) {
|
||||
if (!this.lazyLifecycles.isEmpty()) {
|
||||
addLazyLifecycles();
|
||||
}
|
||||
List<SmartLifecycle> componentsInRole = this.lifecycles.get(role);
|
||||
@@ -201,7 +202,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
|
||||
* @param role the role.
|
||||
*/
|
||||
public void stopLifecyclesInRole(String role) {
|
||||
if (this.lazyLifecycles.size() > 0) {
|
||||
if (!this.lazyLifecycles.isEmpty()) {
|
||||
addLazyLifecycles();
|
||||
}
|
||||
List<SmartLifecycle> componentsInRole = this.lifecycles.get(role);
|
||||
@@ -234,7 +235,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
|
||||
* @since 4.3.8
|
||||
*/
|
||||
public Collection<String> getRoles() {
|
||||
if (this.lazyLifecycles.size() > 0) {
|
||||
if (!this.lazyLifecycles.isEmpty()) {
|
||||
addLazyLifecycles();
|
||||
}
|
||||
return Collections.unmodifiableCollection(this.lifecycles.keySet());
|
||||
@@ -270,7 +271,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
|
||||
* @since 4.3.8
|
||||
*/
|
||||
public Map<String, Boolean> getEndpointsRunningStatus(String role) {
|
||||
if (this.lazyLifecycles.size() > 0) {
|
||||
if (!this.lazyLifecycles.isEmpty()) {
|
||||
addLazyLifecycles();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
* Copyright 2002-2024 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 org.springframework.util.Assert;
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 3.0
|
||||
*
|
||||
@@ -43,7 +44,7 @@ public abstract class AbstractJsonInboundMessageMapper<P> implements InboundMess
|
||||
"JSON message is invalid. Expected a message in the format of either " +
|
||||
"{\"headers\":{...},\"payload\":{...}} or {\"payload\":{...}.\"headers\":{...}} but was ";
|
||||
|
||||
protected static final Map<String, Class<?>> DEFAULT_HEADER_TYPES = new HashMap<String, Class<?>>();
|
||||
protected static final Map<String, Class<?>> DEFAULT_HEADER_TYPES = new HashMap<>();
|
||||
|
||||
static {
|
||||
DEFAULT_HEADER_TYPES.put(IntegrationMessageHeaderAccessor.PRIORITY, Integer.class);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2022 the original author or authors.
|
||||
* Copyright 2017-2024 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.MessageHeaders;
|
||||
* The {@link MessageJacksonDeserializer} implementation for the {@link AdviceMessage}.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.3.10
|
||||
*/
|
||||
@@ -46,7 +47,7 @@ public class AdviceMessageJacksonDeserializer extends MessageJacksonDeserializer
|
||||
protected AdviceMessage<?> buildMessage(MutableMessageHeaders headers, Object payload, JsonNode root,
|
||||
DeserializationContext ctxt) throws IOException {
|
||||
Message<?> inputMessage = getMapper().readValue(root.get("inputMessage").traverse(), Message.class);
|
||||
return new AdviceMessage<Object>(payload, (MessageHeaders) headers, inputMessage);
|
||||
return new AdviceMessage<>(payload, (MessageHeaders) headers, inputMessage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@@ -197,8 +198,8 @@ public class TransactionSynchronizationFactoryBean implements FactoryBean<Defaul
|
||||
.acceptIfNotNull(this.afterCommitChannel, processor::setAfterCommitChannel)
|
||||
.acceptIfNotNull(this.afterRollbackChannel, processor::setAfterRollbackChannel);
|
||||
|
||||
if (this.beanFactory instanceof AutowireCapableBeanFactory) {
|
||||
((AutowireCapableBeanFactory) this.beanFactory).initializeBean(processor,
|
||||
if (this.beanFactory instanceof AutowireCapableBeanFactory autowireCapableBeanFactory) {
|
||||
autowireCapableBeanFactory.initializeBean(processor,
|
||||
getClass().getName() + "#" + TransactionSynchronizationFactoryBean.this.counter.incrementAndGet());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2024 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,6 +37,7 @@ import org.springframework.util.ObjectUtils;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public abstract class AbstractMessageProcessingTransformer
|
||||
implements Transformer, BeanFactoryAware, ManageableLifecycle {
|
||||
@@ -61,8 +62,8 @@ public abstract class AbstractMessageProcessingTransformer
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
if (this.messageProcessor instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.messageProcessor).setBeanFactory(beanFactory);
|
||||
if (this.messageProcessor instanceof BeanFactoryAware beanFactoryAware) {
|
||||
beanFactoryAware.setBeanFactory(beanFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,21 +79,21 @@ public abstract class AbstractMessageProcessingTransformer
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (this.messageProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.messageProcessor).start();
|
||||
if (this.messageProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
if (this.messageProcessor instanceof Lifecycle) {
|
||||
((Lifecycle) this.messageProcessor).stop();
|
||||
if (this.messageProcessor instanceof Lifecycle lifecycle) {
|
||||
lifecycle.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRunning() {
|
||||
return !(this.messageProcessor instanceof Lifecycle) || ((Lifecycle) this.messageProcessor).isRunning();
|
||||
return !(this.messageProcessor instanceof Lifecycle lifecycle) || lifecycle.isRunning();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Gary Russell
|
||||
* @author Soby Chacko
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware {
|
||||
|
||||
@@ -61,10 +62,10 @@ public class BeanFactoryTypeConverter implements TypeConverter, BeanFactoryAware
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
if (beanFactory instanceof ConfigurableBeanFactory) {
|
||||
Object typeConverter = ((ConfigurableBeanFactory) beanFactory).getTypeConverter();
|
||||
if (typeConverter instanceof SimpleTypeConverter) {
|
||||
this.delegate = (SimpleTypeConverter) typeConverter;
|
||||
if (beanFactory instanceof ConfigurableBeanFactory configurableBeanFactory) {
|
||||
Object typeConverter = configurableBeanFactory.getTypeConverter();
|
||||
if (typeConverter instanceof SimpleTypeConverter simpleTypeConverter) {
|
||||
this.delegate = simpleTypeConverter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2022 the original author or authors.
|
||||
* Copyright 2014-2024 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.
|
||||
@@ -50,6 +50,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Soby Chacko
|
||||
* @author Artem Bilan
|
||||
* @author Chris Bono
|
||||
* @author Ngoc Nhan
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@@ -177,7 +178,7 @@ public final class MessagingAnnotationUtils {
|
||||
Set<Annotation> visited = new HashSet<>();
|
||||
|
||||
recursiveFindAnnotation(annotationType, messagingAnnotation, annotationChain, visited);
|
||||
if (annotationChain.size() > 0) {
|
||||
if (!annotationChain.isEmpty()) {
|
||||
Collections.reverse(annotationChain);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.util.ClassUtils;
|
||||
* @author Gary Russell
|
||||
* @author Christian Tzolov
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class UUIDConverter implements Converter<Object, UUID> {
|
||||
|
||||
@@ -66,8 +67,8 @@ public class UUIDConverter implements Converter<Object, UUID> {
|
||||
if (input == null) {
|
||||
return null;
|
||||
}
|
||||
if (input instanceof UUID) {
|
||||
return (UUID) input;
|
||||
if (input instanceof UUID uuid) {
|
||||
return uuid;
|
||||
}
|
||||
if (input instanceof String inputText) {
|
||||
if (isValidUuidStringRepresentation(inputText)) {
|
||||
|
||||
@@ -26,11 +26,12 @@ import org.springframework.util.ReflectionUtils.MethodFilter;
|
||||
/**
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
* @author Ngoc Nhan
|
||||
* @since 2.0
|
||||
*/
|
||||
public class UniqueMethodFilter implements MethodFilter {
|
||||
|
||||
private final List<Method> uniqueMethods = new ArrayList<Method>();
|
||||
private final List<Method> uniqueMethods = new ArrayList<>();
|
||||
|
||||
public UniqueMethodFilter(Class<?> targetClass) {
|
||||
Method[] allMethods = ReflectionUtils.getAllDeclaredMethods(targetClass);
|
||||
|
||||
Reference in New Issue
Block a user