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");
}
}
}
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();
}
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());
}
Aggregations