Class AbstractPersistentAcceptOnceFileListFilter<F>

java.lang.Object
org.springframework.integration.file.filters.AbstractFileListFilter<F>
org.springframework.integration.file.filters.AbstractDirectoryAwareFileListFilter<F>
org.springframework.integration.file.filters.AbstractPersistentAcceptOnceFileListFilter<F>
Type Parameters:
F - the file type.
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable, FileListFilter<F>, ResettableFileListFilter<F>, ReversibleFileListFilter<F>
Direct Known Subclasses:
FileSystemPersistentAcceptOnceFileListFilter

public abstract class AbstractPersistentAcceptOnceFileListFilter<F>
extends AbstractDirectoryAwareFileListFilter<F>
implements ReversibleFileListFilter<F>, ResettableFileListFilter<F>, java.io.Closeable
Stores "seen" files in a MetadataStore to survive application restarts. The default key is 'prefix' plus the absolute file name; value is the timestamp of the file. Files are deemed as already 'seen' if they exist in the store and have the same modified time as the current file.
Since:
3.0
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected java.io.Flushable flushableStore  
    protected boolean flushOnUpdate  
    protected java.lang.String prefix  
    protected org.springframework.integration.metadata.ConcurrentMetadataStore store  
  • Constructor Summary

    Constructors 
    Constructor Description
    AbstractPersistentAcceptOnceFileListFilter​(org.springframework.integration.metadata.ConcurrentMetadataStore store, java.lang.String prefix)  
  • Method Summary

    Modifier and Type Method Description
    boolean accept​(F file)
    Subclasses must implement this method.
    protected java.lang.String buildKey​(F file)
    The default key is the prefix plus the full filename.
    void close()  
    protected abstract java.lang.String fileName​(F file)  
    protected boolean fileStillExists​(F file)
    Check if the file still exists; default implementation returns true.
    protected void flushIfNeeded()
    Flush the store if it's a Flushable and flushOnUpdate is true.
    protected boolean isDirectory​(F file)
    Subclasses must implement this method to indicate whether the file is a directory or not.
    protected boolean isEqual​(F file, java.lang.String value)
    Override this method if you wish to use something other than the modified timestamp to determine equality.
    protected abstract long modified​(F file)  
    boolean remove​(F fileToRemove)
    Remove the specified file from the filter, so it will pass on the next attempt.
    void rollback​(F file, java.util.List<F> files)
    Indicate that not all files previously passed by this filter (in FileListFilter.filterFiles(Object[]) have been processed; the file must be in the list of files; it, and all files after it, will be considered to have not been processed and will be considered next time.
    void setFlushOnUpdate​(boolean flushOnUpdate)
    Determine whether the metadataStore should be flushed on each update (if Flushable).

    Methods inherited from class org.springframework.integration.file.filters.AbstractDirectoryAwareFileListFilter

    alwaysAccept, isForRecursion, setAlwaysAcceptDirectories, setForRecursion

    Methods inherited from class org.springframework.integration.file.filters.AbstractFileListFilter

    filterFiles, supportsSingleFileFiltering

    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.file.filters.FileListFilter

    filterFiles, isForRecursion, supportsSingleFileFiltering
  • Field Details

    • store

      protected final org.springframework.integration.metadata.ConcurrentMetadataStore store
    • prefix

      protected final java.lang.String prefix
    • flushableStore

      @Nullable protected final java.io.Flushable flushableStore
    • flushOnUpdate

      protected boolean flushOnUpdate
  • Constructor Details

  • Method Details

    • setFlushOnUpdate

      public void setFlushOnUpdate​(boolean flushOnUpdate)
      Determine whether the metadataStore should be flushed on each update (if Flushable).
      Parameters:
      flushOnUpdate - true to flush.
      Since:
      4.1.5
    • accept

      public boolean accept​(F file)
      Description copied from class: AbstractFileListFilter
      Subclasses must implement this method.
      Specified by:
      accept in interface FileListFilter<F>
      Specified by:
      accept in class AbstractFileListFilter<F>
      Parameters:
      file - The file.
      Returns:
      true if the file passes the filter.
      See Also:
      FileListFilter.supportsSingleFileFiltering()
    • fileStillExists

      protected boolean fileStillExists​(F file)
      Check if the file still exists; default implementation returns true.
      Parameters:
      file - the file.
      Returns:
      true if the filter should return true.
      Since:
      4.3.19
    • rollback

      public void rollback​(F file, java.util.List<F> files)
      Indicate that not all files previously passed by this filter (in FileListFilter.filterFiles(Object[]) have been processed; the file must be in the list of files; it, and all files after it, will be considered to have not been processed and will be considered next time.
      Specified by:
      rollback in interface ReversibleFileListFilter<F>
      Parameters:
      file - the file which failed.
      files - the list of files that were returned by FileListFilter.filterFiles(Object[]).
      Since:
      4.0.4
    • remove

      public boolean remove​(F fileToRemove)
      Description copied from interface: ResettableFileListFilter
      Remove the specified file from the filter, so it will pass on the next attempt.
      Specified by:
      remove in interface ResettableFileListFilter<F>
      Parameters:
      fileToRemove - the element to remove.
      Returns:
      true if the file was removed as a result of this call.
    • close

      public void close() throws java.io.IOException
      Specified by:
      close in interface java.lang.AutoCloseable
      Specified by:
      close in interface java.io.Closeable
      Throws:
      java.io.IOException
    • isEqual

      protected boolean isEqual​(F file, java.lang.String value)
      Override this method if you wish to use something other than the modified timestamp to determine equality.
      Parameters:
      file - The file.
      value - The current value for the key in the store.
      Returns:
      true if equal.
    • buildKey

      protected java.lang.String buildKey​(F file)
      The default key is the prefix plus the full filename.
      Parameters:
      file - The file.
      Returns:
      The key.
    • flushIfNeeded

      protected void flushIfNeeded()
      Flush the store if it's a Flushable and flushOnUpdate is true.
      Since:
      1.4.5
    • isDirectory

      protected boolean isDirectory​(F file)
      Description copied from class: AbstractDirectoryAwareFileListFilter
      Subclasses must implement this method to indicate whether the file is a directory or not.
      Specified by:
      isDirectory in class AbstractDirectoryAwareFileListFilter<F>
      Parameters:
      file - the file.
      Returns:
      true if it's a directory.
    • modified

      protected abstract long modified​(F file)
    • fileName

      protected abstract java.lang.String fileName​(F file)