use of org.apache.aries.subsystem.core.internal.BundleResourceInstaller.BundleConstituent in project aries by apache.
the class Subsystems method getSubsystemsByBundle.
// TODO Not very pretty. A quick fix.
public Object[] getSubsystemsByBundle(Bundle bundle) {
BundleRevision revision = null;
ArrayList<BasicSubsystem> result = new ArrayList<BasicSubsystem>();
synchronized (subsystemToConstituents) {
for (BasicSubsystem subsystem : subsystemToConstituents.keySet()) {
for (Resource constituent : getConstituents(subsystem)) {
if (constituent instanceof BundleConstituent && ((BundleConstituent) constituent).getBundle() == bundle) {
result.add(subsystem);
revision = ((BundleConstituent) constituent).getRevision();
}
}
}
}
result.trimToSize();
if (revision == null)
return null;
return new Object[] { revision, result };
}
use of org.apache.aries.subsystem.core.internal.BundleResourceInstaller.BundleConstituent in project aries by apache.
the class BundleEventHook method handleExplicitlyInstalledBundleBundleContext.
/*
* This method guards against an uninstalled origin bundle. Guards against a
* null bundle revision are done elsewhere. It is assumed the bundle
* revision is never null once we get here.
*/
private void handleExplicitlyInstalledBundleBundleContext(BundleRevision originRevision, BundleRevision bundleRevision) {
/*
* The newly installed bundle must become a constituent of all the Subsystems of which the bundle
* whose context was used to perform the install is a constituent (OSGI.enterprise spec. 134.10.1.1).
*/
Collection<BasicSubsystem> subsystems = getSubsystems().getSubsystemsReferencing(originRevision);
boolean bundleRevisionInstalled = false;
for (BasicSubsystem s : subsystems) {
for (Resource constituent : s.getConstituents()) {
if (constituent instanceof BundleConstituent) {
BundleRevision rev = ((BundleConstituent) constituent).getRevision();
if (originRevision.equals(rev)) {
Utils.installResource(bundleRevision, s);
bundleRevisionInstalled = true;
}
}
}
}
/* if the bundle is not made constituent of any subsystem then make it constituent of root */
if (!bundleRevisionInstalled) {
Utils.installResource(bundleRevision, getSubsystems().getRootSubsystem());
}
}
Aggregations