Hi there,

since the question of service ordering has just popped up in the context of 
sling servlet filters, I had a look at the R4 and R5 specs and the 
corresponding errata. 

It looks as if the definition of service ranking has changed between R4 and R5 
and there seems to be a remainder of the old definition in R5 that was meant to 
clarify but looks like a contradiction to me.

I couldn't find any discussion of this in the mailing list archives and I hope 
that it is okay to bring this up.

In R4 I found a definition of service ranking order in the enterprise spec. It 
is used in the description of delegation to JNDI backends and it reads like it 
reverses the usual meaning of service.ranking by sorting on service.ranking in 
ascending order, querying implementation in ranking order and using the first 
supporting implementation:

Paragraph 126.3.2:

    "Several steps in these algorithm iterate over a set of available services. 
This iteration must always take place in service ranking order. Service ranking 
order is achieved by sorting on ascending service.ranking service property and 
then descending service.id property."

An erratum exists, explaining that the intention was to pick the last item from 
a list that is in service ranking order. Although it is not mentioned 
explicitly, I assume this also means that iteration of the list would progress 
from the end towards the beginning of the sorted list.

Paragraph 126.3.2.1:

   "* Get all the Initial Context Factory Builder services. For each such 
service, 
      in ranking order:
      * Ask the Initial Context Factory Builder service to create a new 
InitialContextFactory
        object. If this is null then continue with the next service.
      * Create the Context with
        the found Initial Context Factory and return it."

No erratum exists for this paragraph, but it seems the intention of the erratum 
above was to define the service ranking order as the reverse of the ordering 
described.

In R5 the definition of service ranking order is in paragraph 5.2.6 of the core 
spec (osgi.r5-core-5.0.0.pdf, Page 118) and it contains this passage:

    "The ranking order is defined as follows:

    • Sorted on descending ranking number (highest first)

    • If the ranking numbers are equal, sorted on ascending service.id property 
(oldest first).

    This ordering is complete because service ids are never reused and handed 
out in order of their registration time. That is, a service that is registered 
later will have a higher service id. Therefore, the ranking order is in 
ascending service.ranking numeric order where ties give a preference to the 
earlier registrant.

    The ranking order is the reverse of the natural ordering of a 
ServiceReference object."


Both "sorted on descending ranking number" and "ranking order is the reverse of 
the natural ordering" (which refers to the definition of the compareTo method 
on ServiceReference, right?) contradict "Therefore, the ranking order is in 
ascending service.ranking numeric order where ties give a preference to the 
earlier registrant."

Should this be changed in the Spec?

Harald Niesche
[email protected]


_______________________________________________
OSGi Developer Mail List
[email protected]
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to