You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a java file watcher that works across platforms and supports recursion, single file watches, and tries to make sure no events are missed. Where possible it uses Java's NIO WatchService.
6
+
A Java file watcher that works across platforms and supports recursion, single file watches, and tries to make sure no events are missed.
7
7
8
8
## Features
9
9
@@ -21,7 +21,6 @@ Features:
21
21
22
22
Planned features:
23
23
24
-
- Avoid poll based watcher in macOS/OSX that only detects changes every 2 seconds (see [#4](https://github.com/SWAT-engineering/java-watch/issues/4))
25
24
- Support single file watches natively in linux (see [#11](https://github.com/SWAT-engineering/java-watch/issues/11))
26
25
- Monitor only specific events (such as only CREATE events)
27
26
@@ -58,6 +57,14 @@ try(var active = watcherSetup.start()) {
58
57
// no new events will be scheduled on the threadpool
59
58
```
60
59
60
+
## Internals
61
+
62
+
On all platforms except macOS, the library internally uses the JDK default implementation of the Java NIO [`WatchService`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/WatchService.html) API.
63
+
64
+
On macOS, the library internally uses our custom `WatchService` implementation based on macOS's native [file system event streams](https://developer.apple.com/documentation/coreservices/file_system_events?language=objc) (using JNA).
65
+
Generally, it offers better performance than the JDK default implementation (because the latter uses a polling loop to detect changes only once every two seconds).
66
+
To force the library to use the JDK default implementation on macOS, set system property `engineering.swat.watch.impl` to `default`.
67
+
61
68
## Related work
62
69
63
70
Before starting this library, we wanted to use existing libraries, but they all lacked proper support for recursive file watches, single file watches or lacked configurability. This library now has a growing collection of tests and a small API that should allow for future improvements without breaking compatibility.
0 commit comments