INT-3858: Doc File Inbound scanner and filter
JIRA: https://jira.spring.io/browse/INT-3858 PR Comments
This commit is contained in:
committed by
Gary Russell
parent
3118596427
commit
152f46719a
@@ -189,20 +189,28 @@ If this is a problem in your case you should call FileLocker.unlock(File file) y
|
||||
When filtering and locking files is not enough it might be needed to control the way files are listed entirely.
|
||||
To implement this type of requirement you can use an implementation of `DirectoryScanner`.
|
||||
This scanner allows you to determine entirely what files are listed each poll.
|
||||
This is also the interface that Spring Integration uses internally to wire FileListFilters FileLocker to the FileReadingMessageSource.
|
||||
A custom DirectoryScanner can be injected into the <int-file:inbound-channel-adapter/> on the `scanner` attribute.
|
||||
This is also the interface that Spring Integration uses internally to wire `FileListFilter` s and `FileLocker` to the `FileReadingMessageSource`.
|
||||
A custom `DirectoryScanner` can be injected into the `<int-file:inbound-channel-adapter/>` on the `scanner` attribute.
|
||||
|
||||
[source,xml]
|
||||
----
|
||||
<int-file:inbound-channel-adapter id="filesIn" directory="file:${input.directory}"
|
||||
prevent-duplicates="true" scanner="customDirectoryScanner"/>
|
||||
scanner="customDirectoryScanner"/>
|
||||
----
|
||||
|
||||
This gives you full freedom to choose the ordering, listing and locking strategies.
|
||||
|
||||
IMPORTANT: It is important to understand that filters (including patterns, regex, prevent-duplicates etc) and lockers, are actually used by the scanner.
|
||||
Any of these attributes set on the adapter are subsequently injected into the scanner.
|
||||
For this reason, if you need to provide a custom scanner and you have multiple file inbound adapters in the same application context, each adapter must be provided with its own instance of the scanner, either by declaring separate beans, or declaring `scope="prototype"` on the scanner bean so that the context will create a new instance for each use.
|
||||
It is also important to understand that filters (including `patterns`, `regex`, `prevent-duplicates` etc) and `locker` s,
|
||||
are actually used by the `scanner`.
|
||||
Any of these attributes set on the adapter are subsequently injected into the internal `scanner`.
|
||||
For the case of an external `scanner`, all filter and locker attributes are prohibited on the
|
||||
`FileReadingMessageSource`; they must be specified (if required) on that custom `DirectoryScanner`.
|
||||
In other words, if you inject a `scanner` into the `FileReadingMessageSource`, you should supply `filter` and `locker`
|
||||
on that `scanner` not on the `FileReadingMessageSource`.
|
||||
|
||||
NOTE: The `DefaultDirectoryScanner` uses a `IgnoreHiddenFileListFilter` and `AcceptOnceFileListFilter` by default.
|
||||
To prevent their use, you should configure your own filter (e.g. `AcceptAllFileListFilter`) or even set it to `null`.
|
||||
|
||||
|
||||
==== WatchServiceDirectoryScanner
|
||||
|
||||
|
||||
Reference in New Issue
Block a user