INT-3229: Add WatchServiceDirectoryScanner
JIRA: https://jira.spring.io/browse/INT-3229 Polishing
This commit is contained in:
committed by
Artem Bilan
parent
f1fc0edbf3
commit
c986206059
@@ -204,6 +204,34 @@ IMPORTANT: It is important to understand that filters (including patterns, regex
|
||||
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.
|
||||
|
||||
==== WatchServiceDirectoryScanner
|
||||
|
||||
This scanner was added in _version 4.2_. It replaces the existing `RecursiveLeafOnlyDirectoryScanner` which is
|
||||
inefficient for large directory trees. The `WatchServiceDirectoryScanner` requires Java 7 or above.
|
||||
|
||||
This scanner relies on file system events when new files are added to the directory.
|
||||
During initialization, the directory is registered to generate events; the initial file list is also built.
|
||||
While walking the directory tree, any subdirectories encountered are also registered to generate events.
|
||||
On the first poll, the initial file list from walking the directory is returned.
|
||||
On subsequent polls, files from new creation events are returned.
|
||||
If a new subdirectory is added, its creation event is used to walk the new subtree to find existing files, as well
|
||||
as registering any new subdirectories found.
|
||||
|
||||
[source, xml]
|
||||
----
|
||||
<bean id="wsScanner" class="org.springframework.integration.file.WatchServiceDirectoryScanner">
|
||||
<constructor-arg value="/tmp/myDir" />
|
||||
</bean>
|
||||
----
|
||||
|
||||
[source, java]
|
||||
----
|
||||
@Bean
|
||||
public DirectoryScanner scanner() {
|
||||
return new WatchServiceDirectoryScanner("/tmp/myDir");
|
||||
}
|
||||
----
|
||||
|
||||
==== Limiting Memory Consumption
|
||||
|
||||
A `HeadDirectoryScanner` can be used to limit the number of files retained in memory.
|
||||
|
||||
@@ -84,6 +84,10 @@ The `HeadDirectoryScanner` can now be used with other `FileListFilter` s.
|
||||
|
||||
The `LastModifiedFileListFilter` has been added.
|
||||
|
||||
===== WatchService Directory Scanner
|
||||
|
||||
The `WatchServiceDirectoryScanner` is now available.
|
||||
|
||||
[[x4.2-class-package-change]]
|
||||
==== Class Package Change
|
||||
|
||||
|
||||
Reference in New Issue
Block a user