org.springframework.integration.adapter.file
Class FileSource

java.lang.Object
  extended by org.springframework.integration.adapter.file.AbstractDirectorySource
      extended by org.springframework.integration.adapter.file.FileSource
All Implemented Interfaces:
org.springframework.beans.factory.InitializingBean, MessageDeliveryAware, MessageSource<java.lang.Object>

public class FileSource
extends AbstractDirectorySource
implements MessageSource<java.lang.Object>, org.springframework.beans.factory.InitializingBean, MessageDeliveryAware

A messaging source that polls a directory to retrieve files.

Author:
Mark Fisher, Marius Bogoevici

Field Summary
private  java.io.File directory
           
private  java.io.FileFilter fileFilter
           
private  java.io.FilenameFilter filenameFilter
           
private  MessageCreator<java.io.File,?> messageCreator
           
 
Fields inherited from class org.springframework.integration.adapter.file.AbstractDirectorySource
FILE_INFO_PROPERTY
 
Constructor Summary
FileSource(org.springframework.core.io.Resource directory)
           
FileSource(org.springframework.core.io.Resource directory, MessageCreator<java.io.File,?> messageCreator)
           
 
Method Summary
 void afterPropertiesSet()
           
protected  void disconnect()
          Disconnects from the directory
protected  void establishConnection()
          Connects to the directory, if necessary.
protected  void populateSnapshot(java.util.Map<java.lang.String,FileInfo> snapshot)
          Constructs the snapshot by iterating files.
protected  java.io.File retrieveNextFile()
          Returns the next file, based on the backlog data.
 void setFileFilter(java.io.FileFilter fileFilter)
           
 void setFilenameFilter(java.io.FilenameFilter filenameFilter)
           
 void setMessageCreator(MessageCreator<java.io.File,?> messageCreator)
           
 
Methods inherited from class org.springframework.integration.adapter.file.AbstractDirectorySource
getDirectoryContentManager, getMessageCreator, onFailure, onSend, receive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.springframework.integration.message.MessageSource
receive
 
Methods inherited from interface org.springframework.integration.message.MessageDeliveryAware
onFailure, onSend
 

Field Detail

directory

private final java.io.File directory

messageCreator

private volatile MessageCreator<java.io.File,?> messageCreator

fileFilter

private volatile java.io.FileFilter fileFilter

filenameFilter

private volatile java.io.FilenameFilter filenameFilter
Constructor Detail

FileSource

public FileSource(org.springframework.core.io.Resource directory)

FileSource

public FileSource(org.springframework.core.io.Resource directory,
                  MessageCreator<java.io.File,?> messageCreator)
Method Detail

setMessageCreator

public void setMessageCreator(MessageCreator<java.io.File,?> messageCreator)

setFileFilter

public void setFileFilter(java.io.FileFilter fileFilter)

setFilenameFilter

public void setFilenameFilter(java.io.FilenameFilter filenameFilter)

afterPropertiesSet

public void afterPropertiesSet()
Specified by:
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean

disconnect

protected void disconnect()
Description copied from class: AbstractDirectorySource
Disconnects from the directory

Specified by:
disconnect in class AbstractDirectorySource

establishConnection

protected void establishConnection()
                            throws java.io.IOException
Description copied from class: AbstractDirectorySource
Connects to the directory, if necessary.

Specified by:
establishConnection in class AbstractDirectorySource
Throws:
java.io.IOException

populateSnapshot

protected void populateSnapshot(java.util.Map<java.lang.String,FileInfo> snapshot)
                         throws java.io.IOException
Description copied from class: AbstractDirectorySource
Constructs the snapshot by iterating files.

Specified by:
populateSnapshot in class AbstractDirectorySource
Throws:
java.io.IOException

retrieveNextFile

protected java.io.File retrieveNextFile()
                                 throws java.io.IOException
Description copied from class: AbstractDirectorySource
Returns the next file, based on the backlog data.

Specified by:
retrieveNextFile in class AbstractDirectorySource
Returns:
Throws:
java.io.IOException