Re: Cross module single ServiceProvider for JPMS services

2020-04-19 Thread Alan Bateman
On 19/04/2020 16:05, Uwe Schindler wrote: Hi Alan, from what I understood: He has some utility method in a shared class that wraps ServiceLoader to discover services and do something with it (the usual way to prevent code duplication). Problem is that ServiceLoade.load() is caller-sensitive,

RE: Cross module single ServiceProvider for JPMS services

2020-04-19 Thread Uwe Schindler
, Germany https://lucene.apache.org/ > -Original Message- > From: jigsaw-dev On Behalf Of Alan > Bateman > Sent: Sunday, April 19, 2020 4:23 PM > To: Alex Sviridov ; jigsaw-dev d...@openjdk.java.net> > Subject: Re: Cross module single ServiceProvider for JPMS services >

Re: Cross module single ServiceProvider for JPMS services

2020-04-19 Thread Alan Bateman
On 19/04/2020 15:00, Alex Sviridov wrote: Hi all, Let's suppose we have modules (A, B, C..) and every module consumes and provides services. To find these services I want to create one util class, for example ServiceProvider that will be used by all modules to get necessary services. There

Re: Cross module single ServiceProvider for JPMS services

2020-04-19 Thread Uwe Schindler
Hi, The problem you see is that ServiceLoader.load() is caller-sensitive, so it has to be called from the exact module that will use the service. You can still have some utility method that works on an already instantiated service loader: 1. The utility class/method just takes a ServiceLoader