Class DefaultFileNameGenerator
java.lang.Object
org.springframework.integration.util.AbstractExpressionEvaluator
org.springframework.integration.file.DefaultFileNameGenerator
- All Implemented Interfaces:
Aware
,BeanFactoryAware
,InitializingBean
,FileNameGenerator
public class DefaultFileNameGenerator extends AbstractExpressionEvaluator implements FileNameGenerator
Default implementation of the filename generator strategy. It evaluates an
expression against the Message in order to generate the file name. Either
the 'expression' property can be set directly, or for a simple header name
to be used as the filename, there is also a
setHeaderName(String)
method for convenience. If neither a header name nor custom expression is set,
the default header name is defined by the constant FileHeaders.FILENAME
.
If no String-typed value is returned from the expression evaluation (or
associated with the header if no expression has been provided), it checks if
the Message payload is a File instance, and if so, it uses the same name.
Finally, it falls back to the Message ID and adds the suffix '.msg'.- Author:
- Mark Fisher, Gary Russell, Artem Bilan
-
Field Summary
Fields inherited from class org.springframework.integration.util.AbstractExpressionEvaluator
EXPRESSION_PARSER, logger
-
Constructor Summary
Constructors Constructor Description DefaultFileNameGenerator()
-
Method Summary
Modifier and Type Method Description String
generateFileName(Message<?> message)
void
setExpression(String expression)
Specify an expression to be evaluated against the Message in order to generate a file name.void
setHeaderName(String headerName)
Specify a custom header name to check for the file name.Methods inherited from class org.springframework.integration.util.AbstractExpressionEvaluator
afterPropertiesSet, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getBeanFactory, getEvaluationContext, getEvaluationContext, getMessageBuilderFactory, onInit, setBeanFactory, setConversionService
-
Constructor Details
-
DefaultFileNameGenerator
public DefaultFileNameGenerator()
-
-
Method Details
-
setExpression
Specify an expression to be evaluated against the Message in order to generate a file name.- Parameters:
expression
- The expression.
-
setHeaderName
Specify a custom header name to check for the file name. The default is defined byFileHeaders.FILENAME
.- Parameters:
headerName
- The header name.
-
generateFileName
- Specified by:
generateFileName
in interfaceFileNameGenerator
-