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