eclipse-archived / smarthome

Eclipse SmartHome™ project
https://www.eclipse.org/smarthome/
Eclipse Public License 2.0
862 stars 783 forks source link

Watch Service - Register Directories After Service Initialization #2433

Open svilenvul opened 7 years ago

svilenvul commented 7 years ago

The current implementation of the AbstractWatchService has an option to watch sub directories, but not to register them after service initalization.

A workaround is made in the FolderObserver by calling initializeWatchService(), when a configuration change is detected. The drawback is that each time when we have to register a new directory WatchService close() method is being called.

I think it will make sense if we divide the code in the AbstractWatchService initializeWatchService() into two protected methods:

This will make possible for the classes that extend AbstractWatchService (including FolderObserver and maybe the new coming FileSystemFirmwareProvider ) to register new directories without closing the watch service and reinitializing it.

If you agree with this change I can create a PR for it.

svilenvul commented 7 years ago

Ahh and something else has to be taken into consideration. With this approach the classes that extend AbstractWatchService would have to manually process the folder CREATE event and call the super class method to register the directory.

kaikreuzer commented 6 years ago

Since we meanwhile had some refactorings of AbstractWatchService - is this still an issue that should be addressed?