Class AcceptOnceFileListFilter<F>
java.lang.Object
org.springframework.integration.file.filters.AbstractFileListFilter<F>
org.springframework.integration.file.filters.AcceptOnceFileListFilter<F>
- All Implemented Interfaces:
FileListFilter<F>,ResettableFileListFilter<F>,ReversibleFileListFilter<F>
public class AcceptOnceFileListFilter<F> extends AbstractFileListFilter<F> implements ReversibleFileListFilter<F>, ResettableFileListFilter<F>
FileListFilter that passes files only one time. This can
conveniently be used to prevent duplication of files, as is done in
FileReadingMessageSource.
This implementation is thread safe.
- Author:
- Iwein Fuld, Josh Long, Gary Russell, Artem Bilan
-
Constructor Summary
Constructors Constructor Description AcceptOnceFileListFilter()Creates an AcceptOnceFileListFilter based on an unbounded queue.AcceptOnceFileListFilter(int maxCapacity)Creates an AcceptOnceFileListFilter that is based on a bounded queue. -
Method Summary
Modifier and Type Method Description booleanaccept(F file)Subclasses must implement this method.booleanremove(F fileToRemove)Remove the specified file from the filter so it will pass on the next attempt.voidrollback(F file, List<F> files)Indicate that not all files previously passed by this filter (inFileListFilter.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.Methods inherited from class org.springframework.integration.file.filters.AbstractFileListFilter
filterFiles, supportsSingleFileFilteringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.integration.file.filters.FileListFilter
filterFiles, isForRecursion, supportsSingleFileFiltering
-
Constructor Details
-
AcceptOnceFileListFilter
public AcceptOnceFileListFilter(int maxCapacity)Creates an AcceptOnceFileListFilter that is based on a bounded queue. If the queue overflows, files that fall out will be passed through this filter again if passed to theAbstractFileListFilter.filterFiles(Object[])- Parameters:
maxCapacity- the maximum number of Files to maintain in the 'seen' queue.
-
AcceptOnceFileListFilter
public AcceptOnceFileListFilter()Creates an AcceptOnceFileListFilter based on an unbounded queue.
-
-
Method Details
-
accept
Description copied from class:AbstractFileListFilterSubclasses must implement this method.- Specified by:
acceptin interfaceFileListFilter<F>- Specified by:
acceptin classAbstractFileListFilter<F>- Parameters:
file- The file.- Returns:
- true if the file passes the filter.
- See Also:
FileListFilter.supportsSingleFileFiltering()
-
rollback
Description copied from interface:ReversibleFileListFilterIndicate that not all files previously passed by this filter (inFileListFilter.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:
rollbackin interfaceReversibleFileListFilter<F>- Parameters:
file- the file which failed.files- the list of files that were returned byFileListFilter.filterFiles(Object[]).
-
remove
Description copied from interface:ResettableFileListFilterRemove the specified file from the filter so it will pass on the next attempt.- Specified by:
removein interfaceResettableFileListFilter<F>- Parameters:
fileToRemove- the element to remove.- Returns:
- true if the file was removed as a result of this call.
-