Class AbstractMarkerFilePresentFileListFilter<F>

java.lang.Object
org.springframework.integration.file.filters.AbstractMarkerFilePresentFileListFilter<F>
Type Parameters:
F - the target protocol file type.
All Implemented Interfaces:
FileListFilter<F>
Direct Known Subclasses:
FileSystemMarkerFilePresentFileListFilter, FtpSystemMarkerFilePresentFileListFilter, SftpSystemMarkerFilePresentFileListFilter, SmbSystemMarkerFilePresentFileListFilter

public abstract class AbstractMarkerFilePresentFileListFilter<F> extends Object implements FileListFilter<F>
A FileListFilter that only passes files matched by one or more FileListFilter if a corresponding marker file is also present to indicate a file transfer is complete. Since they look at multiple files, they cannot be used for late filtering in the streaming message source.
Since:
5.0
Author:
Gary Russell
  • Constructor Details

    • AbstractMarkerFilePresentFileListFilter

      public AbstractMarkerFilePresentFileListFilter(FileListFilter<F> filter)
      Construct an instance with a single FileListFilter and ".complete" will be appended to the name of a matched file when looking for the marker file. i.e. if a file foo.txt is matched by the filter this filter will only pass "foo.txt" if "foo.txt.complete" is present.
      Parameters:
      filter - the file name filter.
    • AbstractMarkerFilePresentFileListFilter

      public AbstractMarkerFilePresentFileListFilter(FileListFilter<F> filter, String suffix)
      Construct an instance with a single FileListFilter and a suffix that will will be appended to the name of a matched file when looking for the marker file. i.e. if a file foo.txt is matched by the filter and the suffix is ".complete", this filter will only pass "foo.txt" if "foo.txt.complete" is present.
      Parameters:
      filter - the file name filter.
      suffix - the replacement suffix.
    • AbstractMarkerFilePresentFileListFilter

      public AbstractMarkerFilePresentFileListFilter(FileListFilter<F> filter, Function<String,String> function)
      Construct an instance with a single FileListFilter and a function that will be applied to the name of a matched file when looking for the marker file. The function returns the name of the marker file to match, or null for never match. If a file foo.txt is matched by the filter and the function returns "foo.txt.complete", this filter will only pass "foo.txt" if "foo.txt.complete" is present.
      Parameters:
      filter - the file name filter.
      function - the function to create the marker file name from the file name.
    • AbstractMarkerFilePresentFileListFilter

      public AbstractMarkerFilePresentFileListFilter(Map<FileListFilter<F>,Function<String,String>> filtersAndFunctions)
      Construct an instance with a map of FileListFilter and functions be applied to the name of a matched file when looking for the marker file. i.e. if a file foo.txt is matched by one of the filters and the corresponding function returns "foo.txt.complete", this filter will only pass "foo.txt" if "foo.txt.complete" is present. The function returns the name of the marker file to match, or null for never match. Due to type erasure, we cannot provide a constructor taking Map<Filter, Function>. For convenience, you can use defaultFileNameFunction(String) to use the default function used by the AbstractMarkerFilePresentFileListFilter(FileListFilter, String) constructor.
      Parameters:
      filtersAndFunctions - the filters and functions.
  • Method Details

    • defaultFileNameFunction

      public static Function<String,String> defaultFileNameFunction(String suffix)
      The default function used to create the file name for the corresponding marker file. Appends a suffix to the file name.
      Parameters:
      suffix - the suffix to append.
      Returns:
      the function.
    • filterFiles

      public List<F> filterFiles(F[] files)
      Description copied from interface: FileListFilter
      Filters out files and returns the files that are left in a list, or an empty list when a null is passed in.
      Specified by:
      filterFiles in interface FileListFilter<F>
      Parameters:
      files - The files.
      Returns:
      The filtered files.
    • getFilename

      protected abstract String getFilename(F file)
      Return the name of the file represented by this F.
      Parameters:
      file - the file.
      Returns:
      the name.