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());
}
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);
}
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);
}
}
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;
}
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;
}
});
}
Aggregations