Search in sources :

Example 1 with SubsystemImportServiceHeader

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

the class Aries1421Test method testSubsystemImportService.

@Test
public void testSubsystemImportService() throws Exception {
    Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
    try {
        String expectedStr = "foo;resolution:=optional,bar;filter:=\"(a=b)\";resolution:=optional";
        SubsystemImportServiceHeader expected = new SubsystemImportServiceHeader(expectedStr);
        Map<String, String> headers = ((BasicSubsystem) applicationA).getDeploymentHeaders();
        String actualStr = headers.get(SubsystemConstants.SUBSYSTEM_IMPORTSERVICE);
        SubsystemImportServiceHeader actual = new SubsystemImportServiceHeader(actualStr);
        assertEquals("Wrong header", expected, actual);
    } finally {
        uninstallSubsystemSilently(applicationA);
    }
}
Also used : BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemImportServiceHeader(org.apache.aries.subsystem.core.archive.SubsystemImportServiceHeader) BasicSubsystem(org.apache.aries.subsystem.core.internal.BasicSubsystem) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Example 2 with SubsystemImportServiceHeader

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

the class SubsystemResource method setImportIsolationPolicy.

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

Example 3 with SubsystemImportServiceHeader

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

the class ServiceDependencyTest method assertSubsystemImportServiceHeader.

private void assertSubsystemImportServiceHeader(Subsystem subsystem, String value) throws InvalidSyntaxException {
    String header = assertHeaderExists(subsystem, SubsystemConstants.SUBSYSTEM_IMPORTSERVICE);
    SubsystemImportServiceHeader actual = new SubsystemImportServiceHeader(header);
    SubsystemImportServiceHeader expected = new SubsystemImportServiceHeader(value);
    Collection<SubsystemImportServiceHeader.Clause> actualClauses = actual.getClauses();
    Collection<SubsystemImportServiceHeader.Clause> expectedClauses = expected.getClauses();
    Assert.assertEquals("Wrong number of clauses", expectedClauses.size(), actualClauses.size());
    Iterator<SubsystemImportServiceHeader.Clause> actualItr = actualClauses.iterator();
    Iterator<SubsystemImportServiceHeader.Clause> expectedItr = expectedClauses.iterator();
    while (expectedItr.hasNext()) {
        assertEquals("Wrong clause", expectedItr.next(), actualItr.next());
    }
}
Also used : SubsystemImportServiceHeader(org.apache.aries.subsystem.core.archive.SubsystemImportServiceHeader)

Example 4 with SubsystemImportServiceHeader

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

the class RawSubsystemResource method computeSubsystemImportServiceHeader.

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

Aggregations

SubsystemImportServiceHeader (org.apache.aries.subsystem.core.archive.SubsystemImportServiceHeader)4 ArrayList (java.util.ArrayList)1 Clause (org.apache.aries.subsystem.core.archive.SubsystemContentHeader.Clause)1 SubsystemImportServiceRequirement (org.apache.aries.subsystem.core.archive.SubsystemImportServiceRequirement)1 BasicSubsystem (org.apache.aries.subsystem.core.internal.BasicSubsystem)1 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)1 Test (org.junit.Test)1 Requirement (org.osgi.resource.Requirement)1 Subsystem (org.osgi.service.subsystem.Subsystem)1