private void collectBundleInfos(File baseDir, ApplicationMetadataFactory applicationMetadataFactory, Set<BundleInfo> bundleInfos) throws IOException, ManagementException {
for (File file : baseDir.listFiles()) {
if (file.isDirectory()) {
if (file.getName().endsWith(".jar")) {
BundleManifest bm = fromBundle(file);
if (bm != null && bm.isValid()) {
bundleInfos.add(new SimpleBundleInfo(applicationMetadataFactory, bm, "reference:" + file.toURI().toString()));
}
} else {
collectBundleInfos(file, applicationMetadataFactory, bundleInfos);
continue;
}
} else {
BundleManifest bm = fromBundle(file);
if (bm != null && bm.isValid()) {
/*
* Pass file:// url instead of reference:file:// as bundle location to make sure
* Equinox has its own copy of the jar. That is, to prevent strange ZipErrors when
* application bundles are updated at runtime, specifically, when
* ApplicationGBean.hotSwapApplicationContent() is called.