Search in sources :

Example 11 with ModuleCapability

use of org.eclipse.osgi.container.ModuleCapability in project rt.equinox.framework by eclipse.

the class PackageAdminImpl method getExportedPackages.

public ExportedPackage[] getExportedPackages(Bundle bundle) {
    if (bundle == null) {
        return getExportedPackages((String) null);
    }
    Module module = StartLevelImpl.getModule(bundle);
    Collection<ModuleRevision> revisions = module == null ? Collections.<ModuleRevision>emptyList() : module.getRevisions().getModuleRevisions();
    Collection<ExportedPackage> allExports = new ArrayList<>();
    for (ModuleRevision revision : revisions) {
        ModuleWiring wiring = revision.getWiring();
        if (wiring != null) {
            List<ModuleCapability> providedPackages = wiring.getModuleCapabilities(PackageNamespace.PACKAGE_NAMESPACE);
            if (providedPackages != null) {
                for (ModuleCapability providedPackage : providedPackages) {
                    allExports.add(new ExportedPackageImpl(providedPackage, wiring));
                }
            }
        }
    }
    return allExports.isEmpty() ? null : allExports.toArray(new ExportedPackage[allExports.size()]);
}
Also used : ExportedPackage(org.osgi.service.packageadmin.ExportedPackage) ArrayList(java.util.ArrayList) ModuleWiring(org.eclipse.osgi.container.ModuleWiring) ModuleCapability(org.eclipse.osgi.container.ModuleCapability) Module(org.eclipse.osgi.container.Module) ModuleRevision(org.eclipse.osgi.container.ModuleRevision)

Aggregations

ModuleCapability (org.eclipse.osgi.container.ModuleCapability)11 Module (org.eclipse.osgi.container.Module)6 ModuleContainer (org.eclipse.osgi.container.ModuleContainer)4 ModuleRevision (org.eclipse.osgi.container.ModuleRevision)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 ModuleWire (org.eclipse.osgi.container.ModuleWire)3 ModuleWiring (org.eclipse.osgi.container.ModuleWiring)3 DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)3 File (java.io.File)2 HashMap (java.util.HashMap)2 Generation (org.eclipse.osgi.storage.BundleInfo.Generation)2 BundleCapability (org.osgi.framework.wiring.BundleCapability)2 Requirement (org.osgi.resource.Requirement)2 ExportedPackage (org.osgi.service.packageadmin.ExportedPackage)2 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 PrivilegedActionException (java.security.PrivilegedActionException)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1