Alan, 

Your suggestion is literally the same thing that Peter suggested which is what 
my reply below was to. So you can take that reply as the reply to your message 
as well.

What would be preferable is to have the serviceLoader accept “criteria” (which 
are callbacks) that can evaluate each of the located services based on any 
additional properties that are included in the properties file and either 
eliminate them or return a “ranking".  The serviceLoader would then end up with 
a set of eligible services in their preferred order.

Ralph

> On Sep 30, 2015, at 7:14 AM, Alan Bateman <alan.bate...@oracle.com> wrote:
> 
> On 30/09/2015 14:59, Ralph Goers wrote:
>> If I understand you correctly, then no that isn’t what I would want. The 
>> version and priority are captured in the same properties file where the 
>> class name is specified. If the class implements the wrong version or isn’t 
>> chosen due to its priority then the class isn’t loaded. To do what you are 
>> describing would require that serviceLoader load each class and that methods 
>> be called on each class to get that information. While that makes life 
>> simpler for the serviceLoader it makes it more complicated for the services 
>> being loaded.
>> 
> It should be possible to create a service type that allows you to select the 
> appropriate service provider implementation. The service type can also work 
> as a factory so that once you select the service provider then you invoke 
> some method on it to get the actual logging provider.
> 
> -Alan.
> 


Reply via email to