0Pricing
Java Academy · Lesson

Services with provides/uses

Decouple with the service loader.

Decoupling with Services

Modules can collaborate without depending on each other's implementations using the service loader pattern.

A module declares it uses a service interface; another declares it provides an implementation. The JVM wires them together.

The Three Roles

A service has three participants:

  • Service interface: the contract, in some module
  • Provider: a module supplying an implementation
  • Consumer: a module that loads implementations at run time

All lessons in this course

  1. module-info.java
  2. requires and exports
  3. Services with provides/uses
  4. Migrating to Modules
← Back to Java Academy