Search in sources :

Example 31 with ModuleWiring

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

the class FrameworkExtensionInstaller method startExtensionActivators.

public void startExtensionActivators(BundleContext context) {
    // First start the hook registry activators
    // TODO not sure we really need these anymore
    HookRegistry hookRegistry = configuration.getHookRegistry();
    List<ActivatorHookFactory> activatorHookFactories = hookRegistry.getActivatorHookFactories();
    for (ActivatorHookFactory activatorFactory : activatorHookFactories) {
        BundleActivator activator = activatorFactory.createActivator();
        try {
            startActivator(activator, context, null);
        } catch (Exception e) {
            configuration.getHookRegistry().getContainer().getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, null, e);
        }
    }
    // start the extension bundle activators.  In Equinox we let
    // framework extensions define Bundle-Activator headers.
    ModuleWiring systemWiring = (ModuleWiring) context.getBundle().adapt(BundleWiring.class);
    if (systemWiring != null) {
        List<ModuleWire> extensionWires = systemWiring.getProvidedModuleWires(HostNamespace.HOST_NAMESPACE);
        for (ModuleWire extensionWire : extensionWires) {
            ModuleRevision extensionRevision = extensionWire.getRequirer();
            startExtensionActivator(extensionRevision, context);
        }
    }
}
Also used : ModuleWire(org.eclipse.osgi.container.ModuleWire) ActivatorHookFactory(org.eclipse.osgi.internal.hookregistry.ActivatorHookFactory) BundleActivator(org.osgi.framework.BundleActivator) BundleWiring(org.osgi.framework.wiring.BundleWiring) ModuleWiring(org.eclipse.osgi.container.ModuleWiring) HookRegistry(org.eclipse.osgi.internal.hookregistry.HookRegistry) ModuleRevision(org.eclipse.osgi.container.ModuleRevision) BundleException(org.osgi.framework.BundleException) PrivilegedActionException(java.security.PrivilegedActionException) MalformedURLException(java.net.MalformedURLException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 32 with ModuleWiring

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

the class ManifestLocalization method findResource.

private URL findResource(String resource) {
    ModuleWiring searchWiring = generation.getRevision().getWiring();
    if (searchWiring != null) {
        if ((generation.getRevision().getTypes() & BundleRevision.TYPE_FRAGMENT) != 0) {
            List<ModuleWire> hostWires = searchWiring.getRequiredModuleWires(HostNamespace.HOST_NAMESPACE);
            searchWiring = null;
            Long lowestHost = Long.MAX_VALUE;
            if (hostWires != null) {
                // search for the host with the highest ID
                for (ModuleWire hostWire : hostWires) {
                    Long hostID = hostWire.getProvider().getRevisions().getModule().getId();
                    if (hostID.compareTo(lowestHost) <= 0) {
                        lowestHost = hostID;
                        searchWiring = hostWire.getProviderWiring();
                    }
                }
            }
        }
    }
    if (searchWiring != null) {
        int lastSlash = resource.lastIndexOf('/');
        // $NON-NLS-1$
        String path = lastSlash > 0 ? resource.substring(0, lastSlash) : "/";
        String fileName = lastSlash != -1 ? resource.substring(lastSlash + 1) : resource;
        List<URL> result = searchWiring.findEntries(path, fileName, 0);
        return (result == null || result.isEmpty()) ? null : result.get(0);
    }
    // search the raw bundle file for the generation
    return generation.getEntry(resource);
}
Also used : ModuleWire(org.eclipse.osgi.container.ModuleWire) ModuleWiring(org.eclipse.osgi.container.ModuleWiring) URL(java.net.URL)

Example 33 with ModuleWiring

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

the class EquinoxBundle method getGenerations.

List<Generation> getGenerations() {
    List<Generation> result = new ArrayList<>();
    ModuleRevision current = getModule().getCurrentRevision();
    result.add((Generation) current.getRevisionInfo());
    ModuleWiring wiring = current.getWiring();
    if (wiring != null) {
        List<ModuleWire> hostWires = wiring.getProvidedModuleWires(HostNamespace.HOST_NAMESPACE);
        if (hostWires != null) {
            for (ModuleWire hostWire : hostWires) {
                result.add((Generation) hostWire.getRequirer().getRevisionInfo());
            }
        }
    }
    return result;
}
Also used : Generation(org.eclipse.osgi.storage.BundleInfo.Generation) ModuleWire(org.eclipse.osgi.container.ModuleWire) ArrayList(java.util.ArrayList) ModuleWiring(org.eclipse.osgi.container.ModuleWiring) ModuleRevision(org.eclipse.osgi.container.ModuleRevision)

Example 34 with ModuleWiring

use of org.eclipse.osgi.container.ModuleWiring 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)

Example 35 with ModuleWiring

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

the class RegisteredPolicy method loadResources.

public Enumeration<URL> loadResources(String name) {
    if (allDependents == null)
        return null;
    Enumeration<URL> results = null;
    int size = allDependents.size();
    for (int i = 0; i < size; i++) {
        try {
            ModuleWiring searchWiring = allDependents.get(i);
            BundleLoader searchLoader = (BundleLoader) searchWiring.getModuleLoader();
            if (searchLoader != null) {
                results = BundleLoader.compoundEnumerations(results, searchLoader.findResources(name));
            }
        } catch (IOException e) {
        // Ignore and keep looking
        }
    }
    return results;
}
Also used : ModuleWiring(org.eclipse.osgi.container.ModuleWiring) IOException(java.io.IOException) URL(java.net.URL) BundleLoader(org.eclipse.osgi.internal.loader.BundleLoader)

Aggregations

ModuleWiring (org.eclipse.osgi.container.ModuleWiring)39 Module (org.eclipse.osgi.container.Module)22 ModuleWire (org.eclipse.osgi.container.ModuleWire)21 ModuleContainer (org.eclipse.osgi.container.ModuleContainer)20 DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)20 Test (org.junit.Test)20 ModuleRevision (org.eclipse.osgi.container.ModuleRevision)12 BundleLoader (org.eclipse.osgi.internal.loader.BundleLoader)8 ArrayList (java.util.ArrayList)7 ResolutionReport (org.eclipse.osgi.report.resolution.ResolutionReport)6 URL (java.net.URL)5 BundleCapability (org.osgi.framework.wiring.BundleCapability)4 HashMap (java.util.HashMap)3 ModuleCapability (org.eclipse.osgi.container.ModuleCapability)3 DummyModuleDatabase (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase)3 Bundle (org.osgi.framework.Bundle)3 BundleException (org.osgi.framework.BundleException)3 IOException (java.io.IOException)2 ModuleClassLoader (org.eclipse.osgi.internal.loader.ModuleClassLoader)2 BundleRequirement (org.osgi.framework.wiring.BundleRequirement)2