In this chapter, we've taken a detailed look at the services feature in the Java module system. We've learned the disadvantages of tight coupling of modules, and how loose coupling provides more flexibility. We then dove right into the syntax of creating and using services and then implemented a sorting service with two provider implementations. We then looked at some advanced concepts related to services, such as mechanisms for prioritizing service instances, using the service interface itself to handle service lookup, and deferring service instance creation using the Provider type in the case of heavy-weight services.
We then revisited the two goals of modularity--strong encapsulation and dependency injection--and evaluated how the services feature impacts those goals.
In the next chapter, we'll learn about the new linking phase that now applies to Java...