users@hk2.java.net

Why is the lowest service id = best service?

From: cowwoc <cowwoc_at_bbs.darktech.org>
Date: Fri, 29 Nov 2013 15:53:08 -0500

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