Re: ClassLoader.getResources vs Module.getResourceAsStream

2018-07-16 Thread Michał Zegan
Well, these are not stateless factories that you register as a service and then discover to later use them to create some objects. Those are factories that implement a specific algorithm like crypto algorithm, or that are adapters for a crypto library like for JCA, in the second case one factory cl

Re: ClassLoader.getResources vs Module.getResourceAsStream

2018-07-16 Thread Alan Bateman
On 16/07/2018 14:08, Bernard Amade wrote after java 8 the case of internationalisation is the worst case of resource handling: - creating diverse resource files (for different cultural contexts) means they might be spread along different jars (you receive an app in your country - that uses a str

Re: ClassLoader.getResources vs Module.getResourceAsStream

2018-07-16 Thread Bernard Amade
> > ServiceLoader is completely the wrong solution for config files. Its > far too heavyweight. > after java 8 the case of internationalisation is the worst case of resource handling: - creating diverse resource files (for different cultural contexts) means they might be spread along different

Re: ClassLoader.getResources vs Module.getResourceAsStream

2018-07-16 Thread Alan Bateman
On 16/07/2018 09:09, Remi Forax wrote: : Alan, we should patch jar to warn when there is a module-info.class that declare services with no corresponding META-INF/services. I'll create an issue in JIRA for that. As things stands, the `jar` tool does some sanity checks but it doesn't catch t

Re: ClassLoader.getResources vs Module.getResourceAsStream

2018-07-16 Thread Alan Bateman
On 16/07/2018 11:06, Stephen Colebourne wrote: In my experience (as I've written before), ClassLoader.getResources is perhaps the biggest pain point I've experienced in trying to move beyond Java 8. The method seems to have been very widely used, and IMO was considered to be preferred over Class.

Re: ClassLoader.getResources vs Module.getResourceAsStream

2018-07-16 Thread Stephen Colebourne
In my experience (as I've written before), ClassLoader.getResources is perhaps the biggest pain point I've experienced in trying to move beyond Java 8. The method seems to have been very widely used, and IMO was considered to be preferred over Class.getResourceXxx. And it is very confusing to use o

Re: ClassLoader.getResources vs Module.getResourceAsStream

2018-07-16 Thread Remi Forax
- Mail original - > De: "Sander Mak" > À: "jigsaw-dev" > Envoyé: Lundi 16 Juillet 2018 08:52:41 > Objet: Re: ClassLoader.getResources vs Module.getResourceAsStream > In that case you'd expose the factories through the services mechanism > (

Re: ClassLoader.getResources vs Module.getResourceAsStream

2018-07-15 Thread Sander Mak
In that case you'd expose the factories through the services mechanism (`provides com.acme.api.MyWidgetFactory with com.acme.factories.XmlBasedWidgetFactory` in the module descriptor). Or, if you must expose the XML itself to the outside world rather than the factories, you can create a service

Re: ClassLoader.getResources vs Module.getResourceAsStream

2018-07-14 Thread Michał Zegan
It is a completely new code. It is not modularized for now because some dependencies are not modularized, but I want it to be compatible to ease later modularization. My actual goal is to load xml files defining and configuring some factories, from all modules that contain them. Not sure how would

Re: ClassLoader.getResources vs Module.getResourceAsStream

2018-07-14 Thread Alan Bateman
On 14/07/2018 16:38, Michał Zegan wrote: What is then a recommendation for searching for all resources with name x that i can access? Something like load all configuration including some kind of extensions. I cannot list resources easily. Services is the cleaner way to do this kind of thing, esp

Re: ClassLoader.getResources vs Module.getResourceAsStream

2018-07-14 Thread Michał Zegan
What is then a recommendation for searching for all resources with name x that i can access? Something like load all configuration including some kind of extensions. I cannot list resources easily. W dniu 14.07.2018 o 17:31, Alan Bateman pisze: > On 14/07/2018 14:00, Michał Zegan wrote: >> Hello.

Re: ClassLoader.getResources vs Module.getResourceAsStream

2018-07-14 Thread Alan Bateman
On 14/07/2018 14:00, Michał Zegan wrote: Hello. When reading docs for jdk9 and jdk10 it seems that those methods work in a bit different way when it goes to encapsulation: Module.getResourceAsStream will retrieve the resource without a problem if a package is opened to the caller module, probably

ClassLoader.getResources vs Module.getResourceAsStream

2018-07-14 Thread Michał Zegan
Hello. When reading docs for jdk9 and jdk10 it seems that those methods work in a bit different way when it goes to encapsulation: Module.getResourceAsStream will retrieve the resource without a problem if a package is opened to the caller module, probably including the fact that it will find a res