Class ServiceRankingComparator

  • All Implemented Interfaces:
    Serializable, Comparator<org.osgi.framework.ServiceReference<?>>

    public final class ServiceRankingComparator
    extends Object
    implements Comparator<org.osgi.framework.ServiceReference<?>>, Serializable
    Service Reference Comparator. This comparator follows OSGi Ranking policy.
    Author:
    hengsin
    See Also:
    Serialized Form
    • Method Detail

      • compare

        public int compare​(org.osgi.framework.ServiceReference<?> serviceReference1,
                           org.osgi.framework.ServiceReference<?> serviceReference2)
        Compares two service reference.
        Specified by:
        compare in interface Comparator<org.osgi.framework.ServiceReference<?>>
        Parameters:
        serviceReference1 - service reference 1
        serviceReference2 - service reference 2
        Returns:
        -1 if service reference 1 service.ranking value is higher than service reference 2, 1 otherwise. (i.e for sorting in descending order of service.ranking value)
        See Also:
        Comparator.compare(java.lang.Object, java.lang.Object)