org.springframework.integration.file.synchronization
Class AbstractInboundRemoteFileSystemSynchronizingMessageSource<F,S extends AbstractInboundRemoteFileSystemSychronizer<F>>

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.endpoint.AbstractEndpoint
          extended by org.springframework.integration.endpoint.MessageProducerSupport
              extended by org.springframework.integration.file.synchronization.AbstractInboundRemoteFileSystemSynchronizingMessageSource<F,S>
All Implemented Interfaces:
BeanFactoryAware, BeanNameAware, InitializingBean, Lifecycle, Phased, SmartLifecycle, NamedComponent, MessageProducer, MessageSource<java.io.File>, TrackableComponent
Direct Known Subclasses:
FtpInboundRemoteFileSystemSynchronizingMessageSource, SftpInboundRemoteFileSystemSynchronizingMessageSource

public abstract class AbstractInboundRemoteFileSystemSynchronizingMessageSource<F,S extends AbstractInboundRemoteFileSystemSychronizer<F>>
extends MessageProducerSupport
implements MessageSource<java.io.File>

Factors out the common logic between the FTP and SFTP adapters. Designed to be extensible to handle adapters whose task it is to synchronize a remote file system with a local file system (NB: this does *NOT* handle pushing files TO the remote file system that exist uniquely in the local file system. It only handles pulling from the remote file system - as you would expect from an 'inbound' adapter).

The base class supports configuration of whether the remote file system and local file system's directories should be created on start (what 'creating a directory' means to the specific adapter is of course implementation specific).

This class is to be used as a pair with an implementation of AbstractInboundRemoteFileSystemSychronizer. The synchronizer must handle the work of actually connecting to the remote file system and delivering new Files.


Field Summary
protected  boolean autoCreateDirectories
          Should the endpoint attempt to create the local directory and/or the remote directory?
protected  FileReadingMessageSource fileSource
          The actual FileReadingMessageSource that monitors the local filesystem once files are synched.
static java.lang.String INCOMPLETE_EXTENSION
          Extension used when downloading files.
protected  Resource localDirectory
          Directory to which things should be synched locally.
protected  FileListFilter<F> remotePredicate
          The predicate to use in scanning the remote File system for downloads.
protected  S synchronizer
          An implementation that will handle the chores of actually connecting to and synching up the remote file system with the local one, in an inbound direction.
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Constructor Summary
AbstractInboundRemoteFileSystemSynchronizingMessageSource()
           
 
Method Summary
protected  void onInit()
          Subclasses may implement this for initialization logic.
 Message<java.io.File> receive()
          Retrieve the next available message from this source.
 void setAutoCreateDirectories(boolean autoCreateDirectories)
           
 void setLocalDirectory(Resource localDirectory)
           
 void setRemotePredicate(FileListFilter<F> remotePredicate)
           
 void setSynchronizer(S synchronizer)
           
 
Methods inherited from class org.springframework.integration.endpoint.MessageProducerSupport
doStart, doStop, sendMessage, setOutputChannel, setSendTimeout, setShouldTrack
 
Methods inherited from class org.springframework.integration.endpoint.AbstractEndpoint
getPhase, isAutoStartup, isRunning, setAutoStartup, setPhase, setTaskScheduler, start, stop, stop
 
Methods inherited from class org.springframework.integration.context.IntegrationObjectSupport
afterPropertiesSet, getBeanFactory, getComponentName, getComponentType, getConversionService, getTaskScheduler, setBeanFactory, setBeanName, setComponentName, setConversionService, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.springframework.integration.context.NamedComponent
getComponentName, getComponentType
 

Field Detail

INCOMPLETE_EXTENSION

public static final java.lang.String INCOMPLETE_EXTENSION
Extension used when downloading files. We change it right after we know it's downloaded.

See Also:
Constant Field Values

autoCreateDirectories

protected volatile boolean autoCreateDirectories
Should the endpoint attempt to create the local directory and/or the remote directory?


synchronizer

protected volatile S extends AbstractInboundRemoteFileSystemSychronizer<F> synchronizer
An implementation that will handle the chores of actually connecting to and synching up the remote file system with the local one, in an inbound direction.


localDirectory

protected volatile Resource localDirectory
Directory to which things should be synched locally.


fileSource

protected volatile FileReadingMessageSource fileSource
The actual FileReadingMessageSource that monitors the local filesystem once files are synched.


remotePredicate

protected FileListFilter<F> remotePredicate
The predicate to use in scanning the remote File system for downloads.

Constructor Detail

AbstractInboundRemoteFileSystemSynchronizingMessageSource

public AbstractInboundRemoteFileSystemSynchronizingMessageSource()
Method Detail

setAutoCreateDirectories

public void setAutoCreateDirectories(boolean autoCreateDirectories)

setSynchronizer

public void setSynchronizer(S synchronizer)

setLocalDirectory

public void setLocalDirectory(Resource localDirectory)

setRemotePredicate

public void setRemotePredicate(FileListFilter<F> remotePredicate)

onInit

protected void onInit()
Description copied from class: IntegrationObjectSupport
Subclasses may implement this for initialization logic.

Overrides:
onInit in class MessageProducerSupport

receive

public Message<java.io.File> receive()
Description copied from interface: MessageSource
Retrieve the next available message from this source. Returns null if no message is available.

Specified by:
receive in interface MessageSource<java.io.File>