Search in sources :

Example 11 with ModuleRevisionBuilder

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);
        }
    }
}
Also used : ManifestElement(org.eclipse.osgi.util.ManifestElement) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ModuleRevisionBuilder(org.eclipse.osgi.container.ModuleRevisionBuilder) BundleException(org.osgi.framework.BundleException)

Aggregations

ModuleRevisionBuilder (org.eclipse.osgi.container.ModuleRevisionBuilder)11 Module (org.eclipse.osgi.container.Module)7 BundleException (org.osgi.framework.BundleException)6 ByteArrayInputStream (java.io.ByteArrayInputStream)3 DataInputStream (java.io.DataInputStream)3 File (java.io.File)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 ModuleContainer (org.eclipse.osgi.container.ModuleContainer)3 Generation (org.eclipse.osgi.storage.BundleInfo.Generation)3 BundleFile (org.eclipse.osgi.storage.bundlefile.BundleFile)3 DirBundleFile (org.eclipse.osgi.storage.bundlefile.DirBundleFile)3 NestedDirBundleFile (org.eclipse.osgi.storage.bundlefile.NestedDirBundleFile)3 ZipBundleFile (org.eclipse.osgi.storage.bundlefile.ZipBundleFile)3 DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)3 BufferedInputStream (java.io.BufferedInputStream)2 FileInputStream (java.io.FileInputStream)2 InputStream (java.io.InputStream)2 URL (java.net.URL)2