use of org.osgi.framework.wiring.BundleRevision in project aries by apache.
the class SubsystemResolverHook method filterResolvable.
public void filterResolvable(Collection<BundleRevision> candidates) {
try {
for (Iterator<BundleRevision> iterator = candidates.iterator(); iterator.hasNext(); ) {
BundleRevision revision = iterator.next();
if (revision.equals(ThreadLocalBundleRevision.get())) {
// The candidate is a bundle whose INSTALLED event is
// currently being processed on this thread.
iterator.remove();
continue;
}
if (revision.getSymbolicName().startsWith(Constants.RegionContextBundleSymbolicNamePrefix))
// Don't want to filter out the region context bundle.
continue;
Collection<BasicSubsystem> subsystems = this.subsystems.getSubsystemsReferencing(revision);
if (subsystems.isEmpty() && ThreadLocalSubsystem.get() != null) {
// This is the revision of a bundle being installed as part of a subsystem installation
// before it has been added as a reference or constituent.
iterator.remove();
continue;
}
for (BasicSubsystem subsystem : subsystems) {
if (subsystem.isFeature()) {
// Feature subsystems require no isolation.
continue;
}
// But only when in the INSTALLING state.
if (Subsystem.State.INSTALLING.equals(subsystem.getState())) {
iterator.remove();
}
}
}
} catch (RuntimeException e) {
// This try/catch block is in place because exceptions occurring here are not showing up in the console during testing.
LOGGER.debug("Unexpected exception while filtering resolution candidates: " + candidates, e);
}
}
use of org.osgi.framework.wiring.BundleRevision in project aries by apache.
the class ResolveContext method installDependenciesOfRequirerIfNecessary.
private void installDependenciesOfRequirerIfNecessary(Requirement requirement) {
if (requirement == null) {
return;
}
Resource requirer = requirement.getResource();
if (resource.equals(requirer)) {
return;
}
Collection<BasicSubsystem> subsystems;
if (requirer instanceof BasicSubsystem) {
BasicSubsystem subsystem = (BasicSubsystem) requirer;
subsystems = Collections.singletonList(subsystem);
} else if (requirer instanceof BundleRevision) {
BundleRevision revision = (BundleRevision) requirer;
BundleConstituent constituent = new BundleConstituent(null, revision);
subsystems = Activator.getInstance().getSubsystems().getSubsystemsByConstituent(constituent);
} else {
return;
}
for (BasicSubsystem subsystem : subsystems) {
if (Utils.isProvisionDependenciesInstall(subsystem) || !State.INSTALLING.equals(subsystem.getState())) {
continue;
}
AccessController.doPrivileged(new StartAction(subsystem, subsystem, subsystem, Restriction.INSTALL_ONLY));
}
}
use of org.osgi.framework.wiring.BundleRevision in project aries by apache.
the class ResolveContext method addWiring.
private void addWiring(Resource resource, Map<Resource, Wiring> wirings) {
if (resource instanceof BundleConstituent) {
BundleConstituent bc = (BundleConstituent) resource;
BundleWiring wiring = bc.getWiring();
if (wiring != null) {
wirings.put(bc.getBundle().adapt(BundleRevision.class), wiring);
}
} else if (resource instanceof BundleRevision) {
BundleRevision br = (BundleRevision) resource;
BundleWiring wiring = br.getWiring();
if (wiring != null) {
wirings.put(br, wiring);
}
}
}
use of org.osgi.framework.wiring.BundleRevision in project aries by apache.
the class ProviderBundleTrackerCustomizer method getHeaderFromBundleOrFragment.
private String getHeaderFromBundleOrFragment(Bundle bundle, String headerName, String matchString) {
String val = bundle.getHeaders().get(headerName);
if (matches(val, matchString))
return val;
BundleRevision rev = bundle.adapt(BundleRevision.class);
if (rev != null) {
BundleWiring wiring = rev.getWiring();
if (wiring != null) {
for (BundleWire wire : wiring.getProvidedWires("osgi.wiring.host")) {
Bundle fragment = wire.getRequirement().getRevision().getBundle();
val = fragment.getHeaders().get(headerName);
if (matches(val, matchString)) {
return val;
}
}
}
}
return null;
}
use of org.osgi.framework.wiring.BundleRevision in project aries by apache.
the class BaseActivator method getAllHeaders.
private List<String> getAllHeaders(String headerName, Bundle bundle) {
List<Bundle> bundlesFragments = new ArrayList<Bundle>();
bundlesFragments.add(bundle);
BundleRevision rev = bundle.adapt(BundleRevision.class);
if (rev != null) {
BundleWiring wiring = rev.getWiring();
if (wiring != null) {
for (BundleWire wire : wiring.getProvidedWires("osgi.wiring.host")) {
bundlesFragments.add(wire.getRequirement().getRevision().getBundle());
}
}
}
List<String> l = new ArrayList<String>();
for (Bundle bf : bundlesFragments) {
String header = bf.getHeaders().get(headerName);
if (header != null) {
l.add(header);
}
}
return l;
}
Aggregations