From 208d022ca6d6488b0d486b0edab7d77b38187941 Mon Sep 17 00:00:00 2001 From: Gunnar Hillert Date: Thu, 7 Feb 2013 16:58:57 -0500 Subject: [PATCH] INT-2769 Document Filename Generation Options INT-2769 - Document filename-generator + filename-generator-expression For reference see: https://jira.springsource.org/browse/INT-2769 INT-2769 Polishing --- src/reference/docbook/file.xml | 75 ++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 8 deletions(-) diff --git a/src/reference/docbook/file.xml b/src/reference/docbook/file.xml index 95c485caa3..c2e9c5e533 100644 --- a/src/reference/docbook/file.xml +++ b/src/reference/docbook/file.xml @@ -157,16 +157,10 @@ FileWritingMessageHandler. This class can deal with File, String, or byte array - payloads. In its simplest form the FileWritingMessageHandler - only requires a destination directory for writing the files. The name - of the file to be written is determined by the handler's - FileNameGenerator. - The default implementation - looks for a Message header whose key matches the constant defined as - FileHeaders.FILENAME. + payloads. - Additionally, you can configure the encoding and the charset that + You can configure the encoding and the charset that will be used in case of a String payload. @@ -175,6 +169,71 @@ Outbound Gateway using the provided XML namespace support. +
+ Generating Filenames + + In its simplest form, the FileWritingMessageHandler + only requires a destination directory for writing the files. The + name of the file to be written is determined by the handler's + FileNameGenerator. + The default implementation + looks for a Message header whose key matches the constant defined + as FileHeaders.FILENAME. + + + Alternatively, you can specify an expression + to be evaluated against the Message in order to generate a file name, e.g.: + headers['myCustomHeader'] + '.foo'. The expression must + evaluate to a String. For convenience, + the DefaultFileNameGenerator also + provides the setHeaderName method, allowing you + to explicitly specify the Message header whose value shall be + used as the filename. + + + Once setup, the DefaultFileNameGenerator will + employ the following resolution steps to determine the filename + for a given Message payload: + + + + Evaluate the expression against the Message and, if the result is a + non-empty String, use it as the + filename. + + + Otherwise, if the payload is a java.io.File, use the + file's filename. + + + Otherwise, use the Message ID appended with .msg + as the filename. + + + + When using the XML namespace support, both, the + File Oubound Channel Adapter and + the File Outbound Gateway support the + following two mutually exclusive configuration attributes: + + + filename-generator (a reference to a FileNameGenerator) implementation) + filename-generator-expression (an expression evaluating to a String) + + + While writing files, a temporary file suffix will be used (default: + .writing). It is appended to the filename while + the file is being written. To customize the suffix, you + can set the temporary-file-suffix attribute + on both, the File Oubound Channel Adapter and + the File Outbound Gateway. + + + When using the APPEND file mode, + the temporary-file-suffix attribute is ignored, + since the data is appended to the file directly. + +
Specifying the Output Directory