Search in sources :

Example 1 with AriesProvisionDependenciesDirective

use of org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective in project aries by apache.

the class SubsystemManifestValidator method validateAriesProvisionDependenciesDirective.

private static void validateAriesProvisionDependenciesDirective(BasicSubsystem subsystem) {
    AriesProvisionDependenciesDirective directive = subsystem.getAriesProvisionDependenciesDirective();
    BasicSubsystem parent = subsystem.getResource().getParents().iterator().next();
    AriesProvisionDependenciesDirective parentDirective = parent.getAriesProvisionDependenciesDirective();
    if (!directive.equals(parentDirective) && (subsystem.isFeature() || State.INSTALLING.equals(parent.getState()))) {
        throw new SubsystemException("The value of the " + AriesProvisionDependenciesDirective.NAME + " directive must be the same as the parent subsystem for features and implicitly installed subsystems.");
    }
}
Also used : SubsystemException(org.osgi.service.subsystem.SubsystemException) AriesProvisionDependenciesDirective(org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective)

Example 2 with AriesProvisionDependenciesDirective

use of org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective in project aries by apache.

the class Aries1383Test method test13.

/*
	 * (13) The root subsystem has apache-aries-provision-dependencies:=install.
	 */
@Test
public void test13() throws Exception {
    Subsystem root = getRootSubsystem();
    Map<String, String> headers = root.getSubsystemHeaders(null);
    String headerStr = headers.get(SubsystemConstants.SUBSYSTEM_TYPE);
    SubsystemTypeHeader header = new SubsystemTypeHeader(headerStr);
    AriesProvisionDependenciesDirective directive = header.getAriesProvisionDependenciesDirective();
    assertEquals("Wrong directive", AriesProvisionDependenciesDirective.INSTALL, directive);
}
Also used : AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) AriesProvisionDependenciesDirective(org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective) SubsystemTypeHeader(org.apache.aries.subsystem.core.archive.SubsystemTypeHeader) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 3 with AriesProvisionDependenciesDirective

use of org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective in project aries by apache.

the class BasicSubsystem method wasInstalledWithChildrenHavingProvisionDependenciesResolve.

private static boolean wasInstalledWithChildrenHavingProvisionDependenciesResolve(Subsystem child) {
    BasicSubsystem bs = (BasicSubsystem) child;
    SubsystemManifest manifest = bs.getSubsystemManifest();
    SubsystemTypeHeader header = manifest.getSubsystemTypeHeader();
    AriesProvisionDependenciesDirective directive = header.getAriesProvisionDependenciesDirective();
    if (directive.isResolve()) {
        return true;
    }
    return wasInstalledWithChildrenHavingProvisionDependenciesResolve(child.getChildren());
}
Also used : SubsystemManifest(org.apache.aries.subsystem.core.archive.SubsystemManifest) AriesProvisionDependenciesDirective(org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective) SubsystemTypeHeader(org.apache.aries.subsystem.core.archive.SubsystemTypeHeader)

Example 4 with AriesProvisionDependenciesDirective

use of org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective in project aries by apache.

the class RawSubsystemResource method computeSubsystemTypeHeader.

private SubsystemTypeHeader computeSubsystemTypeHeader(SubsystemManifest manifest) {
    SubsystemTypeHeader header = manifest.getSubsystemTypeHeader();
    AriesProvisionDependenciesDirective directive = header.getAriesProvisionDependenciesDirective();
    if (directive != null) {
        // manifest. Validation of the value occurs later.
        return header;
    }
    // The directive was not specified in the original manifest. The value 
    // of the parent directive becomes the default.
    SubsystemManifest parentManifest = ((BasicSubsystem) parentSubsystem).getSubsystemManifest();
    SubsystemTypeHeader parentHeader = parentManifest.getSubsystemTypeHeader();
    directive = parentHeader.getAriesProvisionDependenciesDirective();
    header = new SubsystemTypeHeader(header.getValue() + ';' + directive);
    return header;
}
Also used : SubsystemManifest(org.apache.aries.subsystem.core.archive.SubsystemManifest) AriesProvisionDependenciesDirective(org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective) SubsystemTypeHeader(org.apache.aries.subsystem.core.archive.SubsystemTypeHeader)

Example 5 with AriesProvisionDependenciesDirective

use of org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective in project aries by apache.

the class SubsystemTest method uninstallSubsystem.

protected void uninstallSubsystem(Subsystem subsystem, boolean quietly) throws Exception {
    BasicSubsystem basicSubsystem = (BasicSubsystem) subsystem;
    AriesProvisionDependenciesDirective directive = basicSubsystem.getAriesProvisionDependenciesDirective();
    Bundle b = null;
    Region region = null;
    RegionDigraph digraph = context().getService(RegionDigraph.class);
    if (!quietly) {
        if (directive.isResolve()) {
            assertState(EnumSet.of(State.INSTALLING, State.INSTALLED, State.RESOLVED), subsystem);
        } else {
            assertState(EnumSet.of(State.INSTALLED, State.RESOLVED), subsystem);
        }
        subsystemEvents.clear();
        if (subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION) || subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE)) {
            b = getRegionContextBundle(subsystem);
            region = digraph.getRegion(b);
        }
    }
    State state = subsystem.getState();
    subsystem.uninstall();
    if (quietly) {
        return;
    }
    Collection<Subsystem> parents = subsystem.getParents();
    if (!EnumSet.of(State.INSTALL_FAILED, State.INSTALLED, State.INSTALLING).contains(state)) {
        assertEvent(subsystem, State.INSTALLED, 5000);
    }
    assertEvent(subsystem, State.UNINSTALLING, 5000);
    assertEvent(subsystem, State.UNINSTALLED, 5000);
    assertState(State.UNINSTALLED, subsystem);
    for (Subsystem parent : parents) {
        assertNotChild(parent, subsystem);
    }
    if (subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION) || subsystem.getType().equals(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE)) {
        assertEquals("Region context bundle not uninstalled", Bundle.UNINSTALLED, b.getState());
        assertNull("Region not removed", digraph.getRegion(region.getName()));
    }
}
Also used : RegionDigraph(org.eclipse.equinox.region.RegionDigraph) Bundle(org.osgi.framework.Bundle) CoreOptions.mavenBundle(org.ops4j.pax.exam.CoreOptions.mavenBundle) CoreOptions.streamBundle(org.ops4j.pax.exam.CoreOptions.streamBundle) State(org.osgi.service.subsystem.Subsystem.State) BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) Region(org.eclipse.equinox.region.Region) BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) AriesProvisionDependenciesDirective(org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective)

Aggregations

AriesProvisionDependenciesDirective (org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective)5 SubsystemTypeHeader (org.apache.aries.subsystem.core.archive.SubsystemTypeHeader)3 AriesSubsystem (org.apache.aries.subsystem.AriesSubsystem)2 SubsystemManifest (org.apache.aries.subsystem.core.archive.SubsystemManifest)2 Subsystem (org.osgi.service.subsystem.Subsystem)2 BasicSubsystem (org.apache.aries.subsystem.core.internal.BasicSubsystem)1 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)1 Region (org.eclipse.equinox.region.Region)1 RegionDigraph (org.eclipse.equinox.region.RegionDigraph)1 Test (org.junit.Test)1 CoreOptions.mavenBundle (org.ops4j.pax.exam.CoreOptions.mavenBundle)1 CoreOptions.streamBundle (org.ops4j.pax.exam.CoreOptions.streamBundle)1 Bundle (org.osgi.framework.Bundle)1 State (org.osgi.service.subsystem.Subsystem.State)1 SubsystemException (org.osgi.service.subsystem.SubsystemException)1