}
public void analyzeResource(Resource resource, List<Capability> caps, List<Requirement> reqs) throws Exception {
Resource fwkFactorySvc = resource.getChild(SERVICE_FRAMEWORK_FACTORY);
if (fwkFactorySvc != null) {
Builder builder = new Builder().setNamespace(Namespaces.NS_CONTRACT).addAttribute(Namespaces.NS_CONTRACT, Namespaces.CONTRACT_OSGI_FRAMEWORK);
Version specVersion = null;
StringBuilder uses = new StringBuilder();
boolean firstPkg = true;
for (Capability cap : caps) {
if (Namespaces.NS_WIRING_PACKAGE.equals(cap.getNamespace())) {
// Add to the uses directive
if (!firstPkg)
uses.append(',');
String pkgName = (String) cap.getAttributes().get(Namespaces.NS_WIRING_PACKAGE);
uses.append(pkgName);
firstPkg = false;
// If it's org.osgi.framework, get the package version and map to OSGi spec version
if (FRAMEWORK_PACKAGE.equals(pkgName)) {
Version frameworkPkgVersion = (Version) cap.getAttributes().get(Namespaces.ATTR_VERSION);
specVersion = mapFrameworkPackageVersion(frameworkPkgVersion);
}
}
}
if (specVersion != null)
builder.addAttribute(Namespaces.ATTR_VERSION, specVersion);
builder.addDirective(Namespaces.DIRECTIVE_USES, uses.toString());
caps.add(builder.buildCapability());
}
}