INT-4443: Use SimpleEC for uriVariablesExpression
JIRA: https://jira.spring.io/browse/INT-4443 **cherry-pick to 5.0.x, 4.3.x** Polishing; use data binding accessor in test evaluation contexts. Add `.withInstanceMethods()` See https://jira.spring.io/browse/SPR-16588?focusedCommentId=158041&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-158041 * Polishing according PR comments
This commit is contained in:
committed by
Artem Bilan
parent
7b86ca7bc8
commit
1cd6c11808
@@ -216,6 +216,10 @@ With this release, the content type of such requests is considered to be `applic
|
||||
by RFC 2616.
|
||||
See <<http-inbound>> for more information.
|
||||
|
||||
`uriVariablesExpression` now uses a `SimpleEvaluationContext` by default (since 4.3.15).
|
||||
|
||||
See <<mapping-uri-variables>> for more information.
|
||||
|
||||
==== SFTP Changes
|
||||
|
||||
===== Factory Bean
|
||||
|
||||
@@ -236,6 +236,10 @@ The `DefaultHttpHeaderMapper.userDefinedHeaderPrefix` property is now an empty s
|
||||
|
||||
See <<http-header-mapping>> for more information.
|
||||
|
||||
`uriVariablesExpression` now uses a `SimpleEvaluationContext` by default (since 5.0.4).
|
||||
|
||||
See <<mapping-uri-variables>> for more information.
|
||||
|
||||
==== MQTT Changes
|
||||
|
||||
Inbound messages are now mapped with headers `RECEIVED_TOPIC`, `RECEIVED_QOS` and `RECEIVED_RETAINED` to avoid inadvertent propagation to outbound messages when an application is relaying messages.
|
||||
|
||||
@@ -526,6 +526,7 @@ Changes in Spring 3.1 can cause some issues with escaped characters, such as '?'
|
||||
For this reason, it is recommended that if you wish to generate the URL entirely at runtime, you use the 'url-expression' attribute.
|
||||
=====
|
||||
|
||||
[[mapping-uri-variables]]
|
||||
==== Mapping URI Variables
|
||||
|
||||
If your URL contains URI variables, you can map them using the `uri-variable` sub-element.
|
||||
@@ -584,6 +585,15 @@ NOTE: The `uri-variables-expression` must evaluate to a `Map`.
|
||||
The values of the Map must be instances of `String` or `Expression`.
|
||||
This Map is provided to an `ExpressionEvalMap` for further resolution of URI variable placeholders using those expressions in the context of the outbound `Message`.
|
||||
|
||||
IMPORTANT
|
||||
====
|
||||
The `uriVariablesExpression` property provides a very powerful mechanism for evaluating URI variables.
|
||||
It is anticipated that simple expressions like the example above will be used.
|
||||
However, you could also configure something like this `"@uriVariablesBean.populate(#root)"` with an expression in the returned map being `variables.put("foo", EXPRESSION_PARSER.parseExpression(message.getHeaders().get("bar", String.class)));`, where the expression is dynamically provided in the message header `bar`.
|
||||
Since the header may come from an untrusted source, the HTTP outbound endpoints use a `SimpleEvaluationContext` when evaluating these expressions; allowing only a subset of SpEL features to be used.
|
||||
If you trust your message sources and wish to use the restricted SpEL constructs, set the `trustedSpel` property of the outbound endpoint to `true`.
|
||||
====
|
||||
|
||||
Scenarios when we need to supply a dynamic set of URI variables on per message basis can be achieved with the custom `url-expression` and some utilities for building and encoding URL parameters:
|
||||
|
||||
[source,xml]
|
||||
|
||||
Reference in New Issue
Block a user