Closed brutskov closed 4 years ago
Good suggestion. I'll see about rolling that out soon.
@sbabcoc , thank you!
I have a pull request that implements the revised watcher attachment strategy: https://github.com/Nordstrom/JUnit-Foundation/pull/63 This set of revisions consolidates the declaration of JUnit Foundation service providers into a single configuration file. Support for the previous file-per-interface approach is retained to provide backward compatibility. One significant benefit to switching from ServiceLoaders to pre-initialized unmodifiable lists is that I no longer need to synchronize my iterators. The code is therefore smaller and less complicated. Another benefit is that we no longer end up with multiple instances of each service provider that implements multiple interfaces. Previously, a separate instance would be instantiated for each implemented interface.
You are using service loader to load customer listeners and watchers by component (one listener - one service file). It makes sense to create some marker interface (like LifecycleItem) and load all listeners and watchers on one ServiceLoader call. You'l resolve and collect our listeners by type on your side but users will be have only one META-INF/services/LifecycleItem file in the classpath.