Summary

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 development thanks to modularity features. We'll also revisit the problem of the monolithic JDK that we discussed in Chapter 1, Introducing Java 9 Modularity, How can we make that better? How can we leverage the concepts of modularity to create leaner and meaner runtimes that are smaller and perform better? The answers to these questions and much more can be found in the next chapter!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.24.180