- Collection<ServiceReference<ModuleFactory>> serviceReferences;
- try {
- serviceReferences = bundleContext.getServiceReferences(
- ModuleFactory.class, null);
- } catch (InvalidSyntaxException e) {
- throw new IllegalStateException(e);
- }
- Map<String, Map.Entry<ModuleFactory, BundleContext>> result = new HashMap<>(serviceReferences.size());
- for (ServiceReference<ModuleFactory> serviceReference : serviceReferences) {
- ModuleFactory factory = bundleContext.getService(serviceReference);
- // null if the service is not registered, the service object
- // returned by a ServiceFactory does not
- // implement the classes under which it was registered or the
- // ServiceFactory threw an exception.
- if(factory == null) {
- throw new NullPointerException("ServiceReference of class" + serviceReference.getClass() + "not found.");
- }
-
- String moduleName = factory.getImplementationName();
+ Map<String, Map.Entry<ModuleFactory, BundleContext>> result = new HashMap<>();
+ for(Entry<ModuleFactory, BundleContext> entry: moduleFactoryBundleTracker.getModuleFactoryEntries()) {
+ ModuleFactory factory = entry.getKey();
+ BundleContext bundleContext = entry.getValue();
+ String moduleName = factory .getImplementationName();