// Find the matching capabilities from bundles in use bundle, and prune
// matched requirements out of the external requirements collection.
Map<ImportedPackage,ExportedPackage> useBundlePkgs = new HashMap<ImportedPackage,ExportedPackage>();
for (Iterator<ImportedPackage> iter = externalReqs.iterator(); iter.hasNext(); )
{
ImportedPackage req = iter.next();
ExportedPackage match = getPackageMatch(req, deployedUseBundle);
if (match != null)
{
useBundlePkgs.put(req, match);
iter.remove();
}
}
StringBuilder useBundleImports = new StringBuilder();
for(Map.Entry<ImportedPackage, ExportedPackage> entry : useBundlePkgs.entrySet()) {
useBundleImports.append(entry.getValue().toDeploymentString());
ImportedPackage key = entry.getKey();
if(key.isOptional())
useBundleImports.append(";" + Constants.RESOLUTION_DIRECTIVE +":=" + Constants.RESOLUTION_OPTIONAL);
useBundleImports.append(",");
}
String result = useBundleImports.toString() + createManifestString(externalReqs);