title: Rename file in-place using Spring Integration FileWritingMessageHandler
body: <p>I am attempting to write a simple test of renaming files in-place using a FileWritingMessageHandler, however I can't seem to figure out how to properly specify the target destination directory.</p>
  
  <p>Since I am recursively scanning a directory tree I would ultimately like to simply read the parent path from the file payload and rename it using the FileNameGenerator, but that doesn't appear to work.</p>
  
  <p>The 'payload.name' in the DefaultFileNameGenerator resolves properly, but 'payload.path' does not.</p>
  
  <p>How do I properly determine the source file's location and use that in the handler?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Here is the channel adapter that scans for files. I had to use <code>.setUseWatchService(true)</code> to achieve recursive scanning.</p>
  
  <pre><code>@Bean
  @InboundChannelAdapter(channel = "sourceFileChannel", poller =     @Poller(fixedRate = "5000", maxMessagesPerPoll = "-1"))
  public MessageSource&lt;File&gt; sourceFiles() {
  
  CompositeFileListFilter&lt;File&gt; filters = new CompositeFileListFilter&lt;&gt;();
  filters.addFilter(new SimplePatternFileListFilter(sourceFilenamePattern));
  filters.addFilter(persistentFilter());
  
  FileReadingMessageSource source = new FileReadingMessageSource();
  source.setAutoCreateDirectory(true);
  source.setDirectory(new File(sourceDirectory));
  source.setFilter(filters);
  source.setUseWatchService(true);
  
  return source;
  }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Artem helped me understand my mistake.</p>
  
  <p>I was able to achieve the desired result by using the SpelExpressionParser as Artem outlined.</p>
  
  <p>The key piece being: </p>
  
  <p><code>new SpelExpressionParser().parseExpression("payload.parent")</code></p>
  
  <p>Where "payload.parent" resolves to the file parent path properly.</p>
  
  <pre><code>@Bean
  @ServiceActivator(inputChannel = "processingFileChannel")
  public MessageHandler copyFileForProcessingOutboundChannelAdapter() {
  
      FileWritingMessageHandler adapter = new FileWritingMessageHandler(new SpelExpressionParser().parseExpression("payload.parent"));
      adapter.setDeleteSourceFiles(false);
      adapter.setAutoCreateDirectory(true);
      adapter.setExpectReply(false);
      adapter.setFileNameGenerator(processingFileNameGenerator());
  
      return adapter;
  }
  
  @Bean
  public DefaultFileNameGenerator processingFileNameGenerator() {
      DefaultFileNameGenerator defaultFileNameGenerator = new DefaultFileNameGenerator();
      defaultFileNameGenerator.setExpression("'p_' + payload.name");
      return defaultFileNameGenerator;
  }
  </code></pre>