Search in sources :

Example 41 with ModuleWire

use of org.eclipse.osgi.container.ModuleWire 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 42 with ModuleWire

use of org.eclipse.osgi.container.ModuleWire 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 43 with ModuleWire

use of org.eclipse.osgi.container.ModuleWire 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 44 with ModuleWire

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

the class BundleLoader method clearManifestLocalizationCache.

protected void clearManifestLocalizationCache() {
    Generation hostGen = (Generation) wiring.getRevision().getRevisionInfo();
    hostGen.clearManifestCache();
    List<ModuleWire> hostWires = wiring.getProvidedModuleWires(HostNamespace.HOST_NAMESPACE);
    // doing a null check because there is no lock on the module database here
    if (hostWires != null) {
        for (ModuleWire fragmentWire : hostWires) {
            Generation fragGen = (Generation) fragmentWire.getRequirer().getRevisionInfo();
            fragGen.clearManifestCache();
        }
    }
}
Also used : Generation(org.eclipse.osgi.storage.BundleInfo.Generation) ModuleWire(org.eclipse.osgi.container.ModuleWire)

Example 45 with ModuleWire

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

the class ClasspathManager method buildFragmentClasspaths.

private FragmentClasspath[] buildFragmentClasspaths(ModuleClassLoader hostloader, ClasspathManager manager) {
    if (hostloader == null) {
        return emptyFragments;
    }
    List<ModuleWire> fragmentWires = hostloader.getBundleLoader().getWiring().getProvidedModuleWires(HostNamespace.HOST_NAMESPACE);
    if (fragmentWires == null || fragmentWires.isEmpty()) {
        // we don't hold locks while checking the graph, just return if no longer valid
        return emptyFragments;
    }
    List<FragmentClasspath> result = new ArrayList<>(fragmentWires.size());
    for (ModuleWire fragmentWire : fragmentWires) {
        ModuleRevision revision = fragmentWire.getRequirer();
        Generation fragGeneration = (Generation) revision.getRevisionInfo();
        String[] cp = getClassPath(revision);
        ClasspathEntry[] fragEntries = buildClasspath(cp, manager, fragGeneration);
        FragmentClasspath fragClasspath = new FragmentClasspath(fragGeneration, fragEntries);
        insertFragment(fragClasspath, result);
    }
    return result.toArray(new FragmentClasspath[result.size()]);
}
Also used : Generation(org.eclipse.osgi.storage.BundleInfo.Generation) ModuleWire(org.eclipse.osgi.container.ModuleWire) ArrayList(java.util.ArrayList) ModuleRevision(org.eclipse.osgi.container.ModuleRevision)

Aggregations

ModuleWire (org.eclipse.osgi.container.ModuleWire)45 Module (org.eclipse.osgi.container.Module)32 ModuleContainer (org.eclipse.osgi.container.ModuleContainer)31 Test (org.junit.Test)31 DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)25 ModuleWiring (org.eclipse.osgi.container.ModuleWiring)21 ResolutionReport (org.eclipse.osgi.report.resolution.ResolutionReport)13 HashMap (java.util.HashMap)11 ArrayList (java.util.ArrayList)9 ModuleRevision (org.eclipse.osgi.container.ModuleRevision)9 NullPackageSource (org.eclipse.osgi.internal.loader.sources.NullPackageSource)5 PackageSource (org.eclipse.osgi.internal.loader.sources.PackageSource)5 HashSet (java.util.HashSet)4 BundleRequirement (org.osgi.framework.wiring.BundleRequirement)4 ModuleCapability (org.eclipse.osgi.container.ModuleCapability)3 Generation (org.eclipse.osgi.storage.BundleInfo.Generation)3 DummyModuleDatabase (org.eclipse.osgi.tests.container.dummys.DummyModuleDatabase)3 BundleCapability (org.osgi.framework.wiring.BundleCapability)3 Bundle (org.osgi.framework.Bundle)2 BundleException (org.osgi.framework.BundleException)2