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