Programming with ServiceLoader API in Java
summary
Demonstrates using ServiceLoader with Java modules to build a plugin-style soft‑drink example (softdrink interface, Coke/DietCoke and Pepsi/DietPepsi modules compiled to JARs) and runs a client on the command line; shows module descriptors using module provides/uses instead of exports, uses java.util.ServiceLoader for dynamic discovery, supports factory/static provider methods for non‑default constructors, shows lazy instantiation and caching, a reload() option, and streaming providers so metadata (annotations/types) can filter implementations.
AI-written summary · about
chapters (14)
- 0:00Introduction to Java modules
- 0:59Limitations of Java 8
- 2:12The Java module system
- 4:14The need for dynamic discovery
- 6:06Understanding plugin architecture
- 8:40Problems with reflection
- 11:15Introduction to Service Loader
- 13:20Creating the service interface
- 17:41Implementing the client module
- 23:28Implementing a provider
- 31:42Lazy loading and provider methods
- 40:57Caching and reloading services
- 44:26Functional style with streams
- 52:24Conclusion and summary
related talks
01h 01mClassloading in Action #underthehood
51mThe Java 9 Module System Beyond The Basics
01h 02mJava 9 Modularity in Action
50mIntroduction to Modular Development
48mThe Java Module System in practice
01h 00mThe Java Module System in Practice
39mPlug-in Architectures With Layrry & Java Module System
01h 08mJava APIs - the Missing Manual
