Search in sources :

Example 1 with DeployedContentHeader

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

the class Aries1425Test method testDeployedContentHeader.

@Test
public void testDeployedContentHeader() throws Exception {
    Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
    try {
        Map<String, String> headers = applicationA.getDeploymentHeaders();
        String header = headers.get(SubsystemConstants.DEPLOYED_CONTENT);
        DeployedContentHeader dch = new DeployedContentHeader(header);
        boolean foundClause = false;
        for (DeployedContentHeader.Clause clause : dch.getClauses()) {
            if (BUNDLE_A.equals(clause.getSymbolicName())) {
                assertEquals("Wrong type", IdentityNamespace.TYPE_FRAGMENT, clause.getType());
                foundClause = true;
                break;
            }
        }
        assertTrue("Missing clause", foundClause);
    } finally {
        uninstallSubsystemSilently(applicationA);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) DeployedContentHeader(org.apache.aries.subsystem.core.archive.DeployedContentHeader) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Example 2 with DeployedContentHeader

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

the class BasicSubsystem method removedContent.

synchronized void removedContent(Collection<DeployedContentHeader.Clause> content) {
    DeploymentManifest manifest = getDeploymentManifest();
    DeployedContentHeader header = manifest.getDeployedContentHeader();
    if (header == null)
        return;
    Collection<DeployedContentHeader.Clause> clauses = new ArrayList<DeployedContentHeader.Clause>(header.getClauses());
    for (Iterator<DeployedContentHeader.Clause> i = clauses.iterator(); i.hasNext(); ) if (content.contains(i.next())) {
        i.remove();
        break;
    }
    DeploymentManifest.Builder builder = new DeploymentManifest.Builder();
    for (Entry<String, Header<?>> entry : manifest.getHeaders().entrySet()) {
        if (DeployedContentHeader.NAME.equals(entry.getKey()))
            continue;
        builder.header(entry.getValue());
    }
    if (!clauses.isEmpty())
        builder.header(new DeployedContentHeader(clauses));
    try {
        setDeploymentManifest(builder.build());
    } catch (Exception e) {
        throw new SubsystemException(e);
    }
}
Also used : DeploymentManifest(org.apache.aries.subsystem.core.archive.DeploymentManifest) SubsystemException(org.osgi.service.subsystem.SubsystemException) DeployedContentHeader(org.apache.aries.subsystem.core.archive.DeployedContentHeader) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) BundleException(org.osgi.framework.BundleException) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException) ResolutionException(org.osgi.service.resolver.ResolutionException) SubsystemException(org.osgi.service.subsystem.SubsystemException) IOException(java.io.IOException) SubsystemTypeHeader(org.apache.aries.subsystem.core.archive.SubsystemTypeHeader) SubsystemContentHeader(org.apache.aries.subsystem.core.archive.SubsystemContentHeader) ProvisionResourceHeader(org.apache.aries.subsystem.core.archive.ProvisionResourceHeader) AriesSubsystemParentsHeader(org.apache.aries.subsystem.core.archive.AriesSubsystemParentsHeader) Header(org.apache.aries.subsystem.core.archive.Header) DeployedContentHeader(org.apache.aries.subsystem.core.archive.DeployedContentHeader)

Example 3 with DeployedContentHeader

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

the class BasicSubsystem method removedContent.

void removedContent(Resource resource) {
    DeploymentManifest manifest = getDeploymentManifest();
    DeployedContentHeader header = manifest.getDeployedContentHeader();
    if (header == null)
        return;
    DeployedContentHeader.Clause clause = header.getClause(resource);
    if (clause == null)
        return;
    removedContent(Collections.singleton(clause));
}
Also used : DeploymentManifest(org.apache.aries.subsystem.core.archive.DeploymentManifest) DeployedContentHeader(org.apache.aries.subsystem.core.archive.DeployedContentHeader)

Aggregations

DeployedContentHeader (org.apache.aries.subsystem.core.archive.DeployedContentHeader)3 DeploymentManifest (org.apache.aries.subsystem.core.archive.DeploymentManifest)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 AriesSubsystemParentsHeader (org.apache.aries.subsystem.core.archive.AriesSubsystemParentsHeader)1 Header (org.apache.aries.subsystem.core.archive.Header)1 ProvisionResourceHeader (org.apache.aries.subsystem.core.archive.ProvisionResourceHeader)1 SubsystemContentHeader (org.apache.aries.subsystem.core.archive.SubsystemContentHeader)1 SubsystemTypeHeader (org.apache.aries.subsystem.core.archive.SubsystemTypeHeader)1 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)1 Test (org.junit.Test)1 BundleException (org.osgi.framework.BundleException)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1 ResolutionException (org.osgi.service.resolver.ResolutionException)1 Subsystem (org.osgi.service.subsystem.Subsystem)1 SubsystemException (org.osgi.service.subsystem.SubsystemException)1