Class AbstractInboundFileSynchronizer<F>

java.lang.Object
org.springframework.integration.file.remote.synchronizer.AbstractInboundFileSynchronizer<F>
Type Parameters:
F - the Type that represents a remote file.
All Implemented Interfaces:
Closeable, AutoCloseable, Aware, BeanFactoryAware, BeanNameAware, InitializingBean, InboundFileSynchronizer
Direct Known Subclasses:
FtpInboundFileSynchronizer, SftpInboundFileSynchronizer, SmbInboundFileSynchronizer

public abstract class AbstractInboundFileSynchronizer<F> extends Object implements InboundFileSynchronizer, BeanFactoryAware, BeanNameAware, InitializingBean, Closeable
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.

Since:
2.0
Author:
Josh Long, Mark Fisher, Oleg Zhurakousky, Gary Russell, Artem Bilan, Ngoc Nhan
  • Field Details Link icon

    • EXPRESSION_PARSER Link icon

      protected static final ExpressionParser EXPRESSION_PARSER
    • logger Link icon

      protected final Log logger
  • Constructor Details Link icon

    • AbstractInboundFileSynchronizer Link icon

      public AbstractInboundFileSynchronizer(SessionFactory<F> sessionFactory)
      Create a synchronizer with the SessionFactory used to acquire Session instances.
      Parameters:
      sessionFactory - The session factory.
  • Method Details Link icon

    • getComparator Link icon

      @Nullable protected Comparator<? extends F> getComparator()
    • setComparator Link icon

      public void setComparator(@Nullable Comparator<? extends F> comparator)
      Set a comparator to sort the retrieved list of F (the Type that represents the remote file) prior to applying filters and max fetch size.
      Parameters:
      comparator - the comparator.
      Since:
      5.1
    • setRemoteFileSeparator Link icon

      public void setRemoteFileSeparator(String remoteFileSeparator)
      Parameters:
      remoteFileSeparator - the remote file separator.
      See Also:
    • setLocalFilenameGeneratorExpression Link icon

      public void setLocalFilenameGeneratorExpression(Expression localFilenameGeneratorExpression)
      Set an expression used to determine the local file name.
      Parameters:
      localFilenameGeneratorExpression - the expression.
    • setLocalFilenameGeneratorExpressionString Link icon

      public void setLocalFilenameGeneratorExpressionString(String localFilenameGeneratorExpression)
      Set an expression used to determine the local file name.
      Parameters:
      localFilenameGeneratorExpression - the expression.
      Since:
      4.3.13
      See Also:
    • setTemporaryFileSuffix Link icon

      public void setTemporaryFileSuffix(String temporaryFileSuffix)
      Set a temporary file suffix to be used while transferring files. Default ".writing".
      Parameters:
      temporaryFileSuffix - the file suffix.
    • setRemoteDirectory Link icon

      public void setRemoteDirectory(String remoteDirectory)
      Specify the full path to the remote directory.
      Parameters:
      remoteDirectory - The remote directory.
    • setRemoteDirectoryExpression Link icon

      public void setRemoteDirectoryExpression(Expression remoteDirectoryExpression)
      Specify an expression that evaluates to the full path to the remote directory.
      Parameters:
      remoteDirectoryExpression - The remote directory expression.
      Since:
      4.2
    • setRemoteDirectoryExpressionString Link icon

      public void setRemoteDirectoryExpressionString(String remoteDirectoryExpression)
      Specify an expression that evaluates to the full path to the remote directory.
      Parameters:
      remoteDirectoryExpression - The remote directory expression.
      Since:
      4.3.13
      See Also:
    • doSetRemoteDirectoryExpression Link icon

      protected final void doSetRemoteDirectoryExpression(Expression expression)
    • setFilter Link icon

      public void setFilter(@Nullable FileListFilter<F> filter)
      Set the filter to be applied to the remote files before transferring.
      Parameters:
      filter - the file list filter.
    • doSetFilter Link icon

      protected final void doSetFilter(@Nullable FileListFilter<F> filterToSet)
    • setDeleteRemoteFiles Link icon

      public void setDeleteRemoteFiles(boolean deleteRemoteFiles)
      Set to true to enable deletion of remote files after successful transfer.
      Parameters:
      deleteRemoteFiles - true to delete.
    • setPreserveTimestamp Link icon

      public void setPreserveTimestamp(boolean preserveTimestamp)
      Set to true to enable the preservation of the remote file timestamp when transferring.
      Parameters:
      preserveTimestamp - true to preserve.
    • setRemoteFileMetadataStore Link icon

      public void setRemoteFileMetadataStore(MetadataStore remoteFileMetadataStore)
      Configure a MetadataStore to hold a remote file info (host, port, remote directory) to transfer downstream in message headers when local file is pulled.
      Parameters:
      remoteFileMetadataStore - the MetadataStore to use.
      Since:
      5.2
    • setMetadataStorePrefix Link icon

      public void setMetadataStorePrefix(String metadataStorePrefix)
      Specify a prefix for keys in metadata store do not clash with other keys in the shared store.
      Parameters:
      metadataStorePrefix - the prefix to use.
      Since:
      5.2
      See Also:
    • setBeanFactory Link icon

      public void setBeanFactory(BeanFactory beanFactory) throws BeansException
      Specified by:
      setBeanFactory in interface BeanFactoryAware
      Throws:
      BeansException
    • setBeanName Link icon

      public void setBeanName(String name)
      Specified by:
      setBeanName in interface BeanNameAware
    • afterPropertiesSet Link icon

      public final void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface InitializingBean
    • doInit Link icon

      protected void doInit()
      Subclasses can override to perform initialization - called from InitializingBean.afterPropertiesSet().
    • filterFiles Link icon

      protected final List<F> filterFiles(F[] files)
    • getTemporaryFileSuffix Link icon

      protected String getTemporaryFileSuffix()
    • close Link icon

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • synchronizeToLocalDirectory Link icon

      public void synchronizeToLocalDirectory(File localDirectory)
      Description copied from interface: InboundFileSynchronizer
      Synchronize all available files to the local directory.
      Specified by:
      synchronizeToLocalDirectory in interface InboundFileSynchronizer
      Parameters:
      localDirectory - the directory.
    • synchronizeToLocalDirectory Link icon

      public void synchronizeToLocalDirectory(File localDirectory, int maxFetchSize)
      Description copied from interface: InboundFileSynchronizer
      Synchronize up to maxFetchSize files to the local directory.
      Specified by:
      synchronizeToLocalDirectory in interface InboundFileSynchronizer
      Parameters:
      localDirectory - the directory.
      maxFetchSize - the maximum files to fetch.
    • rollbackFromFileToListEnd Link icon

      protected void rollbackFromFileToListEnd(List<F> filteredFiles, F file)
    • copyFileToLocalDirectory Link icon

      protected boolean copyFileToLocalDirectory(@Nullable String remoteDirectoryPath, @Nullable EvaluationContext localFileEvaluationContext, F remoteFile, File localDirectory, Session<F> session) throws IOException
      Throws:
      IOException
    • getRemoteFileMetadata Link icon

      @Nullable public String getRemoteFileMetadata(File localFile)
      Obtain a metadata for remote file associated with the provided local file.
      Parameters:
      localFile - the local file to retrieve metadata for.
      Returns:
      the metadata for remove file in the URI style: protocol://host:port/remoteDirectory#remoteFileName
      Since:
      5.2
    • removeRemoteFileMetadata Link icon

      public void removeRemoteFileMetadata(File localFile)
      Remove a metadata for remote file associated with the provided local file.
      Parameters:
      localFile - the local file to remove metadata for.
      Since:
      5.2
    • isFile Link icon

      protected abstract boolean isFile(F file)
    • getFilename Link icon

      protected abstract String getFilename(F file)
    • getModified Link icon

      protected abstract long getModified(F file)
    • protocol Link icon

      protected abstract String protocol()
      Return the protocol this synchronizer works with.
      Returns:
      the protocol this synchronizer works with.
      Since:
      5.2