org.springframework.integration.adapter.file
Class AbstractDirectorySource

java.lang.Object
  extended by org.springframework.integration.adapter.file.AbstractDirectorySource
All Implemented Interfaces:
MessageDeliveryAware, MessageSource<java.lang.Object>
Direct Known Subclasses:
FileSource, FtpSource

public abstract class AbstractDirectorySource
extends java.lang.Object
implements MessageSource<java.lang.Object>, MessageDeliveryAware

Base class for implementing a Source that creates messages from files in a directory, either local or remote.

Author:
Marius Bogoevici

Field Summary
private  DirectoryContentManager directoryContentManager
           
static java.lang.String FILE_INFO_PROPERTY
           
private  org.apache.commons.logging.Log logger
           
private  MessageCreator<java.io.File,?> messageCreator
           
 
Constructor Summary
AbstractDirectorySource(MessageCreator<java.io.File,?> messageCreator)
           
 
Method Summary
protected abstract  void disconnect()
          Disconnects from the directory
protected abstract  void establishConnection()
          Connects to the directory, if necessary.
protected  DirectoryContentManager getDirectoryContentManager()
           
 MessageCreator<java.io.File,?> getMessageCreator()
           
 void onFailure(MessagingException exception)
          Callback method invoked after a message delivery failure.
 void onSend(Message<?> message)
          Callback method invoked after a message is sent successfully.
protected abstract  void populateSnapshot(java.util.Map<java.lang.String,FileInfo> snapshot)
          Constructs the snapshot by iterating files.
 Message receive()
          Retrieve a message from this source or null if no message is available.
protected abstract  java.io.File retrieveNextFile()
          Returns the next file, based on the backlog data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_INFO_PROPERTY

public static final java.lang.String FILE_INFO_PROPERTY
See Also:
Constant Field Values

logger

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

directoryContentManager

private final DirectoryContentManager directoryContentManager

messageCreator

private final MessageCreator<java.io.File,?> messageCreator
Constructor Detail

AbstractDirectorySource

public AbstractDirectorySource(MessageCreator<java.io.File,?> messageCreator)
Method Detail

getDirectoryContentManager

protected DirectoryContentManager getDirectoryContentManager()

getMessageCreator

public MessageCreator<java.io.File,?> getMessageCreator()

receive

public final Message receive()
Description copied from interface: MessageSource
Retrieve a message from this source or null if no message is available.

Specified by:
receive in interface MessageSource<java.lang.Object>

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

onFailure

public void onFailure(MessagingException exception)
Description copied from interface: MessageDeliveryAware
Callback method invoked after a message delivery failure.

Specified by:
onFailure in interface MessageDeliveryAware

establishConnection

protected abstract void establishConnection()
                                     throws java.io.IOException
Connects to the directory, if necessary.

Throws:
java.io.IOException

populateSnapshot

protected abstract void populateSnapshot(java.util.Map<java.lang.String,FileInfo> snapshot)
                                  throws java.io.IOException
Constructs the snapshot by iterating files.

Parameters:
snapshot -
Throws:
java.io.IOException

retrieveNextFile

protected abstract java.io.File retrieveNextFile()
                                          throws java.io.IOException
Returns the next file, based on the backlog data.

Returns:
Throws:
java.io.IOException

disconnect

protected abstract void disconnect()
Disconnects from the directory