Search in sources :

Example 16 with Resource

use of org.osgi.resource.Resource in project aries by apache.

the class ResolveContext method isProcessableAsFragment.

private boolean isProcessableAsFragment(Requirement requirement) {
    Resource resource = requirement.getResource();
    String namespace = requirement.getNamespace();
    return Utils.isFragment(resource) && !(ExecutionEnvironmentNamespace.EXECUTION_ENVIRONMENT_NAMESPACE.equals(namespace) || HostNamespace.HOST_NAMESPACE.equals(namespace));
}
Also used : Resource(org.osgi.resource.Resource)

Example 17 with Resource

use of org.osgi.resource.Resource in project aries by apache.

the class ResolveContext method installDependenciesOfRequirerIfNecessary.

private void installDependenciesOfRequirerIfNecessary(Requirement requirement) {
    if (requirement == null) {
        return;
    }
    Resource requirer = requirement.getResource();
    if (resource.equals(requirer)) {
        return;
    }
    Collection<BasicSubsystem> subsystems;
    if (requirer instanceof BasicSubsystem) {
        BasicSubsystem subsystem = (BasicSubsystem) requirer;
        subsystems = Collections.singletonList(subsystem);
    } else if (requirer instanceof BundleRevision) {
        BundleRevision revision = (BundleRevision) requirer;
        BundleConstituent constituent = new BundleConstituent(null, revision);
        subsystems = Activator.getInstance().getSubsystems().getSubsystemsByConstituent(constituent);
    } else {
        return;
    }
    for (BasicSubsystem subsystem : subsystems) {
        if (Utils.isProvisionDependenciesInstall(subsystem) || !State.INSTALLING.equals(subsystem.getState())) {
            continue;
        }
        AccessController.doPrivileged(new StartAction(subsystem, subsystem, subsystem, Restriction.INSTALL_ONLY));
    }
}
Also used : BundleConstituent(org.apache.aries.subsystem.core.internal.BundleResourceInstaller.BundleConstituent) Resource(org.osgi.resource.Resource) BundleRevision(org.osgi.framework.wiring.BundleRevision)

Example 18 with Resource

use of org.osgi.resource.Resource in project aries by apache.

the class ResolveContext method processAsBundle.

private void processAsBundle(Requirement requirement, List<Capability> capabilities) {
    String namespace = requirement.getNamespace();
    Resource bundle = requirement.getResource();
    Wiring wiring = wirings.get(bundle);
    List<Wire> wires = wiring.getRequiredResourceWires(namespace);
    processWires(wires, requirement, capabilities);
}
Also used : BundleWiring(org.osgi.framework.wiring.BundleWiring) Wiring(org.osgi.resource.Wiring) Resource(org.osgi.resource.Resource) Wire(org.osgi.resource.Wire)

Example 19 with Resource

use of org.osgi.resource.Resource in project aries by apache.

the class Aries1368Test method testApplicationWithFragmentInArchiveWithSubsystemContentHeaderWithType.

@Test
public void testApplicationWithFragmentInArchiveWithSubsystemContentHeaderWithType() throws Exception {
    Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
    try {
        assertConstituents(3, applicationA);
        startSubsystem(applicationA);
        assertBundleState(Bundle.ACTIVE, BUNDLE_A, applicationA);
        assertBundleState(Bundle.RESOLVED, FRAGMENT_A, applicationA);
        Bundle bundle = context(applicationA).getBundleByName(FRAGMENT_A);
        assertNotNull("Bundle not found: " + FRAGMENT_A, bundle);
        Resource resource = bundle.adapt(BundleRevision.class);
        Capability capability = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).get(0);
        assertEquals("Wrong type", IdentityNamespace.TYPE_FRAGMENT, capability.getAttributes().get(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE));
    } finally {
        stopAndUninstallSubsystemSilently(applicationA);
    }
}
Also used : Capability(org.osgi.resource.Capability) TestCapability(org.apache.aries.subsystem.itests.util.TestCapability) Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) Resource(org.osgi.resource.Resource) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 20 with Resource

use of org.osgi.resource.Resource in project aries by apache.

the class Aries1368Test method testApplicationWithFragmentInRepositoryWithSubsystemContentHeaderWithType.

@Test
public void testApplicationWithFragmentInRepositoryWithSubsystemContentHeaderWithType() throws Exception {
    Subsystem applicationB = installSubsystemFromFile(APPLICATION_B);
    try {
        assertConstituents(3, applicationB);
        startSubsystem(applicationB);
        assertBundleState(Bundle.ACTIVE, BUNDLE_A, applicationB);
        assertBundleState(Bundle.RESOLVED, FRAGMENT_A, applicationB);
        Bundle bundle = context(applicationB).getBundleByName(FRAGMENT_A);
        assertNotNull("Bundle not found: " + FRAGMENT_A, bundle);
        Resource resource = bundle.adapt(BundleRevision.class);
        Capability capability = resource.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE).get(0);
        String type = String.valueOf(capability.getAttributes().get(IdentityNamespace.CAPABILITY_TYPE_ATTRIBUTE));
        assertEquals("Wrong type", IdentityNamespace.TYPE_FRAGMENT, type);
    } finally {
        stopAndUninstallSubsystemSilently(applicationB);
    }
}
Also used : Capability(org.osgi.resource.Capability) TestCapability(org.apache.aries.subsystem.itests.util.TestCapability) Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) Resource(org.osgi.resource.Resource) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Aggregations

Resource (org.osgi.resource.Resource)201 Capability (org.osgi.resource.Capability)62 Requirement (org.osgi.resource.Requirement)62 ArrayList (java.util.ArrayList)57 List (java.util.List)39 HashMap (java.util.HashMap)32 File (java.io.File)27 Collection (java.util.Collection)24 Wire (org.osgi.resource.Wire)24 ResourceBuilder (aQute.bnd.osgi.resource.ResourceBuilder)23 Map (java.util.Map)22 CapReqBuilder (aQute.bnd.osgi.resource.CapReqBuilder)18 URI (java.net.URI)18 HashSet (java.util.HashSet)18 BndEditModel (aQute.bnd.build.model.BndEditModel)15 MockRegistry (test.lib.MockRegistry)15 Version (org.osgi.framework.Version)14 BundleRevision (org.osgi.framework.wiring.BundleRevision)14 Repository (org.osgi.service.repository.Repository)14 IdentityCapability (aQute.bnd.osgi.resource.ResourceUtils.IdentityCapability)13