// retrieve bundle infos
List<ExtendedBundleInfo> bundleInfos = new ArrayList<ExtendedBundleInfo>();
// get the StartLeval object
ServiceReference startLevelRef = bundleContext.getServiceReference(StartLevel.class.getCanonicalName());
StartLevel startLevelService = (StartLevel) bundleContext.getService(startLevelRef);
// get configured bundle Ids
Set<Long> configurationBundleIds = getConfigurationBundleIds();
Bundle[] bundles = bundleContext.getBundles();
for (Bundle bundle : bundles) {
if (searchString != "" && !matchBundle(bundle, searchString)){
continue;
}
// construct the result bundleInfos by listType
if ("wab".equals(listType)){
if (checkWABBundle(bundle)){
ExtendedBundleInfo info = createExtendedBundleInfo(bundle, startLevelService, configurationBundleIds);
info.addContextPath(getContextPath(bundle));
bundleInfos.add(info);
}
}else if ("blueprint".equals(listType)){
if (checkBlueprintBundle(bundle)){
ExtendedBundleInfo info = createExtendedBundleInfo(bundle, startLevelService, configurationBundleIds);
// currently, we try get the the blueprintContainer service to determine if a blueprint bundle is created
// TODO A better way is using a BlueprintListener to track all blueprint bundle events
String filter = "(&(osgi.blueprint.container.symbolicname=" + bundle.getSymbolicName()
+ ")(osgi.blueprint.container.version=" + bundle.getVersion() + "))";
ServiceReference[] serviceReferences = null;
try {
serviceReferences = bundleContext.getServiceReferences(BlueprintContainer.class.getName(), filter);
} catch (InvalidSyntaxException e) {
throw new RuntimeException(e);
}
if (serviceReferences != null && serviceReferences.length > 0){
info.setBlueprintState(BlueprintState.CREATED);
}
bundleInfos.add(info);
}
}else if ("system".equals(listType)){
if (checkSysBundle(bundle,startLevelService)){
ExtendedBundleInfo info = createExtendedBundleInfo(bundle, startLevelService, configurationBundleIds);
bundleInfos.add(info);
}
}else if ("configuration".equals(listType)){
if (checkConfigurationBundle(bundle,configurationBundleIds)){
ExtendedBundleInfo info = createExtendedBundleInfo(bundle, startLevelService, configurationBundleIds);
bundleInfos.add(info);
}
}else{
ExtendedBundleInfo info = createExtendedBundleInfo(bundle, startLevelService, configurationBundleIds);
bundleInfos.add(info);
}
}
Collections.sort(bundleInfos, new BundleIdDescComparator());
renderRequest.setAttribute("extendedBundleInfos", bundleInfos);
// set the values to render attribute
renderRequest.setAttribute("listTypeValue", listType);
renderRequest.setAttribute("searchStringValue", searchString);
renderRequest.setAttribute("initStartLevel", startLevelService.getInitialBundleStartLevel());
if (bundleInfos.size() == 0) {
addWarningMessage(renderRequest, getLocalizedString(renderRequest, "consolebase.bundlemanager.warn.nobundlesfound"));
}