Search in sources :

Example 1 with ServiceComparator

use of ddf.catalog.util.impl.ServiceComparator in project ddf by codice.

the class MigrateCommand method getCatalogProviders.

private List<CatalogProvider> getCatalogProviders() {
    ServiceTracker st = new ServiceTracker(bundleContext, CatalogProvider.class.getName(), null);
    st.open();
    ServiceReference<CatalogProvider>[] serviceRefs = st.getServiceReferences();
    Map<ServiceReference<CatalogProvider>, CatalogProvider> map = new TreeMap<>(new ServiceComparator());
    if (null != serviceRefs) {
        for (ServiceReference<CatalogProvider> serviceReference : serviceRefs) {
            map.put(serviceReference, (CatalogProvider) st.getService(serviceReference));
        }
    }
    return new ArrayList<>(map.values());
}
Also used : ServiceTracker(org.osgi.util.tracker.ServiceTracker) CatalogProvider(ddf.catalog.source.CatalogProvider) ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) ServiceReference(org.osgi.framework.ServiceReference) ServiceComparator(ddf.catalog.util.impl.ServiceComparator)

Aggregations

CatalogProvider (ddf.catalog.source.CatalogProvider)1 ServiceComparator (ddf.catalog.util.impl.ServiceComparator)1 ArrayList (java.util.ArrayList)1 TreeMap (java.util.TreeMap)1 ServiceReference (org.osgi.framework.ServiceReference)1 ServiceTracker (org.osgi.util.tracker.ServiceTracker)1