org.springframework.integration.file.synchronization
Class AbstractInboundRemoteFileSystemSychronizer<F>

java.lang.Object
  extended by org.springframework.integration.context.IntegrationObjectSupport
      extended by org.springframework.integration.endpoint.AbstractEndpoint
          extended by org.springframework.integration.file.synchronization.AbstractInboundRemoteFileSystemSychronizer<F>
All Implemented Interfaces:
BeanFactoryAware, BeanNameAware, InitializingBean, Lifecycle, Phased, SmartLifecycle, NamedComponent
Direct Known Subclasses:
FtpInboundRemoteFileSystemSynchronizer, SftpInboundRemoteFileSystemSynchronizer

public abstract class AbstractInboundRemoteFileSystemSychronizer<F>
extends AbstractEndpoint

Base class charged with knowing how to connect to a remote file system, scan it for new files and then download the files.

The implementation should run through any configured FileListFilters to ensure the file entry is acceptable.


Nested Class Summary
static interface AbstractInboundRemoteFileSystemSychronizer.EntryAcknowledgmentStrategy<F>
          Strategy interface to expose a hook for dispatching, moving, or deleting the file once it has been delivered.
 
Field Summary
protected  AbstractInboundRemoteFileSystemSychronizer.EntryAcknowledgmentStrategy<F> entryAcknowledgmentStrategy
          The AbstractInboundRemoteFileSystemSychronizer.EntryAcknowledgmentStrategy implementation.
protected  FileListFilter<F> filter
          An FileListFilter that runs against the remote file system view.
protected  Resource localDirectory
          The directory to which we write our synchronizations.
protected  java.util.concurrent.ScheduledFuture<?> scheduledFuture
          The ScheduledFuture instance we get when we schedule our SynchronizeTask.
protected  boolean shouldDeleteSourceFile
          Should we delete the source file? For an FTP server, for example, this would delete the original FTPFile instance.
 
Fields inherited from class org.springframework.integration.context.IntegrationObjectSupport
logger
 
Constructor Summary
AbstractInboundRemoteFileSystemSychronizer()
           
 
Method Summary
protected  void acknowledge(java.lang.Object usefulContextOrClientData, F file)
           
protected  void doStart()
          Subclasses must implement this method with the start behavior.
protected  void doStop()
          Subclasses must implement this method with the stop behavior.
protected abstract  Trigger getTrigger()
          Returns the Trigger that dictates how frequently the trigger should fire.
 void setEntryAcknowledgmentStrategy(AbstractInboundRemoteFileSystemSychronizer.EntryAcknowledgmentStrategy<F> entryAcknowledgmentStrategy)
           
 void setFilter(FileListFilter<F> filter)
           
 void setLocalDirectory(Resource localDirectory)
           
 void setShouldDeleteSourceFile(boolean shouldDeleteSourceFile)
           
protected abstract  void syncRemoteToLocalFileSystem()
          This is the callback where we need the implementation to do some specific work
 
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, onInit, setBeanFactory, setBeanName, setComponentName, setConversionService, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

shouldDeleteSourceFile

protected boolean shouldDeleteSourceFile
Should we delete the source file? For an FTP server, for example, this would delete the original FTPFile instance.


localDirectory

protected volatile Resource localDirectory
The directory to which we write our synchronizations.


filter

protected volatile FileListFilter<F> filter
An FileListFilter that runs against the remote file system view.


scheduledFuture

protected java.util.concurrent.ScheduledFuture<?> scheduledFuture
The ScheduledFuture instance we get when we schedule our SynchronizeTask.


entryAcknowledgmentStrategy

protected AbstractInboundRemoteFileSystemSychronizer.EntryAcknowledgmentStrategy<F> entryAcknowledgmentStrategy
The AbstractInboundRemoteFileSystemSychronizer.EntryAcknowledgmentStrategy implementation.

Constructor Detail

AbstractInboundRemoteFileSystemSychronizer

public AbstractInboundRemoteFileSystemSychronizer()
Method Detail

setEntryAcknowledgmentStrategy

public void setEntryAcknowledgmentStrategy(AbstractInboundRemoteFileSystemSychronizer.EntryAcknowledgmentStrategy<F> entryAcknowledgmentStrategy)

setShouldDeleteSourceFile

public void setShouldDeleteSourceFile(boolean shouldDeleteSourceFile)

setLocalDirectory

public void setLocalDirectory(Resource localDirectory)

setFilter

public void setFilter(FileListFilter<F> filter)

acknowledge

protected void acknowledge(java.lang.Object usefulContextOrClientData,
                           F file)
                    throws java.lang.Throwable
Parameters:
usefulContextOrClientData - this is context information to be passed to the individual AbstractInboundRemoteFileSystemSychronizer.EntryAcknowledgmentStrategy. AbstractInboundRemoteFileSystemSychronizer.EntryAcknowledgmentStrategy.acknowledge(Object, Object) will be called in line with the MessageSource.receive() call so this could conceivably be a 'live' stateful client (a connection?) that is inappropriate to cache as it has per-request state.
file - leverages strategy implementations to enable different behavior. It's a hook to the file entry after it's been successfully downloaded. Conceptually, you might delete the remote one or rename it, etc.
Throws:
java.lang.Throwable - escape hatch exception, let the adapter deal with it.

doStart

protected void doStart()
Subclasses must implement this method with the start behavior. This method will be invoked while holding the AbstractEndpoint.lifecycleLock.

Specified by:
doStart in class AbstractEndpoint

doStop

protected void doStop()
Subclasses must implement this method with the stop behavior. This method will be invoked while holding the AbstractEndpoint.lifecycleLock.

Specified by:
doStop in class AbstractEndpoint

getTrigger

protected abstract Trigger getTrigger()
Returns the Trigger that dictates how frequently the trigger should fire.


syncRemoteToLocalFileSystem

protected abstract void syncRemoteToLocalFileSystem()
                                             throws java.lang.Exception
This is the callback where we need the implementation to do some specific work

Throws:
java.lang.Exception