INT-3494: Resolve dir for writing as a Resource (#3109)

* INT-3494: Resolve dir for writing as a Resource

JIRA: https://jira.spring.io/browse/INT-3494

The expression for local directory can be resolved into a `Resource`
or resource location.
* Fix `ExpressionUtils.expressionToFile()` to support `Resource` and
also use `ResourceUtils.getFile(path)` when expression result is a string
* Modify tests to ensure that resource is resolved properly
* Upgrade affected tests to JUnit 5
* Mention an new functionality in docs

* * Improve Java doc for `ExpressionUtils.expressionToFile()`
* Finish the sentence in the `file.adoc`
This commit is contained in:
Artem Bilan
2019-11-14 16:27:59 -05:00
committed by Gary Russell
parent 069d8730e0
commit 0f5bd4a40a
7 changed files with 164 additions and 211 deletions

View File

@@ -688,7 +688,8 @@ If you want to have full SpEL support, you can use the `directory-expression` at
This attribute accepts a SpEL expression that is evaluated for each message being processed.
Thus, you have full access to a message's payload and its headers when you dynamically specify the output file directory.
The SpEL expression must resolve to either a `String` or to `java.io.File`.
The SpEL expression must resolve to either a `String`, `java.io.File` or `org.springframework.core.io.Resource`.
(The later is evaluated into a `File` anyway.)
Furthermore, the resulting `String` or `File` must point to a directory.
If you do not specify the `directory-expression` attribute, then you must set the `directory` attribute.