org.apache.sling.commons.osgi

## Class SortingServiceTracker<T>

- java.lang.Object
- - org.osgi.util.tracker.ServiceTracker<T,T>
  - - org.apache.sling.commons.osgi.SortingServiceTracker<T>

All Implemented Interfaces:
  org.osgi.util.tracker.ServiceTrackerCustomizer<T,T>

    public class SortingServiceTracker<T>
    extends org.osgi.util.tracker.ServiceTracker<T,T>

Implementation providing a sorted list of services by service ranking.

### Field Summary

### Fields inherited from class org.osgi.util.tracker.ServiceTracker

`context, filter`

### Constructor Summary

Constructors
Constructor and Description
`SortingServiceTracker(org.osgi.framework.BundleContext context, String clazz)` Constructor

### Method Summary

All Methods Instance Methods Concrete Methods
`T` `addingService(org.osgi.framework.ServiceReference<T> reference)`
`List<org.osgi.framework.ServiceReference<T>>` `getSortedServiceReferences()` Return a sorted list of the services references.
`List<T>` `getSortedServices()` Return a sorted list of the services.
`void` `modifiedService(org.osgi.framework.ServiceReference<T> reference, T service)`
`void` `removedService(org.osgi.framework.ServiceReference<T> reference, T service)`

### Methods inherited from class org.osgi.util.tracker.ServiceTracker

`close, getService, getService, getServiceReference, getServiceReferences, getServices, getServices, getTracked, getTrackingCount, isEmpty, open, open, remove, size, waitForService`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SortingServiceTracker

    public SortingServiceTracker(org.osgi.framework.BundleContext context,
                                 String clazz)

Constructor

Parameters:
  `context` - Bundle context
  `clazz` - Class

### Method Detail

#### removedService

    public void removedService(org.osgi.framework.ServiceReference<T> reference,
                               T service)

Specified by:
  `removedService` in interface `org.osgi.util.tracker.ServiceTrackerCustomizer<T,T>`
Overrides:
  `removedService` in class `org.osgi.util.tracker.ServiceTracker<T,T>`
See Also:
  `ServiceTracker.removedService(org.osgi.framework.ServiceReference, java.lang.Object)`

#### modifiedService

    public void modifiedService(org.osgi.framework.ServiceReference<T> reference,
                                T service)

Specified by:
  `modifiedService` in interface `org.osgi.util.tracker.ServiceTrackerCustomizer<T,T>`
Overrides:
  `modifiedService` in class `org.osgi.util.tracker.ServiceTracker<T,T>`
See Also:
  `ServiceTrackerCustomizer.modifiedService(org.osgi.framework.ServiceReference, java.lang.Object)`

#### addingService

    public T addingService(org.osgi.framework.ServiceReference<T> reference)

Specified by:
  `addingService` in interface `org.osgi.util.tracker.ServiceTrackerCustomizer<T,T>`
Overrides:
  `addingService` in class `org.osgi.util.tracker.ServiceTracker<T,T>`
See Also:
  `ServiceTrackerCustomizer.addingService(org.osgi.framework.ServiceReference)`

#### getSortedServices

    public List<T> getSortedServices()

Return a sorted list of the services.

Returns:
  Service list

#### getSortedServiceReferences

    public List<org.osgi.framework.ServiceReference<T>> getSortedServiceReferences()

Return a sorted list of the services references.

Returns:
  Service list