----- Mail original ----- > De: "Alex Sviridov" <ooo_satu...@mail.ru> > À: "jigsaw-dev" <jigsaw-dev@openjdk.java.net> > Envoyé: Vendredi 20 Novembre 2020 12:48:21 > Objet: Why service provider method is called "provider", but not "provide"?
> Hello all, Hi Alex, > > According to this tutorial > https://www.logicbig.com/tutorials/core-java-tutorial/modules/service-provider-method.html > we can declare in module-info provider class with "provider" method. For > example, > > ...... > public class TheServiceProvider { > public static AService provider() { > return new AServiceImpl(); > } > } > > The only thing what I don’t understand is why this method is called > "provider". > The method doesn’t return > provider, method returns an instance of the service, so, as I understand, the > method must be named > "provide". And, as I understand, provider is usually the class, that has > "provide" method. The spec is in ServiceLoader https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/util/ServiceLoader.html yes, the name is not very logical. > > Of course that’s not very important, but it is JDK, so it was developed by > very > experienced java developer > who should know java naming convention and I want to understand why this did > so. > Could anyone explain? I believe it's due to the fact that most services used by the JDK are themselves factories. And naming is hard. > > > -- > Best regards, Alex Orlov regards, Rémi