Search in sources :

Example 1 with ImportPackageHeader

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

the class SubsystemResource method setImportIsolationPolicy.

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

Example 2 with ImportPackageHeader

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

the class RawSubsystemResource method computeImportPackageHeader.

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

Example 3 with ImportPackageHeader

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

the class Aries1421Test method testImportPackageVersionRanges.

@Test
public void testImportPackageVersionRanges() throws Exception {
    Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
    try {
        Bundle bundleA = getConstituentAsBundle(applicationA, BUNDLE_A, null, null);
        String expectedStr = bundleA.getHeaders().get(Constants.IMPORT_PACKAGE);
        ImportPackageHeader expected = new ImportPackageHeader(expectedStr);
        Map<String, String> headers = ((BasicSubsystem) applicationA).getDeploymentHeaders();
        String actualStr = headers.get(Constants.IMPORT_PACKAGE);
        ImportPackageHeader actual = new ImportPackageHeader(actualStr);
        assertEquals("Wrong header", expected, actual);
    } finally {
        uninstallSubsystemSilently(applicationA);
    }
}
Also used : 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) ImportPackageHeader(org.apache.aries.subsystem.core.archive.ImportPackageHeader) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Aggregations

ImportPackageHeader (org.apache.aries.subsystem.core.archive.ImportPackageHeader)3 ArrayList (java.util.ArrayList)1 ImportPackageRequirement (org.apache.aries.subsystem.core.archive.ImportPackageRequirement)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