Search in sources :

Example 26 with ModuleWiring

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

the class TestModuleContainer method testModuleWiringToString.

@Test
public void testModuleWiringToString() throws BundleException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    // install a test module
    Map<String, String> testManifest = new HashMap<String, String>();
    testManifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    testManifest.put(Constants.BUNDLE_SYMBOLICNAME, "test.name");
    testManifest.put(Constants.BUNDLE_VERSION, "1.0");
    Module testModule = installDummyModule(testManifest, "host10", container);
    ResolutionReport report = container.resolve(Arrays.asList(testModule), true);
    Assert.assertNull("Failed to resolve test.", report.getResolutionException());
    ModuleRevision revision = testModule.getCurrentRevision();
    ModuleWiring wiring = revision.getWiring();
    Assert.assertEquals("Unexpected wiring.toString()", revision.toString(), wiring.toString());
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) HashMap(java.util.HashMap) ModuleWiring(org.eclipse.osgi.container.ModuleWiring) Module(org.eclipse.osgi.container.Module) ResolutionReport(org.eclipse.osgi.report.resolution.ResolutionReport) ModuleRevision(org.eclipse.osgi.container.ModuleRevision) Test(org.junit.Test)

Example 27 with ModuleWiring

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

the class TestModuleContainer method testSimpleResolve.

@Test
public void testSimpleResolve() throws BundleException, IOException {
    DummyContainerAdaptor adaptor = createDummyAdaptor();
    ModuleContainer container = adaptor.getContainer();
    Module systemBundle = installDummyModule("system.bundle.MF", Constants.SYSTEM_BUNDLE_LOCATION, container);
    ModuleRevision systemRevision = systemBundle.getCurrentRevision();
    container.resolve(Arrays.asList(systemBundle), true);
    ModuleWiring systemWiring = systemRevision.getWiring();
    Assert.assertNotNull("system wiring is null", systemWiring);
    Module b1 = installDummyModule("b1_v1.MF", "b1", container);
    ModuleRevision b1Revision = b1.getCurrentRevision();
    container.resolve(Arrays.asList(b1), true);
    ModuleWiring b1Wiring = b1Revision.getWiring();
    Assert.assertNotNull("b1 wiring is null", b1Wiring);
}
Also used : DummyContainerAdaptor(org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor) ModuleContainer(org.eclipse.osgi.container.ModuleContainer) ModuleWiring(org.eclipse.osgi.container.ModuleWiring) Module(org.eclipse.osgi.container.Module) ModuleRevision(org.eclipse.osgi.container.ModuleRevision) Test(org.junit.Test)

Example 28 with ModuleWiring

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

the class Storage method installExtensions.

private void installExtensions() {
    Module systemModule = moduleContainer.getModule(0);
    ModuleRevision systemRevision = systemModule == null ? null : systemModule.getCurrentRevision();
    ModuleWiring systemWiring = systemRevision == null ? null : systemRevision.getWiring();
    if (systemWiring == null) {
        return;
    }
    Collection<ModuleRevision> fragments = new ArrayList<>();
    for (ModuleWire hostWire : systemWiring.getProvidedModuleWires(HostNamespace.HOST_NAMESPACE)) {
        fragments.add(hostWire.getRequirer());
    }
    try {
        getExtensionInstaller().addExtensionContent(fragments, null);
    } catch (BundleException e) {
        getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, e.getMessage(), e);
    }
}
Also used : ModuleWire(org.eclipse.osgi.container.ModuleWire) ModuleWiring(org.eclipse.osgi.container.ModuleWiring) ArrayList(java.util.ArrayList) BundleException(org.osgi.framework.BundleException) Module(org.eclipse.osgi.container.Module) ModuleRevision(org.eclipse.osgi.container.ModuleRevision)

Example 29 with ModuleWiring

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

the class Handler method findBundleEntry.

protected BundleEntry findBundleEntry(URL url, Module module) throws IOException {
    ModuleRevision current = module.getCurrentRevision();
    ModuleWiring wiring = current == null ? null : current.getWiring();
    ModuleClassLoader classloader = (ModuleClassLoader) (current == null ? null : wiring.getClassLoader());
    if (classloader == null)
        throw new FileNotFoundException(url.getPath());
    BundleEntry entry = classloader.getClasspathManager().findLocalEntry(url.getPath(), url.getPort());
    if (entry == null) {
        // this isn't strictly needed but is kept to maintain compatibility
        entry = classloader.getClasspathManager().findLocalEntry(url.getPath());
    }
    if (entry == null) {
        throw new FileNotFoundException(url.getPath());
    }
    return entry;
}
Also used : ModuleClassLoader(org.eclipse.osgi.internal.loader.ModuleClassLoader) ModuleWiring(org.eclipse.osgi.container.ModuleWiring) FileNotFoundException(java.io.FileNotFoundException) ModuleRevision(org.eclipse.osgi.container.ModuleRevision) BundleEntry(org.eclipse.osgi.storage.bundlefile.BundleEntry)

Example 30 with ModuleWiring

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

the class EquinoxBundle method getModuleClassLoader.

private ModuleClassLoader getModuleClassLoader(boolean logResolveError) {
    ResolutionReport report = resolve();
    if (logResolveError && !Module.RESOLVED_SET.contains(module.getState())) {
        String reportMessage = report.getResolutionReportMessage(module.getCurrentRevision());
        equinoxContainer.getEventPublisher().publishFrameworkEvent(FrameworkEvent.ERROR, this, new BundleException(reportMessage, BundleException.RESOLVE_ERROR));
    }
    return AccessController.doPrivileged(new PrivilegedAction<ModuleClassLoader>() {

        @Override
        public ModuleClassLoader run() {
            ModuleWiring wiring = getModule().getCurrentRevision().getWiring();
            if (wiring != null) {
                ModuleLoader moduleLoader = wiring.getModuleLoader();
                if (moduleLoader instanceof BundleLoader) {
                    return ((BundleLoader) moduleLoader).getModuleClassLoader();
                }
            }
            return null;
        }
    });
}
Also used : ModuleLoader(org.eclipse.osgi.container.ModuleLoader) ModuleClassLoader(org.eclipse.osgi.internal.loader.ModuleClassLoader) ModuleWiring(org.eclipse.osgi.container.ModuleWiring) BundleException(org.osgi.framework.BundleException) ResolutionReport(org.eclipse.osgi.report.resolution.ResolutionReport) 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