From 5b6820ae55ad35d3fde9998bce55111f2feedb30 Mon Sep 17 00:00:00 2001 From: abilan Date: Wed, 1 Feb 2023 13:42:17 -0500 Subject: [PATCH 1/2] GH-3998: Fix gateway docs for `@Payload` Fixes https://github.com/spring-projects/spring-integration/issues/3998 The `GatewayProxyFactoryBean` now deals only with a `MethodArgsHolder` as a root evaluation context object. There is no `#args` and `#method` SpEL variables anymore. However, the `gateway.adoc` still refer to those. * Fix `gateway.adoc` for a proper expressions and actual wording --- src/reference/asciidoc/gateway.adoc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/reference/asciidoc/gateway.adoc b/src/reference/asciidoc/gateway.adoc index 19f87722d0f..cb56923aa2a 100644 --- a/src/reference/asciidoc/gateway.adoc +++ b/src/reference/asciidoc/gateway.adoc @@ -225,10 +225,10 @@ public interface MyGateway { void twoMapsAndOneAnnotatedWithPayload(@Payload Map payload, Map headers); - @Payload("#args[0] + #args[1] + '!'") + @Payload("args[0] + args[1] + '!'") void payloadAnnotationAtMethodLevel(String a, String b); - @Payload("@someBean.exclaim(#args[0])") + @Payload("@someBean.exclaim(args[0])") void payloadAnnotationAtMethodLevelUsingBeanResolver(String s); void payloadAnnotationWithExpression(@Payload("toUpperCase()") String s); @@ -254,17 +254,17 @@ public interface MyGateway { <1> Note that, in this example, the SpEL variable, `#this`, refers to the argument -- in this case, the value of `s`. The XML equivalent looks a little different, since there is no `#this` context for the method argument. -However, expressions can refer to method arguments by using the `#args` variable, as the following example shows: +However, expressions can refer to method arguments by using the `args` property for the `MethodArgsHolder` root object, as the following example shows: ==== [source,xml] ---- - - - + + + - + ---- @@ -515,13 +515,13 @@ Starting with version 5.0, the timeouts can be defined as expressions, as the fo ==== [source, java] ---- -@Gateway(payloadExpression = "#args[0]", requestChannel = "someChannel", - requestTimeoutExpression = "#args[1]", replyTimeoutExpression = "#args[2]") +@Gateway(payloadExpression = "args[0]", requestChannel = "someChannel", + requestTimeoutExpression = "args[1]", replyTimeoutExpression = "args[2]") String lateReply(String payload, long requestTimeout, long replyTimeout); ---- ==== -The evaluation context has a `BeanResolver` (use `@someBean` to reference other beans), and the `#args` array variable is available. +The evaluation context has a `BeanResolver` (use `@someBean` to reference other beans), and the `args` array property from the `#root` object is available. When configuring with XML, the timeout attributes can be a long value or a SpEL expression, as the following example shows: @@ -529,9 +529,9 @@ When configuring with XML, the timeout attributes can be a long value or a SpEL [source, xml] ---- + reply-timeout="args[1]"> ---- ==== From 219a8df84ea46db5b34335a95ab8f3378c542c94 Mon Sep 17 00:00:00 2001 From: abilan Date: Wed, 1 Feb 2023 13:57:37 -0500 Subject: [PATCH 2/2] * Cross link to `gateway-expressions` paragraph for better context --- src/reference/asciidoc/gateway.adoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/reference/asciidoc/gateway.adoc b/src/reference/asciidoc/gateway.adoc index cb56923aa2a..cdf3c35add3 100644 --- a/src/reference/asciidoc/gateway.adoc +++ b/src/reference/asciidoc/gateway.adoc @@ -158,6 +158,7 @@ IMPORTANT: If you specify, for example, the `requestChannel` in `` NOTE: If a no-argument gateway is specified in XML, and the interface method has both a `@Payload` and `@Gateway` annotation (with a `payloadExpression` or a `payload-expression` in an `` element), the `@Payload` value is ignored. +[[gateway-expressions]] ===== Expressions and "`Global`" Headers The `
` element supports `expression` as an alternative to `value`. @@ -254,7 +255,7 @@ public interface MyGateway { <1> Note that, in this example, the SpEL variable, `#this`, refers to the argument -- in this case, the value of `s`. The XML equivalent looks a little different, since there is no `#this` context for the method argument. -However, expressions can refer to method arguments by using the `args` property for the `MethodArgsHolder` root object, as the following example shows: +However, expressions can refer to method arguments by using the `args` property for the `MethodArgsHolder` root object (see <> for more information), as the following example shows: ==== [source,xml] @@ -522,7 +523,7 @@ String lateReply(String payload, long requestTimeout, long replyTimeout); ==== The evaluation context has a `BeanResolver` (use `@someBean` to reference other beans), and the `args` array property from the `#root` object is available. - +See <> for more information about this root object. When configuring with XML, the timeout attributes can be a long value or a SpEL expression, as the following example shows: ====