Search in sources :

Example 51 with BundleRequirement

use of org.osgi.framework.wiring.BundleRequirement in project karaf by apache.

the class PackageServiceImpl method getImports.

@Override
public List<String> getImports(long bundleId) {
    Bundle bundle = bundleContext.getBundle(bundleId);
    BundleRevision rev = bundle.adapt(BundleRevision.class);
    List<BundleRequirement> reqs = rev.getDeclaredRequirements(BundleRevision.PACKAGE_NAMESPACE);
    List<String> imports = new ArrayList<>();
    for (BundleRequirement req : reqs) {
        PackageRequirement packageReq = create(req, bundle);
        imports.add(packageReq.getPackageName());
    }
    return imports;
}
Also used : Bundle(org.osgi.framework.Bundle) PackageRequirement(org.apache.karaf.packages.core.PackageRequirement) BundleRevision(org.osgi.framework.wiring.BundleRevision) ArrayList(java.util.ArrayList) BundleRequirement(org.osgi.framework.wiring.BundleRequirement)

Example 52 with BundleRequirement

use of org.osgi.framework.wiring.BundleRequirement in project karaf by apache.

the class BundleServiceImpl method getUnsatisfiedRequirements.

@Override
public List<BundleRequirement> getUnsatisfiedRequirements(Bundle bundle, String namespace) {
    List<BundleRequirement> result = new ArrayList<>();
    BundleRevision rev = bundle.adapt(BundleRevision.class);
    if (rev != null) {
        List<BundleRequirement> reqs = rev.getDeclaredRequirements(namespace);
        for (BundleRequirement req : reqs) {
            if (!canBeSatisfied(req)) {
                result.add(req);
            }
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) BundleRevision(org.osgi.framework.wiring.BundleRevision) BundleRequirement(org.osgi.framework.wiring.BundleRequirement)

Example 53 with BundleRequirement

use of org.osgi.framework.wiring.BundleRequirement in project karaf by apache.

the class BundleWiresTest method hostRequirement.

private BundleRequirement hostRequirement(String packageFilter) {
    BundleRequirement req = c.createMock(BundleRequirement.class);
    Map<String, String> directives = new HashMap<>();
    directives.put(Namespace.REQUIREMENT_FILTER_DIRECTIVE, packageFilter);
    expect(req.getDirectives()).andReturn(directives);
    expect(req.getNamespace()).andReturn(HostNamespace.HOST_NAMESPACE);
    return req;
}
Also used : BundleRequirement(org.osgi.framework.wiring.BundleRequirement)

Example 54 with BundleRequirement

use of org.osgi.framework.wiring.BundleRequirement in project karaf by apache.

the class BundleWiresTest method packageRequirement.

private BundleRequirement packageRequirement(String packageFilter) {
    BundleRequirement req = c.createMock(BundleRequirement.class);
    Map<String, String> directives = new HashMap<>();
    directives.put(Namespace.REQUIREMENT_FILTER_DIRECTIVE, packageFilter);
    expect(req.getDirectives()).andReturn(directives);
    expect(req.getNamespace()).andReturn(PackageNamespace.PACKAGE_NAMESPACE);
    return req;
}
Also used : BundleRequirement(org.osgi.framework.wiring.BundleRequirement)

Example 55 with BundleRequirement

use of org.osgi.framework.wiring.BundleRequirement in project karaf by apache.

the class BundleWiresTest method hostWire.

private BundleWire hostWire(String hostFilter, BundleCapability bundleRef) {
    BundleWire wire = c.createMock(BundleWire.class);
    BundleRequirement req = hostRequirement(hostFilter);
    expect(wire.getRequirement()).andReturn(req);
    expect(wire.getCapability()).andReturn(bundleRef);
    return wire;
}
Also used : BundleWire(org.osgi.framework.wiring.BundleWire) BundleRequirement(org.osgi.framework.wiring.BundleRequirement)

Aggregations

BundleRequirement (org.osgi.framework.wiring.BundleRequirement)55 BundleCapability (org.osgi.framework.wiring.BundleCapability)23 ArrayList (java.util.ArrayList)20 BundleWire (org.osgi.framework.wiring.BundleWire)18 BundleRevision (org.osgi.framework.wiring.BundleRevision)17 HashMap (java.util.HashMap)15 Bundle (org.osgi.framework.Bundle)15 Test (org.junit.Test)14 BundleException (org.osgi.framework.BundleException)11 ResolverHook (org.osgi.framework.hooks.resolver.ResolverHook)10 BundleWiring (org.osgi.framework.wiring.BundleWiring)10 List (java.util.List)9 Collection (java.util.Collection)8 BundleRequirementImpl (org.apache.felix.framework.wiring.BundleRequirementImpl)8 ResolverHookFactory (org.osgi.framework.hooks.resolver.ResolverHookFactory)8 CompositeData (javax.management.openmbean.CompositeData)6 Module (org.eclipse.osgi.container.Module)6 ModuleContainer (org.eclipse.osgi.container.ModuleContainer)6 DummyContainerAdaptor (org.eclipse.osgi.tests.container.dummys.DummyContainerAdaptor)6 SimpleFilter (org.apache.felix.framework.capabilityset.SimpleFilter)5