use of org.eclipse.osgi.container.ModuleRevisionBuilder in project rt.equinox.framework by eclipse.
the class BundleLoader method addDynamicImportPackage.
/**
* Adds a list of DynamicImport-Package manifest elements to the dynamic
* import tables of this BundleLoader. Duplicate packages are checked and
* not added again.
* @param packages the DynamicImport-Package elements to add.
*/
public final void addDynamicImportPackage(ManifestElement[] packages) {
if (packages == null)
return;
List<String> dynamicImports = new ArrayList<>(packages.length);
StringBuilder importSpec = new StringBuilder();
for (ManifestElement dynamicImportElement : packages) {
String[] names = dynamicImportElement.getValueComponents();
for (String name : names) dynamicImports.add(name);
if (importSpec.length() > 0) {
importSpec.append(',');
}
importSpec.append(dynamicImportElement.toString());
}
if (dynamicImports.size() > 0) {
addDynamicImportPackage(dynamicImports.toArray(new String[dynamicImports.size()]));
Map<String, String> dynamicImportMap = new HashMap<>();
dynamicImportMap.put(Constants.DYNAMICIMPORT_PACKAGE, importSpec.toString());
try {
ModuleRevisionBuilder builder = OSGiManifestBuilderFactory.createBuilder(dynamicImportMap);
wiring.addDynamicImports(builder);
} catch (BundleException e) {
throw new RuntimeException(e);
}
}
}
Aggregations