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
  • Constructor Details

    • DefaultFileNameGenerator

      public DefaultFileNameGenerator()
  • Method Details

    • setExpression

      public void setExpression(String expression)
      Specify an expression to be evaluated against the Message in order to generate a file name.
      Parameters:
      expression - The expression.
    • setHeaderName

      public void setHeaderName(String headerName)
      Specify a custom header name to check for the file name. The default is defined by FileHeaders.FILENAME.
      Parameters:
      headerName - The header name.
    • generateFileName

      public String generateFileName(Message<?> message)
      Specified by:
      generateFileName in interface FileNameGenerator