Search in sources :

Example 6 with BundleConstituent

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 };
}
Also used : BundleConstituent(org.apache.aries.subsystem.core.internal.BundleResourceInstaller.BundleConstituent) BundleRevision(org.osgi.framework.wiring.BundleRevision) ArrayList(java.util.ArrayList) Resource(org.osgi.resource.Resource)

Example 7 with BundleConstituent

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());
    }
}
Also used : BundleConstituent(org.apache.aries.subsystem.core.internal.BundleResourceInstaller.BundleConstituent) Resource(org.osgi.resource.Resource) BundleRevision(org.osgi.framework.wiring.BundleRevision)

Aggregations

BundleConstituent (org.apache.aries.subsystem.core.internal.BundleResourceInstaller.BundleConstituent)7 BundleRevision (org.osgi.framework.wiring.BundleRevision)7 Resource (org.osgi.resource.Resource)3 Bundle (org.osgi.framework.Bundle)2 BundleWiring (org.osgi.framework.wiring.BundleWiring)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 DynamicImportPackageHeader (org.apache.aries.subsystem.core.archive.DynamicImportPackageHeader)1 DynamicImportPackageRequirement (org.apache.aries.subsystem.core.archive.DynamicImportPackageRequirement)1 Region (org.eclipse.equinox.region.Region)1 FilteredRegion (org.eclipse.equinox.region.RegionDigraph.FilteredRegion)1 BundleCapability (org.osgi.framework.wiring.BundleCapability)1 FrameworkWiring (org.osgi.framework.wiring.FrameworkWiring)1 SubsystemException (org.osgi.service.subsystem.SubsystemException)1