org.springframework.integration.adapter.file
Class FileSource
java.lang.Object
org.springframework.integration.adapter.file.AbstractDirectorySource<java.io.File>
org.springframework.integration.adapter.file.FileSource
- All Implemented Interfaces:
- MessageDeliveryAware, MessageSource<java.io.File>, PollableSource<java.io.File>
public class FileSource
- extends AbstractDirectorySource<java.io.File>
- implements MessageDeliveryAware
A messaging source that polls a directory to retrieve files.
- Author:
- Mark Fisher, Marius Bogoevici
Constructor Summary |
FileSource(org.springframework.core.io.Resource directory)
|
FileSource(org.springframework.core.io.Resource directory,
MessageCreator<java.io.File,java.io.File> messageCreator)
|
Method Summary |
protected Message<java.io.File> |
buildNextMessage()
Hook point for implementors to create the next message that should be
received. |
void |
onSend(Message<?> message)
Callback method invoked after a message is sent successfully. |
protected void |
populateSnapshot(java.util.Map<java.lang.String,FileInfo> snapshot)
Constructs the snapshot by iterating files. |
protected java.io.File |
retrieveNextPayload()
Returns the next file, based on the backlog data. |
void |
setFileFilter(java.io.FileFilter fileFilter)
|
void |
setFilenameFilter(java.io.FilenameFilter filenameFilter)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
logger
private final org.apache.commons.logging.Log logger
directory
private final java.io.File directory
fileFilter
private volatile java.io.FileFilter fileFilter
filenameFilter
private volatile java.io.FilenameFilter filenameFilter
FileSource
public FileSource(org.springframework.core.io.Resource directory)
FileSource
public FileSource(org.springframework.core.io.Resource directory,
MessageCreator<java.io.File,java.io.File> messageCreator)
buildNextMessage
protected Message<java.io.File> buildNextMessage()
throws java.io.IOException
- Description copied from class:
AbstractDirectorySource
- Hook point for implementors to create the next message that should be
received. Implementations can use a File by File approach (like
FileSource). In cases where retrieval could be expensive because of
network latency, a batched approach could be implemented here. See
FtpSource for an example.
- Overrides:
buildNextMessage
in class AbstractDirectorySource<java.io.File>
- Returns:
- the next message containing (part of) the unprocessed content of
the directory
- Throws:
java.io.IOException
setFileFilter
public void setFileFilter(java.io.FileFilter fileFilter)
setFilenameFilter
public void setFilenameFilter(java.io.FilenameFilter filenameFilter)
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<java.io.File>
- Throws:
java.io.IOException
retrieveNextPayload
protected java.io.File retrieveNextPayload()
throws java.io.IOException
- Description copied from class:
AbstractDirectorySource
- Returns the next file, based on the backlog data.
- Specified by:
retrieveNextPayload
in class AbstractDirectorySource<java.io.File>
- Returns:
-
- Throws:
java.io.IOException
onSend
public void onSend(Message<?> message)
- Description copied from interface:
MessageDeliveryAware
- Callback method invoked after a message is sent successfully.
- Specified by:
onSend
in interface MessageDeliveryAware
- Specified by:
onSend
in class AbstractDirectorySource<java.io.File>