org.springframework.integration.adapter.ftp
Class FtpSource

java.lang.Object
  extended by org.springframework.integration.adapter.file.AbstractDirectorySource<java.util.List<java.io.File>>
      extended by org.springframework.integration.adapter.ftp.FtpSource
All Implemented Interfaces:
MessageDeliveryAware, MessageSource<java.util.List<java.io.File>>, PollableSource<java.util.List<java.io.File>>

public class FtpSource
extends AbstractDirectorySource<java.util.List<java.io.File>>

A source adapter for receiving files via FTP.

Author:
Marius Bogoevici, Mark Fisher, Iwein Fuld

Field Summary
private  FTPClientPool clientPool
           
private  java.io.File localWorkingDirectory
           
private  org.apache.commons.logging.Log logger
           
private  int maxFilesPerPayload
           
 
Fields inherited from class org.springframework.integration.adapter.file.AbstractDirectorySource
FILE_INFO_PROPERTY
 
Constructor Summary
FtpSource(MessageCreator<java.util.List<java.io.File>,java.util.List<java.io.File>> messageCreator, FTPClientPool clientPool)
           
 
Method Summary
 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  void refreshSnapshotAndMarkProcessing(Backlog<FileInfo> directoryContentManager)
          Naive implementation that ignores thread safety.
protected  java.util.List<java.io.File> retrieveNextPayload()
          Returns the next file, based on the backlog data.
 void setLocalWorkingDirectory(java.io.File localWorkingDirectory)
           
 void setMaxMessagesPerPayload(int maxMessagesPerPayload)
           
 
Methods inherited from class org.springframework.integration.adapter.file.AbstractDirectorySource
buildNextMessage, fileProcessed, getDirectoryContentManager, getMessageCreator, onFailure, receive
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private final org.apache.commons.logging.Log logger

localWorkingDirectory

private volatile java.io.File localWorkingDirectory

maxFilesPerPayload

private int maxFilesPerPayload

clientPool

private final FTPClientPool clientPool
Constructor Detail

FtpSource

public FtpSource(MessageCreator<java.util.List<java.io.File>,java.util.List<java.io.File>> messageCreator,
                 FTPClientPool clientPool)
Method Detail

setMaxMessagesPerPayload

public void setMaxMessagesPerPayload(int maxMessagesPerPayload)

setLocalWorkingDirectory

public void setLocalWorkingDirectory(java.io.File localWorkingDirectory)

refreshSnapshotAndMarkProcessing

protected void refreshSnapshotAndMarkProcessing(Backlog<FileInfo> directoryContentManager)
                                         throws java.io.IOException
Description copied from class: AbstractDirectorySource
Naive implementation that ignores thread safety. Subclasses that want to be thread safe and use the reservation facilities of Backlog should override this method and call directoryContentManager.fileProcessing(...) with the appropriate arguments.

Overrides:
refreshSnapshotAndMarkProcessing in class AbstractDirectorySource<java.util.List<java.io.File>>
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<java.util.List<java.io.File>>
Throws:
java.io.IOException

retrieveNextPayload

protected java.util.List<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.util.List<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.util.List<java.io.File>>