What about the intent behind how are developers supposed to use this tool?
For example, when Optional was introduced in Java 8, it was specified that it is intended to be used as a methods return type. And people should not use it as class member or method argument, even though the compiler will not prevent them to. Here is a language feature that comes with guidelines as to how it is intended to be used. Can you tell me how the expert group envisions usage of the ServiceLoader in Java 9, with reference to the original question (and any other thing you can add with regard to this). -----Original Message----- From: Alan Bateman [mailto:alan.bate...@oracle.com] Sent: יום ג 29 נובמבר 2016 14:06 To: Pisarev, Vitaliy <vitaliy.pisa...@hpe.com>; jigsaw-dev@openjdk.java.net Subject: Re: Services and Bindings - expected usage scenarios On 29/11/2016 11:35, Pisarev, Vitaliy wrote: > Another best practices question. > > I am aware that the ServiceLoader API is not new to Java. What's new > in Java 9 is that is has been put forward to the front of the stage and it is > now very easy for a service provider to register a service. > > The thing is that up until now, the ServiceLoader was a relatively low level > component, primarily used by infrastructure components that loaded plugins > that implemented various java specs. > It is no surprise than that the ServiceLoader is something that very few ever > heard of. > > Is it the intent of project Jigsaw that the service loader becomes a central > and ubiquitous mechanism in the day to day work of plain old java developers? > As far as I am concerned, it is a very useful tool even when I do not > have a plugin architecture and just want a module to expose a certain service > via an interface without having to jump throw hooks in order to provide the > consumer a way to instantiate it.. > > Which leads me to the next question: is the returned instance a singleton or > a prototype? Services are a first class part of the module system but are a somewhat advanced topic. The ServiceLoader API is part of the story but arguably just a small aspect when compared to the architectural and design issues involved in moving to services, loose coupling, and improved SoC. Provider factories can implement singletons where needed, the details are in the javadoc [1]. -Alan [1] http://download.java.net/java/jigsaw/docs/api/index.html