10 Using services to decouple modules

This chapter covers

  • Improving project designs with services
  • Creating services, consumers, and providers in the JPMS
  • Using the ServiceLoader to consume services
  • Developing well-designed services
  • Deploying services in plain and modular JARs across different Java versions

Up to now, we represented relationships between modules with requires directives where the depending module has to reference each specific dependency by name. As section 3.2 explains in depth, this lies at the heart of reliable configuration. But sometimes you want a higher level of abstraction.

This chapter explores services in the module system and how to use them to decouple modules by removing direct dependencies between them. The first ...

Get The Java Module System now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.