Search in sources :

Example 1 with SubsystemTypeHeader

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

the class SubsystemTest method assertProvisionPolicy.

protected void assertProvisionPolicy(Subsystem subsystem, boolean acceptsDependencies) {
    String headerStr = subsystem.getSubsystemHeaders(null).get(SubsystemConstants.SUBSYSTEM_TYPE);
    assertNotNull("Missing subsystem type header", headerStr);
    SubsystemTypeHeader header = new SubsystemTypeHeader(headerStr);
    ProvisionPolicyDirective directive = header.getProvisionPolicyDirective();
    if (acceptsDependencies)
        assertTrue("Subsystem does not accept dependencies", directive.isAcceptDependencies());
    else
        assertTrue("Subsystem accepts dependencies", directive.isRejectDependencies());
}
Also used : ProvisionPolicyDirective(org.apache.aries.subsystem.core.archive.ProvisionPolicyDirective) SubsystemTypeHeader(org.apache.aries.subsystem.core.archive.SubsystemTypeHeader)

Example 2 with SubsystemTypeHeader

use of org.apache.aries.subsystem.core.archive.SubsystemTypeHeader 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 SubsystemTypeHeader

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

the class ResolveContext method isAcceptDependencies.

private boolean isAcceptDependencies() {
    SubsystemManifest manifest = resource.getSubsystemManifest();
    SubsystemTypeHeader header = manifest.getSubsystemTypeHeader();
    ProvisionPolicyDirective directive = header.getProvisionPolicyDirective();
    return directive.isAcceptDependencies();
}
Also used : SubsystemManifest(org.apache.aries.subsystem.core.archive.SubsystemManifest) ProvisionPolicyDirective(org.apache.aries.subsystem.core.archive.ProvisionPolicyDirective) SubsystemTypeHeader(org.apache.aries.subsystem.core.archive.SubsystemTypeHeader)

Example 4 with SubsystemTypeHeader

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

the class SubsystemManifestValidator method validate.

public static void validate(BasicSubsystem subsystem, SubsystemManifest manifest) {
    if (subsystem.getResource().getId() == 0) {
        return;
    }
    validatePreferredProviderHeader(manifest.getPreferredProviderHeader());
    validateAriesProvisionDependenciesDirective(subsystem);
    if (subsystem.isComposite()) {
        SubsystemContentHeader header = manifest.getSubsystemContentHeader();
        if (header == null) {
            return;
        }
        for (SubsystemContentHeader.Clause clause : header.getClauses()) {
            if (!clause.getVersionRange().isExact()) {
                throw new SubsystemException("Composite subsystem using version range for content: " + clause);
            }
        }
    } else if (subsystem.isFeature()) {
        SubsystemTypeHeader subsystemTypeHeader = manifest.getSubsystemTypeHeader();
        ProvisionPolicyDirective provisionPolicyDirective = subsystemTypeHeader.getProvisionPolicyDirective();
        if (provisionPolicyDirective.isAcceptDependencies()) {
            throw new SubsystemException("Feature subsystems may not declare a provision-policy of acceptDependencies");
        }
        if (manifest.getHeaders().get(SubsystemConstants.PREFERRED_PROVIDER) != null) {
            throw new SubsystemException("Feature subsystems may not declare a " + SubsystemConstants.PREFERRED_PROVIDER + " header");
        }
    }
}
Also used : SubsystemContentHeader(org.apache.aries.subsystem.core.archive.SubsystemContentHeader) ProvisionPolicyDirective(org.apache.aries.subsystem.core.archive.ProvisionPolicyDirective) SubsystemException(org.osgi.service.subsystem.SubsystemException) SubsystemTypeHeader(org.apache.aries.subsystem.core.archive.SubsystemTypeHeader)

Example 5 with SubsystemTypeHeader

use of org.apache.aries.subsystem.core.archive.SubsystemTypeHeader 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)

Aggregations

SubsystemTypeHeader (org.apache.aries.subsystem.core.archive.SubsystemTypeHeader)6 AriesProvisionDependenciesDirective (org.apache.aries.subsystem.core.archive.AriesProvisionDependenciesDirective)3 ProvisionPolicyDirective (org.apache.aries.subsystem.core.archive.ProvisionPolicyDirective)3 SubsystemManifest (org.apache.aries.subsystem.core.archive.SubsystemManifest)3 AriesSubsystem (org.apache.aries.subsystem.AriesSubsystem)1 SubsystemContentHeader (org.apache.aries.subsystem.core.archive.SubsystemContentHeader)1 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)1 Test (org.junit.Test)1 Subsystem (org.osgi.service.subsystem.Subsystem)1 SubsystemException (org.osgi.service.subsystem.SubsystemException)1