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