concept ServiceLoader in category java

This is an excerpt from Manning's book The Java Module System.
At run time, the depending module can use the
ServiceLoaderclass to get all provided implementations of a service by callingServiceLoader.load(${service}.class). The module system then returns aProvider<${service}>for each provider any module in the module graph declares. Figure 10.3 illustrates implementing aProvider.Figure 10.3 At the center of using services is a specific type, here called
Service. The classProviderimplements it, and the module containing it declares that with aprovides — withdirective. Modules consuming services need to declare that with ausesdirective. At run time, they can then use theServiceLoaderto get instances of all providers for a given service.![]()