The idea behind the lowest service id is that it is the oldest service
added to the registry. That way other code is less likely to suddenly
get a different implementation when a new one is added (especially if
they are using proxies).
If you want different behavior there are other avenues, such as using
ranking.
In the end we had to make a decision on what to do with that, and we
went with the somewhat conservative rule of "older is better". It
wouldn't be a terrible idea to add a service that broke ties, but we
don't have such a service at this time...
On 11/29/2013 3:53 PM, cowwoc wrote:
> Hi,
>
> https://hk2.java.net/2.2.0-b24/api-overview.html reads:
>
> The best instance of a service is a service with the highest ranking
> or the lowest service id. The ranking of a service is found in its
> Descriptor and can be changed at any time at run time. The service id
> of a service is a system assigned value for the Descriptor when it is
> bound into the ServiceLocator. The system assigned value is a
> monotonically increasing value. Thus if two services have the same
> ranking the best service will be associated with the oldest Descriptor
> bound into the system.
>
> Out of curiosity, why is that? If you used the highest service is as
> "best" then we could easily "override" a service binding by simply
> injecting a new one. What does binding to the lowest id get us?
>
> Thanks,
> Gili