use of org.apache.aries.application.Content in project aries by apache.
the class EquinoxFrameworkUtils method calculateSystemPackagesToFlow.
/**
* Calculates which system packages should be flowed
* to a child framework based on what packages the
* child framework imports. Equinox will require anything imported by the
* child framework which is available from the system bundle
* in the parent framework to come from the system bundle
* in the child framework. However, we don't want to flow
* all the extra system packages by default since we want CBAs
* which use them to explicitly import them.
* @param importPackage
* @return
* @throws CompositeBundleCalculateException
*/
public static String calculateSystemPackagesToFlow(final Collection<Content> systemExports, final Collection<Content> imports) {
// Let's always set javax.transaction as system extra packages because of the split package.
// It is reasonable to do so because we always flow userTransaction service into child framework anyway.
Map<String, String> map = new HashMap<String, String>();
map.put(EquinoxFrameworkConstants.TRANSACTION_BUNDLE, EquinoxFrameworkConstants.TRANSACTION_BUNDLE_VERSION);
Map<String, Map<String, String>> resultMap = new HashMap<String, Map<String, String>>();
resultMap.put(EquinoxFrameworkConstants.TRANSACTION_BUNDLE, map);
// let's go through the import list to build the resultMap
for (Content nvp : imports) {
String name = nvp.getContentName().trim();
// if it exist in the list of packages exported by the system, we need to add it to the result
if (existInExports(name, nvp.getNameValueMap(), systemExports)) {
for (Content nvpp : systemExports) {
if (nvpp.getContentName().trim().equals(name)) {
Map<String, String> frameworkVersion = nvpp.getNameValueMap();
resultMap.put(name, frameworkVersion);
// We don't break here since we're too lazy to check the version
// again and so we might end up flowing multiple statements for the
// same package (but with different versions). Better this than
// accidentally flowing the wrong version if we hit it first.
}
}
}
}
StringBuffer result = new StringBuffer();
for (String key : resultMap.keySet()) {
result.append(getString(key, resultMap) + ",");
}
String toReturn = trimEndString(result.toString().trim(), ",");
return toReturn;
}
use of org.apache.aries.application.Content in project aries by apache.
the class EquinoxFrameworkUtils method getExportPackages.
public static Collection<Content> getExportPackages(BundleContext isolatedBundleContext) {
Set<Content> exports = new HashSet<Content>();
Bundle sysBundle = isolatedBundleContext.getBundle(0);
if (sysBundle != null && sysBundle.getHeaders() != null) {
String exportString = (String) sysBundle.getHeaders().get(Constants.EXPORT_PACKAGE);
if (exportString != null) {
for (NameValuePair nvp : ManifestHeaderProcessor.parseExportString(exportString)) exports.add(ContentFactory.parseContent(nvp.getName(), nvp.getAttributes()));
}
}
return Collections.unmodifiableSet(exports);
}
Aggregations