Class AbstractInboundFileSynchronizingMessageSource<F>

java.lang.Object
org.springframework.integration.util.AbstractExpressionEvaluator
org.springframework.integration.endpoint.AbstractMessageSource<T>
org.springframework.integration.endpoint.AbstractFetchLimitingMessageSource<java.io.File>
org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizingMessageSource<F>
Type Parameters:
F - the target system file type.
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle, org.springframework.integration.core.MessageSource<java.io.File>, org.springframework.integration.IntegrationPattern, org.springframework.integration.support.context.NamedComponent, org.springframework.integration.support.management.IntegrationInboundManagement, org.springframework.integration.support.management.IntegrationManagement, org.springframework.integration.support.management.ManageableLifecycle, org.springframework.integration.support.management.MessageSourceManagement

public abstract class AbstractInboundFileSynchronizingMessageSource<F>
extends org.springframework.integration.endpoint.AbstractFetchLimitingMessageSource<java.io.File>
implements org.springframework.integration.support.management.ManageableLifecycle
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 AbstractInboundFileSynchronizer. The synchronizer must handle the work of actually connecting to the remote file system and delivering new Files.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.springframework.integration.support.management.IntegrationManagement

    org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides
  • Field Summary

    Fields inherited from class org.springframework.integration.util.AbstractExpressionEvaluator

    EXPRESSION_PARSER, logger

    Fields inherited from interface org.springframework.integration.support.management.IntegrationManagement

    METER_PREFIX, RECEIVE_COUNTER_NAME, SEND_TIMER_NAME
  • Constructor Summary

    Constructors 
    Constructor Description
    AbstractInboundFileSynchronizingMessageSource​(AbstractInboundFileSynchronizer<F> synchronizer)  
    AbstractInboundFileSynchronizingMessageSource​(AbstractInboundFileSynchronizer<F> synchronizer, java.util.Comparator<java.io.File> comparator)  
  • Method Summary

    Modifier and Type Method Description
    org.springframework.integration.support.AbstractIntegrationMessageBuilder<java.io.File> doReceive​(int maxFetchSize)
    Polls from the file source.
    AbstractInboundFileSynchronizer<F> getSynchronizer()
    Return the underlying synchronizer.
    boolean isRunning()  
    protected void onInit()  
    void setAutoCreateLocalDirectory​(boolean autoCreateLocalDirectory)  
    void setLocalDirectory​(java.io.File localDirectory)  
    void setLocalFilter​(FileListFilter<java.io.File> localFileListFilter)
    A FileListFilter used to determine which files will generate messages after they have been synchronized.
    void setScanner​(DirectoryScanner scanner)
    Switch the local FileReadingMessageSource to use a custom DirectoryScanner.
    void setUseWatchService​(boolean useWatchService)
    Switch the local FileReadingMessageSource to use its internal FileReadingMessageSource.WatchServiceDirectoryScanner.
    void start()  
    void stop()  

    Methods inherited from class org.springframework.integration.endpoint.AbstractFetchLimitingMessageSource

    doReceive, getMaxFetchSize, setMaxFetchSize

    Methods inherited from class org.springframework.integration.endpoint.AbstractMessageSource

    buildMessage, destroy, getBeanName, getComponentName, getManagedName, getManagedType, getOverrides, isLoggingEnabled, receive, registerMetricsCaptor, setBeanName, setHeaderExpressions, setLoggingEnabled, setManagedName, setManagedType

    Methods inherited from class org.springframework.integration.util.AbstractExpressionEvaluator

    afterPropertiesSet, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, evaluateExpression, getBeanFactory, getEvaluationContext, getEvaluationContext, getMessageBuilderFactory, setBeanFactory, setConversionService

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.integration.support.management.IntegrationManagement

    getThisAs

    Methods inherited from interface org.springframework.integration.core.MessageSource

    getIntegrationPatternType

    Methods inherited from interface org.springframework.integration.support.context.NamedComponent

    getComponentType
  • Constructor Details

  • Method Details

    • setAutoCreateLocalDirectory

      public void setAutoCreateLocalDirectory​(boolean autoCreateLocalDirectory)
    • setLocalDirectory

      public void setLocalDirectory​(java.io.File localDirectory)
    • setLocalFilter

      public void setLocalFilter​(FileListFilter<java.io.File> localFileListFilter)
      A FileListFilter used to determine which files will generate messages after they have been synchronized. It will be combined with a filter that will prevent accessing files that are in the process of being synchronized (files having the AbstractInboundFileSynchronizer.getTemporaryFileSuffix()).

      The default is an FileSystemPersistentAcceptOnceFileListFilter which filters duplicate file names (processed during the current execution).

      Parameters:
      localFileListFilter - The local file list filter.
    • setUseWatchService

      public void setUseWatchService​(boolean useWatchService)
      Switch the local FileReadingMessageSource to use its internal FileReadingMessageSource.WatchServiceDirectoryScanner.
      Parameters:
      useWatchService - the boolean flag to switch to FileReadingMessageSource.WatchServiceDirectoryScanner on true.
      Since:
      5.0
    • setScanner

      public void setScanner​(DirectoryScanner scanner)
      Switch the local FileReadingMessageSource to use a custom DirectoryScanner.
      Parameters:
      scanner - the DirectoryScanner to use.
      Since:
      5.0
    • getSynchronizer

      public AbstractInboundFileSynchronizer<F> getSynchronizer()
      Return the underlying synchronizer.
      Returns:
      the synchronizer.
      Since:
      5.0.7
    • onInit

      protected void onInit()
      Overrides:
      onInit in class org.springframework.integration.util.AbstractExpressionEvaluator
    • start

      public void start()
      Specified by:
      start in interface org.springframework.context.Lifecycle
      Specified by:
      start in interface org.springframework.integration.support.management.ManageableLifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface org.springframework.context.Lifecycle
      Specified by:
      stop in interface org.springframework.integration.support.management.ManageableLifecycle
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle
      Specified by:
      isRunning in interface org.springframework.integration.support.management.ManageableLifecycle
    • doReceive

      public final org.springframework.integration.support.AbstractIntegrationMessageBuilder<java.io.File> doReceive​(int maxFetchSize)
      Polls from the file source. If the result is not null, it will be returned. If the result is null, it attempts to sync up with the remote directory to populate the file source. At most, maxFetchSize files will be fetched. Then, it polls the file source again and returns the result, whether or not it is null.
      Specified by:
      doReceive in class org.springframework.integration.endpoint.AbstractFetchLimitingMessageSource<java.io.File>
      Parameters:
      maxFetchSize - the maximum files to fetch.