ServiceLoader

The java.util class that finds implementations of a service interface at run time.

In more detail

A consumer module declares uses for the interface and calls ServiceLoader.load. A provider module declares provides Interface with Implementation. A named consumer without a uses directive gets a ServiceConfigurationError.

Example

for (Pricing p : ServiceLoader.load(Pricing.class)) { ... }

Related terms

Taught in

References

Certification courses