Search in sources :

Example 1 with ProvisionPolicyDirective

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

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

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

Aggregations

ProvisionPolicyDirective (org.apache.aries.subsystem.core.archive.ProvisionPolicyDirective)3 SubsystemTypeHeader (org.apache.aries.subsystem.core.archive.SubsystemTypeHeader)3 SubsystemContentHeader (org.apache.aries.subsystem.core.archive.SubsystemContentHeader)1 SubsystemManifest (org.apache.aries.subsystem.core.archive.SubsystemManifest)1 SubsystemException (org.osgi.service.subsystem.SubsystemException)1