Class SortingServiceTracker<T>
- java.lang.Object
-
- org.osgi.util.tracker.ServiceTracker<T,T>
-
- org.apache.sling.commons.osgi.SortingServiceTracker<T>
-
- All Implemented Interfaces:
ServiceTrackerCustomizer<T,T>
public class SortingServiceTracker<T> extends ServiceTracker<T,T>
Implementation providing a sorted list of services by service ranking.
-
-
Constructor Summary
Constructors Constructor Description SortingServiceTracker(BundleContext context, java.lang.String clazz)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TaddingService(ServiceReference<T> reference)Default implementation of theServiceTrackerCustomizer.addingServicemethod.java.util.List<ServiceReference<T>>getSortedServiceReferences()Return a sorted list of the services references.java.util.List<T>getSortedServices()Return a sorted list of the services.voidmodifiedService(ServiceReference<T> reference, T service)Default implementation of theServiceTrackerCustomizer.modifiedServicemethod.voidremovedService(ServiceReference<T> reference, T service)Default implementation of theServiceTrackerCustomizer.removedServicemethod.-
Methods inherited from class org.osgi.util.tracker.ServiceTracker
close, getService, getService, getServiceReference, getServiceReferences, getServices, getServices, getTracked, getTrackingCount, isEmpty, open, open, remove, size, waitForService
-
-
-
-
Constructor Detail
-
SortingServiceTracker
public SortingServiceTracker(BundleContext context, java.lang.String clazz)
Constructor- Parameters:
context- Bundle contextclazz- Class
-
-
Method Detail
-
removedService
public void removedService(ServiceReference<T> reference, T service)
Description copied from class:ServiceTrackerDefault implementation of theServiceTrackerCustomizer.removedServicemethod.This method is only called when this
ServiceTrackerhas been constructed with anull ServiceTrackerCustomizerargument.This implementation calls
ungetService, on theBundleContextwith which thisServiceTrackerwas created, passing the specifiedServiceReference.This method can be overridden in a subclass. If the default implementation of
addingServicemethod was used, this method must unget the service.- Specified by:
removedServicein interfaceServiceTrackerCustomizer<T,T>- Overrides:
removedServicein classServiceTracker<T,T>- Parameters:
reference- The reference to removed service.service- The service object for the removed service.- See Also:
ServiceTracker.removedService(org.osgi.framework.ServiceReference, java.lang.Object)
-
modifiedService
public void modifiedService(ServiceReference<T> reference, T service)
Description copied from class:ServiceTrackerDefault implementation of theServiceTrackerCustomizer.modifiedServicemethod.This method is only called when this
ServiceTrackerhas been constructed with anull ServiceTrackerCustomizerargument.This implementation does nothing.
- Specified by:
modifiedServicein interfaceServiceTrackerCustomizer<T,T>- Overrides:
modifiedServicein classServiceTracker<T,T>- Parameters:
reference- The reference to modified service.service- The service object for the modified service.- See Also:
ServiceTrackerCustomizer.modifiedService(org.osgi.framework.ServiceReference, java.lang.Object)
-
addingService
public T addingService(ServiceReference<T> reference)
Description copied from class:ServiceTrackerDefault implementation of theServiceTrackerCustomizer.addingServicemethod.This method is only called when this
ServiceTrackerhas been constructed with anull ServiceTrackerCustomizerargument.This implementation returns the result of calling
getService, on theBundleContextwith which thisServiceTrackerwas created, passing the specifiedServiceReference.This method can be overridden in a subclass to customize the service object to be tracked for the service being added. In that case, take care not to rely on the default implementation of
removedServiceto unget the service.- Specified by:
addingServicein interfaceServiceTrackerCustomizer<T,T>- Overrides:
addingServicein classServiceTracker<T,T>- Parameters:
reference- The reference to the service being added to thisServiceTracker.- Returns:
- The service object to be tracked for the service added to this
ServiceTracker. - See Also:
ServiceTrackerCustomizer.addingService(org.osgi.framework.ServiceReference)
-
getSortedServices
public java.util.List<T> getSortedServices()
Return a sorted list of the services.- Returns:
- Service list
-
getSortedServiceReferences
public java.util.List<ServiceReference<T>> getSortedServiceReferences()
Return a sorted list of the services references.- Returns:
- Service list
-
-