// generate and register new services
Bundle targetBundle = findBundleForPlugin(bundleContext, pluginKey);
List<ModuleDescriptor> generatedDescriptors = new ArrayList<ModuleDescriptor>();
List<ServiceRegistration> serviceRegistrations = newArrayList();
ConditionGenerator conditionGenerator = data.isGlobalExtension(pluginKey) ? new GroupsConditionGenerator(settingsManager.getSettings().getAccessGroups()) :
new UsersConditionGenerator(data.getUsersList(pluginKey));
for (ModuleDescriptor generatedDescriptor : descriptorGenerator.getDescriptorsToExposeForUsers(conditionGenerator, targetBundle.getLastModified()))
{
ServiceRegistration reg = targetBundle.getBundleContext().registerService(ModuleDescriptor.class.getName(), generatedDescriptor, null);
serviceRegistrations.add(reg);
generatedDescriptors.add(generatedDescriptor);