Search in sources :

Example 1 with RequireBundleHeader

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

the class Aries1421Test method testRequireBundleVersionRanges.

@Test
public void testRequireBundleVersionRanges() throws Exception {
    Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
    try {
        Bundle bundleA = getConstituentAsBundle(applicationA, BUNDLE_A, null, null);
        String expectedStr = bundleA.getHeaders().get(Constants.REQUIRE_BUNDLE);
        RequireBundleHeader expected = new RequireBundleHeader(expectedStr);
        Map<String, String> headers = ((BasicSubsystem) applicationA).getDeploymentHeaders();
        String actualStr = headers.get(Constants.REQUIRE_BUNDLE);
        RequireBundleHeader actual = new RequireBundleHeader(actualStr);
        assertEquals("Wrong header", expected, actual);
    } finally {
        uninstallSubsystemSilently(applicationA);
    }
}
Also used : RequireBundleHeader(org.apache.aries.subsystem.core.archive.RequireBundleHeader) Bundle(org.osgi.framework.Bundle) BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Example 2 with RequireBundleHeader

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

the class SubsystemResource method setImportIsolationPolicy.

private void setImportIsolationPolicy(RegionFilterBuilder builder, RequireBundleHeader header) throws InvalidSyntaxException {
    if (header == null)
        return;
    for (RequireBundleHeader.Clause clause : header.getClauses()) {
        RequireBundleRequirement requirement = new RequireBundleRequirement(clause, this);
        String policy = RegionFilter.VISIBLE_REQUIRE_NAMESPACE;
        String filter = requirement.getDirectives().get(RequireBundleRequirement.DIRECTIVE_FILTER);
        builder.allow(policy, filter);
    }
}
Also used : RequireBundleHeader(org.apache.aries.subsystem.core.archive.RequireBundleHeader) RequireBundleRequirement(org.apache.aries.subsystem.core.archive.RequireBundleRequirement)

Example 3 with RequireBundleHeader

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

the class RawSubsystemResource method computeRequireBundleHeader.

private RequireBundleHeader computeRequireBundleHeader() {
    if (requirements.isEmpty())
        return null;
    ArrayList<RequireBundleHeader.Clause> clauses = new ArrayList<RequireBundleHeader.Clause>(requirements.size());
    for (Requirement requirement : requirements) {
        if (!BundleNamespace.BUNDLE_NAMESPACE.equals(requirement.getNamespace()))
            continue;
        clauses.add(RequireBundleHeader.Clause.valueOf(requirement));
    }
    if (clauses.isEmpty())
        return null;
    clauses.trimToSize();
    return new RequireBundleHeader(clauses);
}
Also used : RequireBundleHeader(org.apache.aries.subsystem.core.archive.RequireBundleHeader) Requirement(org.osgi.resource.Requirement) ArrayList(java.util.ArrayList) Clause(org.apache.aries.subsystem.core.archive.SubsystemContentHeader.Clause)

Aggregations

RequireBundleHeader (org.apache.aries.subsystem.core.archive.RequireBundleHeader)3 ArrayList (java.util.ArrayList)1 RequireBundleRequirement (org.apache.aries.subsystem.core.archive.RequireBundleRequirement)1 Clause (org.apache.aries.subsystem.core.archive.SubsystemContentHeader.Clause)1 BasicSubsystem (org.apache.aries.subsystem.core.internal.BasicSubsystem)1 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)1 Test (org.junit.Test)1 Bundle (org.osgi.framework.Bundle)1 Requirement (org.osgi.resource.Requirement)1 Subsystem (org.osgi.service.subsystem.Subsystem)1