Sonar fixes
Hidden fields, `o.s.i.a*` through `o.s.i.j*`.
This commit is contained in:
committed by
Artem Bilan
parent
6eeec50b4a
commit
e40cfe101e
@@ -425,10 +425,10 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
Deque<ChannelInterceptor> interceptorStack = null;
|
||||
boolean sent = false;
|
||||
boolean metricsProcessed = false;
|
||||
MetricsContext metrics = null;
|
||||
boolean countsEnabled = this.countsEnabled;
|
||||
ChannelInterceptorList interceptors = this.interceptors;
|
||||
AbstractMessageChannelMetrics channelMetrics = this.channelMetrics;
|
||||
MetricsContext metricsContext = null;
|
||||
boolean countsAreEnabled = this.countsEnabled;
|
||||
ChannelInterceptorList interceptorList = this.interceptors;
|
||||
AbstractMessageChannelMetrics metrics = this.channelMetrics;
|
||||
SampleFacade sample = null;
|
||||
try {
|
||||
if (this.datatypes.length > 0) {
|
||||
@@ -438,15 +438,15 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
if (debugEnabled) {
|
||||
logger.debug("preSend on channel '" + this + "', message: " + message);
|
||||
}
|
||||
if (interceptors.getSize() > 0) {
|
||||
if (interceptorList.getSize() > 0) {
|
||||
interceptorStack = new ArrayDeque<>();
|
||||
message = interceptors.preSend(message, this, interceptorStack);
|
||||
message = interceptorList.preSend(message, this, interceptorStack);
|
||||
if (message == null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (countsEnabled) {
|
||||
metrics = channelMetrics.beforeSend();
|
||||
if (countsAreEnabled) {
|
||||
metricsContext = metrics.beforeSend();
|
||||
if (this.metricsCaptor != null) {
|
||||
sample = this.metricsCaptor.start();
|
||||
}
|
||||
@@ -454,7 +454,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
if (sample != null) {
|
||||
sample.stop(sendTimer(sent));
|
||||
}
|
||||
channelMetrics.afterSend(metrics, sent);
|
||||
metrics.afterSend(metricsContext, sent);
|
||||
metricsProcessed = true;
|
||||
}
|
||||
else {
|
||||
@@ -465,20 +465,20 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
logger.debug("postSend (sent=" + sent + ") on channel '" + this + "', message: " + message);
|
||||
}
|
||||
if (interceptorStack != null) {
|
||||
interceptors.postSend(message, this, sent);
|
||||
interceptors.afterSendCompletion(message, this, sent, null, interceptorStack);
|
||||
interceptorList.postSend(message, this, sent);
|
||||
interceptorList.afterSendCompletion(message, this, sent, null, interceptorStack);
|
||||
}
|
||||
return sent;
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (countsEnabled && !metricsProcessed) {
|
||||
if (countsAreEnabled && !metricsProcessed) {
|
||||
if (sample != null) {
|
||||
sample.stop(buildSendTimer(false, e.getClass().getSimpleName()));
|
||||
}
|
||||
channelMetrics.afterSend(metrics, false);
|
||||
metrics.afterSend(metricsContext, false);
|
||||
}
|
||||
if (interceptorStack != null) {
|
||||
interceptors.afterSendCompletion(message, this, sent, e, interceptorStack);
|
||||
interceptorList.afterSendCompletion(message, this, sent, e, interceptorStack);
|
||||
}
|
||||
throw IntegrationUtils.wrapInDeliveryExceptionIfNecessary(message,
|
||||
() -> "failed to send Message to channel '" + this.getComponentName() + "'", e);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -85,8 +85,9 @@ public class DirectChannel extends AbstractSubscribableChannel {
|
||||
protected void onInit() {
|
||||
super.onInit();
|
||||
if (this.maxSubscribers == null) {
|
||||
Integer maxSubscribers = this.getIntegrationProperty(IntegrationProperties.CHANNELS_MAX_UNICAST_SUBSCRIBERS, Integer.class);
|
||||
this.setMaxSubscribers(maxSubscribers);
|
||||
Integer max = this.getIntegrationProperty(IntegrationProperties.CHANNELS_MAX_UNICAST_SUBSCRIBERS,
|
||||
Integer.class);
|
||||
this.setMaxSubscribers(max);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -316,17 +316,17 @@ public class ConsumerEndpointFactoryBean
|
||||
if (this.autoStartup != null) {
|
||||
this.endpoint.setAutoStartup(this.autoStartup);
|
||||
}
|
||||
int phase = this.phase;
|
||||
int phaseToSet = this.phase;
|
||||
if (!this.isPhaseSet) {
|
||||
if (this.endpoint instanceof PollingConsumer) {
|
||||
phase = Integer.MAX_VALUE / 2;
|
||||
phaseToSet = Integer.MAX_VALUE / 2;
|
||||
}
|
||||
else {
|
||||
phase = Integer.MIN_VALUE;
|
||||
phaseToSet = Integer.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
this.endpoint.setPhase(phase);
|
||||
this.endpoint.setPhase(phaseToSet);
|
||||
this.endpoint.setRole(this.role);
|
||||
if (this.taskScheduler != null) {
|
||||
this.endpoint.setTaskScheduler(this.taskScheduler);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -117,24 +117,20 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
Assert.notNull(beanFactory, "'beanFactory' must not be null");
|
||||
this.messageHandlerAttributes.add(SEND_TIMEOUT_ATTRIBUTE);
|
||||
this.beanFactory = beanFactory;
|
||||
ConversionService conversionService = this.beanFactory.getConversionService();
|
||||
if (conversionService != null) {
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
else {
|
||||
this.conversionService = DefaultConversionService.getSharedInstance();
|
||||
}
|
||||
this.conversionService = this.beanFactory.getConversionService() != null
|
||||
? this.beanFactory.getConversionService()
|
||||
: DefaultConversionService.getSharedInstance();
|
||||
this.channelResolver = new BeanFactoryChannelResolver(beanFactory);
|
||||
this.annotationType = (Class<T>) GenericTypeResolver.resolveTypeArgument(this.getClass(),
|
||||
MethodAnnotationPostProcessor.class);
|
||||
Disposables disposables = null;
|
||||
Disposables disposablesBean = null;
|
||||
try {
|
||||
disposables = beanFactory.getBean(Disposables.class);
|
||||
disposablesBean = beanFactory.getBean(Disposables.class);
|
||||
}
|
||||
catch (Exception e) {
|
||||
// NOSONAR - only for test cases
|
||||
}
|
||||
this.disposables = disposables;
|
||||
this.disposables = disposablesBean;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2018 the original author or authors.
|
||||
* Copyright 2016-2019 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.
|
||||
@@ -88,9 +88,9 @@ public abstract class EndpointSpec<S extends EndpointSpec<S, F, H>, F extends Be
|
||||
* @see PollerSpec
|
||||
*/
|
||||
public S poller(PollerSpec pollerMetadataSpec) {
|
||||
Map<Object, String> componentsToRegister = pollerMetadataSpec.getComponentsToRegister();
|
||||
if (componentsToRegister != null) {
|
||||
this.componentsToRegister.putAll(componentsToRegister);
|
||||
Map<Object, String> components = pollerMetadataSpec.getComponentsToRegister();
|
||||
if (components != null) {
|
||||
this.componentsToRegister.putAll(components);
|
||||
}
|
||||
return poller(pollerMetadataSpec.get());
|
||||
}
|
||||
|
||||
@@ -3095,14 +3095,14 @@ public abstract class IntegrationFlowDefinition<B extends IntegrationFlowDefinit
|
||||
|
||||
private boolean isOutputChannelRequired() {
|
||||
if (this.currentComponent != null) {
|
||||
Object currentComponent = this.currentComponent;
|
||||
Object currentElement = this.currentComponent;
|
||||
|
||||
if (AopUtils.isAopProxy(currentComponent)) {
|
||||
currentComponent = extractProxyTarget(currentComponent);
|
||||
if (AopUtils.isAopProxy(currentElement)) {
|
||||
currentElement = extractProxyTarget(currentElement);
|
||||
}
|
||||
|
||||
return currentComponent instanceof AbstractMessageProducingHandler
|
||||
|| currentComponent instanceof SourcePollingChannelAdapterSpec;
|
||||
return currentElement instanceof AbstractMessageProducingHandler
|
||||
|| currentElement instanceof SourcePollingChannelAdapterSpec;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -250,23 +250,23 @@ public abstract class AbstractPollingEndpoint extends AbstractEndpoint implement
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Callable<Message<?>> pollingTask = this::doPoll;
|
||||
Callable<Message<?>> task = this::doPoll;
|
||||
|
||||
List<Advice> adviceChain = this.adviceChain;
|
||||
if (!CollectionUtils.isEmpty(adviceChain)) {
|
||||
ProxyFactory proxyFactory = new ProxyFactory(pollingTask);
|
||||
if (!CollectionUtils.isEmpty(adviceChain)) {
|
||||
adviceChain.stream()
|
||||
List<Advice> advices = this.adviceChain;
|
||||
if (!CollectionUtils.isEmpty(advices)) {
|
||||
ProxyFactory proxyFactory = new ProxyFactory(task);
|
||||
if (!CollectionUtils.isEmpty(advices)) {
|
||||
advices.stream()
|
||||
.filter(advice -> !isReceiveOnlyAdvice(advice))
|
||||
.forEach(proxyFactory::addAdvice);
|
||||
}
|
||||
pollingTask = (Callable<Message<?>>) proxyFactory.getProxy(this.beanClassLoader);
|
||||
task = (Callable<Message<?>>) proxyFactory.getProxy(this.beanClassLoader);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(receiveOnlyAdviceChain)) {
|
||||
applyReceiveOnlyAdviceChain(receiveOnlyAdviceChain);
|
||||
}
|
||||
|
||||
return pollingTask;
|
||||
return task;
|
||||
}
|
||||
|
||||
private Runnable createPoller() {
|
||||
|
||||
@@ -219,9 +219,9 @@ public abstract class MessageProducerSupport extends AbstractEndpoint implements
|
||||
* @since 4.3.10
|
||||
*/
|
||||
protected final boolean sendErrorMessageIfNecessary(Message<?> message, RuntimeException exception) {
|
||||
MessageChannel errorChannel = getErrorChannel();
|
||||
if (errorChannel != null) {
|
||||
this.messagingTemplate.send(errorChannel, buildErrorMessage(message, exception));
|
||||
MessageChannel channel = getErrorChannel();
|
||||
if (channel != null) {
|
||||
this.messagingTemplate.send(channel, buildErrorMessage(message, exception));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -145,17 +145,13 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint
|
||||
protected void applyReceiveOnlyAdviceChain(Collection<Advice> chain) {
|
||||
if (!CollectionUtils.isEmpty(chain)) {
|
||||
if (AopUtils.isAopProxy(this.source)) {
|
||||
Advised source = (Advised) this.source;
|
||||
this.appliedAdvices.forEach(source::removeAdvice);
|
||||
for (Advice advice : chain) {
|
||||
source.addAdvisor(adviceToReceiveAdvisor(advice));
|
||||
}
|
||||
Advised advised = (Advised) this.source;
|
||||
this.appliedAdvices.forEach(advised::removeAdvice);
|
||||
chain.stream().forEach(advice -> advised.addAdvisor(adviceToReceiveAdvisor(advice)));
|
||||
}
|
||||
else {
|
||||
ProxyFactory proxyFactory = new ProxyFactory(this.source);
|
||||
for (Advice advice : chain) {
|
||||
proxyFactory.addAdvisor(adviceToReceiveAdvisor(advice));
|
||||
}
|
||||
chain.stream().forEach(advice -> proxyFactory.addAdvisor(adviceToReceiveAdvisor(advice)));
|
||||
this.source = (MessageSource<?>) proxyFactory.getProxy(getBeanClassLoader());
|
||||
}
|
||||
this.appliedAdvices.clear();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2018 the original author or authors.
|
||||
* Copyright 2013-2019 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.
|
||||
@@ -282,16 +282,21 @@ public final class ExpressionEvalMap extends AbstractMap<String, Object> {
|
||||
|
||||
private class ExpressionEvalMapFinalBuilderImpl implements ExpressionEvalMapFinalBuilder {
|
||||
|
||||
ExpressionEvalMapFinalBuilderImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionEvalMap build() {
|
||||
if (ExpressionEvalMapBuilder.this.evaluationCallback != null) {
|
||||
return new ExpressionEvalMap(ExpressionEvalMapBuilder.this.expressions,
|
||||
ExpressionEvalMapBuilder.this.evaluationCallback);
|
||||
}
|
||||
ComponentsEvaluationCallback evaluationCallback =
|
||||
new ComponentsEvaluationCallback(ExpressionEvalMapBuilder.this.context,
|
||||
ExpressionEvalMapBuilder.this.root, ExpressionEvalMapBuilder.this.returnType);
|
||||
return new ExpressionEvalMap(ExpressionEvalMapBuilder.this.expressions, evaluationCallback);
|
||||
else {
|
||||
return new ExpressionEvalMap(ExpressionEvalMapBuilder.this.expressions,
|
||||
new ComponentsEvaluationCallback(ExpressionEvalMapBuilder.this.context,
|
||||
ExpressionEvalMapBuilder.this.root, ExpressionEvalMapBuilder.this.returnType));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -300,6 +305,10 @@ public final class ExpressionEvalMap extends AbstractMap<String, Object> {
|
||||
private class ExpressionEvalMapComponentsBuilderImpl extends ExpressionEvalMapFinalBuilderImpl
|
||||
implements ExpressionEvalMapComponentsBuilder {
|
||||
|
||||
ExpressionEvalMapComponentsBuilderImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionEvalMapComponentsBuilder usingEvaluationContext(EvaluationContext context) {
|
||||
return ExpressionEvalMapBuilder.this.usingEvaluationContext(context);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -173,9 +173,9 @@ public class MessageFilter extends AbstractReplyProducingPostProcessingMessageHa
|
||||
@Override
|
||||
public Object postProcess(Message<?> message, Object result) {
|
||||
if (result == null) {
|
||||
MessageChannel discardChannel = getDiscardChannel();
|
||||
if (discardChannel != null) {
|
||||
this.messagingTemplate.send(discardChannel, message);
|
||||
MessageChannel channel = getDiscardChannel();
|
||||
if (channel != null) {
|
||||
this.messagingTemplate.send(channel, message);
|
||||
}
|
||||
if (this.throwExceptionOnRejection) {
|
||||
throw new MessageRejectedException(message, "MessageFilter '" + this.getComponentName()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017 the original author or authors.
|
||||
* Copyright 2017-2019 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.StringUtils;
|
||||
* Otherwise the default state is applied.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
@@ -47,17 +48,17 @@ public class AnnotationGatewayProxyFactoryBean extends GatewayProxyFactoryBean {
|
||||
|
||||
public AnnotationGatewayProxyFactoryBean(Class<?> serviceInterface) {
|
||||
super(serviceInterface);
|
||||
AnnotationAttributes gatewayAttributes =
|
||||
AnnotationAttributes annotationAttributes =
|
||||
AnnotatedElementUtils.getMergedAnnotationAttributes(serviceInterface,
|
||||
MessagingGateway.class.getName(), false, true);
|
||||
if (gatewayAttributes == null) {
|
||||
gatewayAttributes = AnnotationUtils.getAnnotationAttributes(
|
||||
if (annotationAttributes == null) {
|
||||
annotationAttributes = AnnotationUtils.getAnnotationAttributes(
|
||||
AnnotationUtils.synthesizeAnnotation(MessagingGateway.class), false, true);
|
||||
}
|
||||
|
||||
this.gatewayAttributes = gatewayAttributes;
|
||||
this.gatewayAttributes = annotationAttributes;
|
||||
|
||||
String id = gatewayAttributes.getString("name");
|
||||
String id = annotationAttributes.getString("name");
|
||||
if (StringUtils.hasText(id)) {
|
||||
setBeanName(id);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -634,10 +634,10 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
}
|
||||
Map<String, Object> headers = null;
|
||||
// We don't want to eagerly resolve the error channel here
|
||||
Object errorChannel = this.errorChannel == null ? this.errorChannelName : this.errorChannel;
|
||||
if (errorChannel != null && method.getReturnType().equals(void.class)) {
|
||||
Object errorChannelForVoidReturn = this.errorChannel == null ? this.errorChannelName : this.errorChannel;
|
||||
if (errorChannelForVoidReturn != null && method.getReturnType().equals(void.class)) {
|
||||
headers = new HashMap<>();
|
||||
headers.put(MessageHeaders.ERROR_CHANNEL, errorChannel);
|
||||
headers.put(MessageHeaders.ERROR_CHANNEL, errorChannelForVoidReturn);
|
||||
}
|
||||
|
||||
if (getMessageBuilderFactory() instanceof DefaultMessageBuilderFactory) {
|
||||
|
||||
@@ -411,19 +411,19 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
protected void send(Object object) {
|
||||
this.initializeIfNecessary();
|
||||
Assert.notNull(object, "request must not be null");
|
||||
MessageChannel requestChannel = getRequestChannel();
|
||||
Assert.state(requestChannel != null,
|
||||
MessageChannel channel = getRequestChannel();
|
||||
Assert.state(channel != null,
|
||||
"send is not supported, because no request channel has been configured");
|
||||
try {
|
||||
if (this.countsEnabled) {
|
||||
this.messageCount.incrementAndGet();
|
||||
}
|
||||
this.messagingTemplate.convertAndSend(requestChannel, object, this.historyWritingPostProcessor);
|
||||
this.messagingTemplate.convertAndSend(channel, object, this.historyWritingPostProcessor);
|
||||
}
|
||||
catch (Exception e) {
|
||||
MessageChannel errorChannel = getErrorChannel();
|
||||
if (errorChannel != null) {
|
||||
this.messagingTemplate.send(errorChannel, new ErrorMessage(e));
|
||||
MessageChannel errorChan = getErrorChannel();
|
||||
if (errorChan != null) {
|
||||
this.messagingTemplate.send(errorChan, new ErrorMessage(e));
|
||||
}
|
||||
else {
|
||||
this.rethrow(e, "failed to send message");
|
||||
@@ -434,37 +434,37 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
@Nullable
|
||||
protected Object receive() {
|
||||
this.initializeIfNecessary();
|
||||
MessageChannel replyChannel = getReplyChannel();
|
||||
Assert.state(replyChannel != null && (replyChannel instanceof PollableChannel),
|
||||
MessageChannel channel = getReplyChannel();
|
||||
Assert.state(channel != null && (channel instanceof PollableChannel),
|
||||
"receive is not supported, because no pollable reply channel has been configured");
|
||||
return this.messagingTemplate.receiveAndConvert(replyChannel, Object.class);
|
||||
return this.messagingTemplate.receiveAndConvert(channel, Object.class);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Message<?> receiveMessage() {
|
||||
initializeIfNecessary();
|
||||
MessageChannel replyChannel = getReplyChannel();
|
||||
Assert.state(replyChannel instanceof PollableChannel,
|
||||
MessageChannel channel = getReplyChannel();
|
||||
Assert.state(channel instanceof PollableChannel,
|
||||
"receive is not supported, because no pollable reply channel has been configured");
|
||||
return this.messagingTemplate.receive(replyChannel);
|
||||
return this.messagingTemplate.receive(channel);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Object receive(long timeout) {
|
||||
this.initializeIfNecessary();
|
||||
MessageChannel replyChannel = getReplyChannel();
|
||||
Assert.state(replyChannel != null && (replyChannel instanceof PollableChannel),
|
||||
MessageChannel channel = getReplyChannel();
|
||||
Assert.state(channel != null && (channel instanceof PollableChannel),
|
||||
"receive is not supported, because no pollable reply channel has been configured");
|
||||
return this.messagingTemplate.receiveAndConvert(replyChannel, timeout);
|
||||
return this.messagingTemplate.receiveAndConvert(channel, timeout);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Message<?> receiveMessage(long timeout) {
|
||||
initializeIfNecessary();
|
||||
MessageChannel replyChannel = getReplyChannel();
|
||||
Assert.state(replyChannel instanceof PollableChannel,
|
||||
MessageChannel channel = getReplyChannel();
|
||||
Assert.state(channel instanceof PollableChannel,
|
||||
"receive is not supported, because no pollable reply channel has been configured");
|
||||
return this.messagingTemplate.receive(replyChannel, timeout);
|
||||
return this.messagingTemplate.receive(channel, timeout);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -482,8 +482,8 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
private Object doSendAndReceive(Object object, boolean shouldConvert) {
|
||||
this.initializeIfNecessary();
|
||||
Assert.notNull(object, "request must not be null");
|
||||
MessageChannel requestChannel = getRequestChannel();
|
||||
if (requestChannel == null) {
|
||||
MessageChannel channel = getRequestChannel();
|
||||
if (channel == null) {
|
||||
throw new MessagingException("No request channel available. Cannot send request message.");
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
this.messageCount.incrementAndGet();
|
||||
}
|
||||
if (shouldConvert) {
|
||||
reply = this.messagingTemplate.convertSendAndReceive(requestChannel, object, Object.class,
|
||||
reply = this.messagingTemplate.convertSendAndReceive(channel, object, Object.class,
|
||||
this.historyWritingPostProcessor);
|
||||
if (reply instanceof Throwable) {
|
||||
error = (Throwable) reply;
|
||||
@@ -508,7 +508,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
? (Message<?>) object : this.requestMapper.toMessage(object);
|
||||
Assert.state(requestMessage != null, () -> "request mapper resulted in no message for " + object);
|
||||
requestMessage = this.historyWritingPostProcessor.postProcessMessage(requestMessage);
|
||||
reply = this.messagingTemplate.sendAndReceive(requestChannel, requestMessage);
|
||||
reply = this.messagingTemplate.sendAndReceive(channel, requestMessage);
|
||||
if (reply instanceof ErrorMessage) {
|
||||
error = ((ErrorMessage) reply).getPayload();
|
||||
}
|
||||
@@ -530,12 +530,12 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
}
|
||||
|
||||
if (error != null) {
|
||||
MessageChannel errorChannel = getErrorChannel();
|
||||
if (errorChannel != null) {
|
||||
MessageChannel errorChan = getErrorChannel();
|
||||
if (errorChan != null) {
|
||||
ErrorMessage errorMessage = buildErrorMessage(requestMessage, error);
|
||||
Message<?> errorFlowReply = null;
|
||||
try {
|
||||
errorFlowReply = this.messagingTemplate.sendAndReceive(errorChannel, errorMessage);
|
||||
errorFlowReply = this.messagingTemplate.sendAndReceive(errorChan, errorMessage);
|
||||
}
|
||||
catch (Exception errorFlowFailure) {
|
||||
throw new MessagingException(errorMessage, "failure occurred in error-handling flow",
|
||||
@@ -572,14 +572,14 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
protected Mono<Message<?>> sendAndReceiveMessageReactive(Object object) {
|
||||
initializeIfNecessary();
|
||||
Assert.notNull(object, "request must not be null");
|
||||
MessageChannel requestChannel = getRequestChannel();
|
||||
if (requestChannel == null) {
|
||||
MessageChannel channel = getRequestChannel();
|
||||
if (channel == null) {
|
||||
throw new MessagingException("No request channel available. Cannot send request message.");
|
||||
}
|
||||
|
||||
registerReplyMessageCorrelatorIfNecessary();
|
||||
|
||||
return doSendAndReceiveMessageReactive(requestChannel, object, false);
|
||||
return doSendAndReceiveMessageReactive(channel, object, false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -603,13 +603,13 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
Object originalReplyChannelHeader = message.getHeaders().getReplyChannel();
|
||||
Object originalErrorChannelHeader = message.getHeaders().getErrorChannel();
|
||||
|
||||
FutureReplyChannel replyChannel = new FutureReplyChannel();
|
||||
FutureReplyChannel replyChan = new FutureReplyChannel();
|
||||
|
||||
Message<?> requestMessage = MutableMessageBuilder.fromMessage(message)
|
||||
.setReplyChannel(replyChannel)
|
||||
.setReplyChannel(replyChan)
|
||||
.setHeader(this.messagingTemplate.getSendTimeoutHeader(), null)
|
||||
.setHeader(this.messagingTemplate.getReceiveTimeoutHeader(), null)
|
||||
.setErrorChannel(replyChannel)
|
||||
.setErrorChannel(replyChan)
|
||||
.build();
|
||||
|
||||
if (requestChannel instanceof ReactiveStreamsSubscribableChannel) {
|
||||
@@ -631,7 +631,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
}
|
||||
}
|
||||
|
||||
return Mono.fromFuture(replyChannel.messageFuture)
|
||||
return Mono.fromFuture(replyChan.messageFuture)
|
||||
.doOnSubscribe(s -> {
|
||||
if (!error && this.countsEnabled) {
|
||||
this.messageCount.incrementAndGet();
|
||||
@@ -662,11 +662,11 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("failure occurred in gateway sendAndReceiveReactive: " + exception.getMessage());
|
||||
}
|
||||
MessageChannel errorChannel = getErrorChannel();
|
||||
if (errorChannel != null) {
|
||||
MessageChannel channel = getErrorChannel();
|
||||
if (channel != null) {
|
||||
ErrorMessage errorMessage = buildErrorMessage(requestMessage, exception);
|
||||
try {
|
||||
return doSendAndReceiveMessageReactive(errorChannel, errorMessage, true);
|
||||
return doSendAndReceiveMessageReactive(channel, errorMessage, true);
|
||||
}
|
||||
catch (Exception errorFlowFailure) {
|
||||
throw new MessagingException(errorMessage, "failure occurred in error-handling flow", errorFlowFailure);
|
||||
@@ -741,8 +741,8 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
}
|
||||
|
||||
protected void registerReplyMessageCorrelatorIfNecessary() {
|
||||
MessageChannel replyChannel = getReplyChannel();
|
||||
if (replyChannel != null && this.replyMessageCorrelator == null) {
|
||||
MessageChannel replyChan = getReplyChannel();
|
||||
if (replyChan != null && this.replyMessageCorrelator == null) {
|
||||
boolean shouldStartCorrelator;
|
||||
synchronized (this.replyMessageCorrelatorMonitor) {
|
||||
if (this.replyMessageCorrelator != null) {
|
||||
@@ -754,24 +754,24 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
handler.setBeanFactory(getBeanFactory());
|
||||
}
|
||||
handler.afterPropertiesSet();
|
||||
if (replyChannel instanceof SubscribableChannel) {
|
||||
correlator = new EventDrivenConsumer((SubscribableChannel) replyChannel, handler);
|
||||
if (replyChan instanceof SubscribableChannel) {
|
||||
correlator = new EventDrivenConsumer((SubscribableChannel) replyChan, handler);
|
||||
}
|
||||
else if (replyChannel instanceof PollableChannel) {
|
||||
PollingConsumer endpoint = new PollingConsumer((PollableChannel) replyChannel, handler);
|
||||
else if (replyChan instanceof PollableChannel) {
|
||||
PollingConsumer endpoint = new PollingConsumer((PollableChannel) replyChan, handler);
|
||||
endpoint.setBeanFactory(getBeanFactory());
|
||||
endpoint.setReceiveTimeout(this.replyTimeout);
|
||||
endpoint.afterPropertiesSet();
|
||||
correlator = endpoint;
|
||||
}
|
||||
else if (replyChannel instanceof ReactiveStreamsSubscribableChannel) {
|
||||
else if (replyChan instanceof ReactiveStreamsSubscribableChannel) {
|
||||
ReactiveStreamsConsumer endpoint =
|
||||
new ReactiveStreamsConsumer(replyChannel, (Subscriber<Message<?>>) handler);
|
||||
new ReactiveStreamsConsumer(replyChan, (Subscriber<Message<?>>) handler);
|
||||
endpoint.afterPropertiesSet();
|
||||
correlator = endpoint;
|
||||
}
|
||||
else {
|
||||
throw new MessagingException("Unsupported 'replyChannel' type [" + replyChannel.getClass() + "]."
|
||||
throw new MessagingException("Unsupported 'replyChannel' type [" + replyChan.getClass() + "]."
|
||||
+ "SubscribableChannel or PollableChannel type are supported.");
|
||||
}
|
||||
this.replyMessageCorrelator = correlator;
|
||||
|
||||
@@ -147,23 +147,23 @@ public abstract class AbstractMessageHandler extends IntegrationObjectSupport
|
||||
this.logger.debug(this + " received message: " + message);
|
||||
}
|
||||
MetricsContext start = null;
|
||||
boolean countsEnabled = this.countsEnabled;
|
||||
AbstractMessageHandlerMetrics handlerMetrics = this.handlerMetrics;
|
||||
boolean countsAreEnabled = this.countsEnabled;
|
||||
AbstractMessageHandlerMetrics metrics = this.handlerMetrics;
|
||||
SampleFacade sample = null;
|
||||
if (countsEnabled && this.metricsCaptor != null) {
|
||||
if (countsAreEnabled && this.metricsCaptor != null) {
|
||||
sample = this.metricsCaptor.start();
|
||||
}
|
||||
try {
|
||||
if (this.shouldTrack) {
|
||||
message = MessageHistory.write(message, this, getMessageBuilderFactory());
|
||||
}
|
||||
if (countsEnabled) {
|
||||
start = handlerMetrics.beforeHandle();
|
||||
if (countsAreEnabled) {
|
||||
start = metrics.beforeHandle();
|
||||
handleMessageInternal(message);
|
||||
if (sample != null) {
|
||||
sample.stop(sendTimer());
|
||||
}
|
||||
handlerMetrics.afterHandle(start, true);
|
||||
metrics.afterHandle(start, true);
|
||||
}
|
||||
else {
|
||||
handleMessageInternal(message);
|
||||
@@ -173,8 +173,8 @@ public abstract class AbstractMessageHandler extends IntegrationObjectSupport
|
||||
if (sample != null) {
|
||||
sample.stop(buildSendTimer(false, e.getClass().getSimpleName()));
|
||||
}
|
||||
if (countsEnabled) {
|
||||
handlerMetrics.afterHandle(start, false);
|
||||
if (countsAreEnabled) {
|
||||
metrics.afterHandle(start, false);
|
||||
}
|
||||
throw IntegrationUtils.wrapInHandlingExceptionIfNecessary(message,
|
||||
() -> "error occurred in message handler [" + this + "]", e);
|
||||
|
||||
@@ -418,9 +418,9 @@ public abstract class AbstractMessageProducingHandler extends AbstractMessageHan
|
||||
*/
|
||||
protected void sendOutput(Object output, @Nullable Object replyChannelArg, boolean useArgChannel) {
|
||||
Object replyChannel = replyChannelArg;
|
||||
MessageChannel outputChannel = getOutputChannel();
|
||||
if (!useArgChannel && outputChannel != null) {
|
||||
replyChannel = outputChannel;
|
||||
MessageChannel outChannel = getOutputChannel();
|
||||
if (!useArgChannel && outChannel != null) {
|
||||
replyChannel = outChannel;
|
||||
}
|
||||
if (replyChannel == null) {
|
||||
throw new DestinationResolutionException("no output-channel or replyChannel header available");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -299,16 +299,16 @@ public class DelayHandler extends AbstractReplyProducingMessageHandler implement
|
||||
}
|
||||
|
||||
private MessageHandler createReleaseMessageTask() {
|
||||
ReleaseMessageHandler releaseHandler = new ReleaseMessageHandler();
|
||||
ReleaseMessageHandler handler = new ReleaseMessageHandler();
|
||||
|
||||
if (!CollectionUtils.isEmpty(this.delayedAdviceChain)) {
|
||||
ProxyFactory proxyFactory = new ProxyFactory(releaseHandler);
|
||||
ProxyFactory proxyFactory = new ProxyFactory(handler);
|
||||
for (Advice advice : this.delayedAdviceChain) {
|
||||
proxyFactory.addAdvice(advice);
|
||||
}
|
||||
return (MessageHandler) proxyFactory.getProxy(getApplicationContext().getClassLoader());
|
||||
}
|
||||
return releaseHandler;
|
||||
return handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -354,6 +354,7 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
|
||||
private MessagingMethodInvokerHelper(Object targetObject, Class<? extends Annotation> annotationType,
|
||||
String methodName, Class<?> expectedType, boolean canProcessMessageList) {
|
||||
|
||||
this.annotationType = annotationType;
|
||||
this.methodName = methodName;
|
||||
this.canProcessMessageList = canProcessMessageList;
|
||||
@@ -367,15 +368,15 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
this.targetObject = targetObject;
|
||||
Map<String, Map<Class<?>, HandlerMethod>> handlerMethodsForTarget =
|
||||
findHandlerMethodsForTarget(targetObject, annotationType, methodName, expectedType != null);
|
||||
Map<Class<?>, HandlerMethod> handlerMethods = handlerMethodsForTarget.get(CANDIDATE_METHODS);
|
||||
Map<Class<?>, HandlerMethod> handlerMessageMethods = handlerMethodsForTarget.get(CANDIDATE_MESSAGE_METHODS);
|
||||
if ((handlerMethods.size() == 1 && handlerMessageMethods.isEmpty()) ||
|
||||
(handlerMessageMethods.size() == 1 && handlerMethods.isEmpty())) {
|
||||
if (handlerMethods.size() == 1) {
|
||||
this.handlerMethod = handlerMethods.values().iterator().next();
|
||||
Map<Class<?>, HandlerMethod> methods = handlerMethodsForTarget.get(CANDIDATE_METHODS);
|
||||
Map<Class<?>, HandlerMethod> messageMethods = handlerMethodsForTarget.get(CANDIDATE_MESSAGE_METHODS);
|
||||
if ((methods.size() == 1 && messageMethods.isEmpty()) ||
|
||||
(messageMethods.size() == 1 && methods.isEmpty())) {
|
||||
if (methods.size() == 1) {
|
||||
this.handlerMethod = methods.values().iterator().next();
|
||||
}
|
||||
else {
|
||||
this.handlerMethod = handlerMessageMethods.values().iterator().next();
|
||||
this.handlerMethod = messageMethods.values().iterator().next();
|
||||
}
|
||||
this.handlerMethods = null;
|
||||
this.handlerMessageMethods = null;
|
||||
@@ -383,8 +384,8 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
}
|
||||
else {
|
||||
this.handlerMethod = null;
|
||||
this.handlerMethods = handlerMethods;
|
||||
this.handlerMessageMethods = handlerMessageMethods;
|
||||
this.handlerMethods = methods;
|
||||
this.handlerMessageMethods = messageMethods;
|
||||
this.handlerMethodsList = new LinkedList<>();
|
||||
|
||||
//TODO Consider to use global option to determine a precedence of methods
|
||||
@@ -440,12 +441,13 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
|
||||
private boolean canReturnExpectedType(AnnotatedMethodFilter filter, Class<?> targetType,
|
||||
TypeConverter typeConverter) {
|
||||
|
||||
if (this.expectedType == null) {
|
||||
return true;
|
||||
}
|
||||
List<Method> methods = filter.filter(Arrays.asList(ReflectionUtils.getAllDeclaredMethods(targetType)));
|
||||
for (Method method : methods) {
|
||||
if (typeConverter.canConvert(TypeDescriptor.valueOf(method.getReturnType()), this.expectedType)) {
|
||||
for (Method candidate : methods) {
|
||||
if (typeConverter.canConvert(TypeDescriptor.valueOf(candidate.getReturnType()), this.expectedType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -687,10 +689,10 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
}
|
||||
|
||||
private Map<String, Map<Class<?>, HandlerMethod>> findHandlerMethodsForTarget(final Object targetObject,
|
||||
final Class<? extends Annotation> annotationType, final String methodNameToUse,
|
||||
final Class<? extends Annotation> annotationType, final String methodNameArg,
|
||||
final boolean requiresReply) {
|
||||
|
||||
Map<String, Map<Class<?>, HandlerMethod>> handlerMethods = new HashMap<>();
|
||||
Map<String, Map<Class<?>, HandlerMethod>> methods = new HashMap<>();
|
||||
|
||||
final Map<Class<?>, HandlerMethod> candidateMethods = new HashMap<>();
|
||||
final Map<Class<?>, HandlerMethod> candidateMessageMethods = new HashMap<>();
|
||||
@@ -700,21 +702,21 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
final AtomicReference<Class<?>> ambiguousFallbackMessageGenericType = new AtomicReference<>();
|
||||
final Class<?> targetClass = getTargetClass(targetObject);
|
||||
|
||||
final String methodName;
|
||||
final String methodNameToUse;
|
||||
|
||||
if (methodNameToUse == null) {
|
||||
if (methodNameArg == null) {
|
||||
if (Function.class.isAssignableFrom(targetClass)) {
|
||||
methodName = "apply";
|
||||
methodNameToUse = "apply";
|
||||
}
|
||||
else if (Consumer.class.isAssignableFrom(targetClass)) {
|
||||
methodName = "accept";
|
||||
methodNameToUse = "accept";
|
||||
}
|
||||
else {
|
||||
methodName = null;
|
||||
methodNameToUse = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
methodName = methodNameToUse;
|
||||
methodNameToUse = methodNameArg;
|
||||
}
|
||||
|
||||
|
||||
@@ -739,10 +741,10 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
if (requiresReply && void.class.equals(method1.getReturnType())) {
|
||||
return;
|
||||
}
|
||||
if (methodName != null && !methodName.equals(method1.getName())) {
|
||||
if (methodNameToUse != null && !methodNameToUse.equals(method1.getName())) {
|
||||
return;
|
||||
}
|
||||
if (methodName == null
|
||||
if (methodNameToUse == null
|
||||
&& ObjectUtils.containsElement(new String[] { "start", "stop", "isRunning" }, method1.getName())) {
|
||||
return;
|
||||
}
|
||||
@@ -820,14 +822,14 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
|
||||
if (candidateMethods.isEmpty() && candidateMessageMethods.isEmpty() && fallbackMethods.isEmpty()
|
||||
&& fallbackMessageMethods.isEmpty()) {
|
||||
findSingleSpecifMethodOnInterfacesIfProxy(targetObject, methodName, candidateMessageMethods,
|
||||
findSingleSpecifMethodOnInterfacesIfProxy(targetObject, methodNameToUse, candidateMessageMethods,
|
||||
candidateMethods);
|
||||
}
|
||||
|
||||
if (!candidateMethods.isEmpty() || !candidateMessageMethods.isEmpty()) {
|
||||
handlerMethods.put(CANDIDATE_METHODS, candidateMethods);
|
||||
handlerMethods.put(CANDIDATE_MESSAGE_METHODS, candidateMessageMethods);
|
||||
return handlerMethods;
|
||||
methods.put(CANDIDATE_METHODS, candidateMethods);
|
||||
methods.put(CANDIDATE_MESSAGE_METHODS, candidateMessageMethods);
|
||||
return methods;
|
||||
}
|
||||
if ((ambiguousFallbackType.get() != null
|
||||
|| ambiguousFallbackMessageGenericType.get() != null)
|
||||
@@ -855,16 +857,16 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
}
|
||||
}
|
||||
if (frameworkMethods.size() == 1) {
|
||||
Method method = org.springframework.util.ClassUtils.getMostSpecificMethod(frameworkMethods.get(0),
|
||||
targetObject.getClass());
|
||||
Method frameworkMethod = org.springframework.util.ClassUtils.getMostSpecificMethod(
|
||||
frameworkMethods.get(0), targetObject.getClass());
|
||||
InvocableHandlerMethod invocableHandlerMethod =
|
||||
this.messageHandlerMethodFactory.createInvocableHandlerMethod(targetObject,
|
||||
method);
|
||||
HandlerMethod handlerMethod = new HandlerMethod(invocableHandlerMethod, this.canProcessMessageList);
|
||||
checkSpelInvokerRequired(targetClass, method, handlerMethod);
|
||||
handlerMethods.put(CANDIDATE_METHODS, Collections.singletonMap(Object.class, handlerMethod));
|
||||
handlerMethods.put(CANDIDATE_MESSAGE_METHODS, candidateMessageMethods);
|
||||
return handlerMethods;
|
||||
frameworkMethod);
|
||||
HandlerMethod theHandlerMethod = new HandlerMethod(invocableHandlerMethod, this.canProcessMessageList);
|
||||
checkSpelInvokerRequired(targetClass, frameworkMethod, theHandlerMethod);
|
||||
methods.put(CANDIDATE_METHODS, Collections.singletonMap(Object.class, theHandlerMethod));
|
||||
methods.put(CANDIDATE_MESSAGE_METHODS, candidateMessageMethods);
|
||||
return methods;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -880,9 +882,9 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
+ "] for method match: "
|
||||
+ fallbackMethods.values());
|
||||
|
||||
handlerMethods.put(CANDIDATE_METHODS, fallbackMethods);
|
||||
handlerMethods.put(CANDIDATE_MESSAGE_METHODS, fallbackMessageMethods);
|
||||
return handlerMethods;
|
||||
methods.put(CANDIDATE_METHODS, fallbackMethods);
|
||||
methods.put(CANDIDATE_MESSAGE_METHODS, fallbackMessageMethods);
|
||||
return methods;
|
||||
}
|
||||
|
||||
private void findSingleSpecifMethodOnInterfacesIfProxy(final Object targetObject, final String methodName,
|
||||
@@ -909,15 +911,15 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
.getMostSpecificMethod(theMethod, targetObject.getClass());
|
||||
InvocableHandlerMethod invocableHandlerMethod =
|
||||
this.messageHandlerMethodFactory.createInvocableHandlerMethod(targetObject, theMethod);
|
||||
HandlerMethod handlerMethod = new HandlerMethod(invocableHandlerMethod, this.canProcessMessageList);
|
||||
checkSpelInvokerRequired(targetClass.get(), theMethod, handlerMethod);
|
||||
Class<?> targetParameterType = handlerMethod.getTargetParameterType();
|
||||
if (handlerMethod.isMessageMethod()) {
|
||||
HandlerMethod theHandlerMethod = new HandlerMethod(invocableHandlerMethod, this.canProcessMessageList);
|
||||
checkSpelInvokerRequired(targetClass.get(), theMethod, theHandlerMethod);
|
||||
Class<?> targetParameterType = theHandlerMethod.getTargetParameterType();
|
||||
if (theHandlerMethod.isMessageMethod()) {
|
||||
if (candidateMessageMethods.containsKey(targetParameterType)) {
|
||||
throw new IllegalArgumentException("Found more than one method match for type " +
|
||||
"[Message<" + targetParameterType + ">]");
|
||||
}
|
||||
candidateMessageMethods.put(targetParameterType, handlerMethod);
|
||||
candidateMessageMethods.put(targetParameterType, theHandlerMethod);
|
||||
}
|
||||
else {
|
||||
if (candidateMethods.containsKey(targetParameterType)) {
|
||||
@@ -930,15 +932,15 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
}
|
||||
throw new IllegalArgumentException(exceptionMessage);
|
||||
}
|
||||
candidateMethods.put(targetParameterType, handlerMethod);
|
||||
candidateMethods.put(targetParameterType, theHandlerMethod);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkSpelInvokerRequired(final Class<?> targetClass, Method methodArg, HandlerMethod handlerMethod) {
|
||||
Method method = AopUtils.getMostSpecificMethod(methodArg, targetClass);
|
||||
UseSpelInvoker useSpel = AnnotationUtils.findAnnotation(method, UseSpelInvoker.class);
|
||||
UseSpelInvoker useSpel = AnnotationUtils.findAnnotation(AopUtils.getMostSpecificMethod(methodArg, targetClass),
|
||||
UseSpelInvoker.class);
|
||||
if (useSpel == null) {
|
||||
useSpel = AnnotationUtils.findAnnotation(targetClass, UseSpelInvoker.class);
|
||||
}
|
||||
@@ -1019,14 +1021,14 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
|
||||
}
|
||||
|
||||
private HandlerMethod findClosestMatch(Class<?> payloadType) {
|
||||
for (Map<Class<?>, HandlerMethod> handlerMethods : this.handlerMethodsList) {
|
||||
Set<Class<?>> candidates = handlerMethods.keySet();
|
||||
for (Map<Class<?>, HandlerMethod> methods : this.handlerMethodsList) {
|
||||
Set<Class<?>> candidates = methods.keySet();
|
||||
Class<?> match = null;
|
||||
if (!CollectionUtils.isEmpty(candidates)) {
|
||||
match = ClassUtils.findClosestMatch(payloadType, candidates, true);
|
||||
}
|
||||
if (match != null) {
|
||||
return handlerMethods.get(match);
|
||||
return methods.get(match);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 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.
|
||||
@@ -118,16 +118,16 @@ public class MessageHistoryConfigurer implements SmartLifecycle, BeanFactoryAwar
|
||||
Assert.notNull(componentNamePatternsSet, "'componentNamePatternsSet' must not be null");
|
||||
Assert.state(!this.running, "'componentNamePatternsSet' cannot be changed without invoking stop() first");
|
||||
for (String s : componentNamePatternsSet) {
|
||||
String[] componentNamePatterns = StringUtils.delimitedListToStringArray(s, ",", " ");
|
||||
Arrays.sort(componentNamePatterns);
|
||||
String[] patterns = StringUtils.delimitedListToStringArray(s, ",", " ");
|
||||
Arrays.sort(patterns);
|
||||
if (this.componentNamePatternsExplicitlySet
|
||||
&& !Arrays.equals(this.componentNamePatterns, componentNamePatterns)) {
|
||||
&& !Arrays.equals(this.componentNamePatterns, patterns)) {
|
||||
throw new BeanDefinitionValidationException("When more than one message history definition " +
|
||||
"(@EnableMessageHistory or <message-history>)" +
|
||||
" is found in the context, they all must have the same 'componentNamePatterns'");
|
||||
}
|
||||
else {
|
||||
this.componentNamePatterns = componentNamePatterns;
|
||||
this.componentNamePatterns = patterns;
|
||||
this.componentNamePatternsExplicitlySet = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user