GH-3648: Fix @Gateway.payloadExpression
Resolves https://github.com/spring-projects/spring-integration/issues/3648 When configuring a gateway proxy with XML, but specifying the payload expression on the method `@Gateway` annotation, the expression was ignored, even though it had been parsed. `@Payload` worked. With this change, if both `@Payload` and `@Gateway` are defined on a gateway method, `@Gateway.payloadExpression` wins. * Fix doc links.
This commit is contained in:
@@ -113,6 +113,8 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
|
||||
private final Class<?> serviceInterface;
|
||||
|
||||
private final Set<Method> hasPayloadExpression = new HashSet<>();
|
||||
|
||||
private MessageChannel defaultRequestChannel;
|
||||
|
||||
private String defaultRequestChannelName;
|
||||
@@ -599,18 +601,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
}
|
||||
|
||||
private boolean findPayloadExpression(Method method) {
|
||||
boolean hasPayloadExpression = method.isAnnotationPresent(Payload.class);
|
||||
if (!hasPayloadExpression) {
|
||||
// check for the method metadata next
|
||||
if (this.methodMetadataMap != null) {
|
||||
GatewayMethodMetadata metadata = this.methodMetadataMap.get(method.getName());
|
||||
hasPayloadExpression = (metadata != null) && metadata.getPayloadExpression() != null;
|
||||
}
|
||||
else if (this.globalMethodMetadata != null) {
|
||||
hasPayloadExpression = this.globalMethodMetadata.getPayloadExpression() != null;
|
||||
}
|
||||
}
|
||||
return hasPayloadExpression;
|
||||
return method.isAnnotationPresent(Payload.class) || this.hasPayloadExpression.contains(method);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -696,6 +687,9 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
|
||||
}
|
||||
Expression payloadExpression =
|
||||
extractPayloadExpressionFromAnnotationOrMetadata(gatewayAnnotation, methodMetadata);
|
||||
if (payloadExpression != null) {
|
||||
this.hasPayloadExpression.add(method);
|
||||
}
|
||||
String requestChannelName = extractRequestChannelFromAnnotationOrMetadata(gatewayAnnotation, methodMetadata);
|
||||
String replyChannelName = extractReplyChannelFromAnnotationOrMetadata(gatewayAnnotation, methodMetadata);
|
||||
Expression requestTimeout = extractRequestTimeoutFromAnnotationOrMetadata(gatewayAnnotation, methodMetadata);
|
||||
|
||||
Reference in New Issue
Block a user