@ServiceProvider(ServiceInterface.class)
public class ServiceImplementation implements ServiceInterface {
// ...
}
public class Main {
public static void main(String[] args) {
ServiceLoader<ServiceInterface> loader = ServiceLoader.load(ServiceInterface.class);
for (ServiceInterface service : loader) {
service.doSomething();
}
}
}
com.example.ServiceInterface=com.example.ServiceImplementation