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
- module-info.java
- requires and exports
- Services with provides/uses
- Migrating to Modules