String pkgName = cap.getAttributes()
.get(PackageNamespace.PACKAGE_NAMESPACE).toString();
// Since a resource can export the same package more than once, get
// all package capabilities for the specified package name.
Wiring wiring = rc.getWirings().get(cap.getResource());
List<Capability> caps = (wiring != null)
? wiring.getResourceCapabilities(null)
: cap.getResource().getCapabilities(null);
for (Capability sourceCap : caps)
{
if (sourceCap.getNamespace().equals(PackageNamespace.PACKAGE_NAMESPACE)
&& sourceCap.getAttributes().get(PackageNamespace.PACKAGE_NAMESPACE).equals(pkgName))