Spring Integration

org.springframework.integration.file
Class DefaultFileNameGenerator

java.lang.Object
  extended by org.springframework.integration.util.AbstractExpressionEvaluator
      extended by org.springframework.integration.file.DefaultFileNameGenerator
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, 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

Constructor Summary
DefaultFileNameGenerator()
           
 
Method Summary
 java.lang.String generateFileName(Message<?> message)
           
 void setExpression(java.lang.String expression)
          Specify an expression to be evaluated against the Message in order to generate a file name.
 void setHeaderName(java.lang.String headerName)
          Specify a custom header name to check for the file name.
 
Methods inherited from class org.springframework.integration.util.AbstractExpressionEvaluator
evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getEvaluationContext, setBeanFactory, setBeanResolver, setConversionService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFileNameGenerator

public DefaultFileNameGenerator()
Method Detail

setExpression

public void setExpression(java.lang.String expression)
Specify an expression to be evaluated against the Message in order to generate a file name.


setHeaderName

public void setHeaderName(java.lang.String headerName)
Specify a custom header name to check for the file name. The default is defined by FileHeaders.FILENAME.


generateFileName

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

Spring Integration