use of org.apache.aries.util.manifest.ManifestHeaderProcessor.NameValuePair in project aries by apache.
the class DeployedBundlesTest method parseEntries.
/**
* Parse manifest entries into a set of values and associated attributes, which can
* be directly compared for equality regardless of ordering.
* <p>
* Example manifest entry format: value1;attrName1=attrValue1;attrName2=attrValue2,value2;attrName1=attrValue1
* @param entries a manifest header entry.
* @return a set of parsed entries.
*/
private static Map<NameValuePair, Integer> parseEntries(String entries) {
Map<NameValuePair, Integer> result = new HashMap<NameValuePair, Integer>();
for (NameValuePair entry : ManifestHeaderProcessor.parseExportString(entries)) {
Integer count = result.get(entry);
if (count != null) {
// This entry already exists to increment the count.
count++;
} else {
count = 1;
}
result.put(entry, count);
}
return result;
}
use of org.apache.aries.util.manifest.ManifestHeaderProcessor.NameValuePair in project aries by apache.
the class EquinoxFrameworkUtils method getSystemExtraPkgs.
public static Collection<Content> getSystemExtraPkgs(BundleContext context) {
Set<Content> extraPkgs = new HashSet<Content>();
String exportString = context.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA);
if (exportString != null) {
for (NameValuePair nvp : ManifestHeaderProcessor.parseExportString(exportString)) extraPkgs.add(ContentFactory.parseContent(nvp.getName(), nvp.getAttributes()));
}
return Collections.unmodifiableSet(extraPkgs);
}
use of org.apache.aries.util.manifest.ManifestHeaderProcessor.NameValuePair in project aries by apache.
the class OpenEJBLocator method getClassPathLocations.
/**
* Find the classpath entries for our bundle
*
* @param manifest
* @param bundle
* @return
*/
private List<IDirectory> getClassPathLocations(BundleManifest manifest, IDirectory bundle) {
List<IDirectory> result = new ArrayList<IDirectory>();
String rawCp = manifest.getRawAttributes().getValue(Constants.BUNDLE_CLASSPATH);
logger.debug("Classpath is " + rawCp);
if (rawCp == null || rawCp.trim() == "")
result.add(bundle);
else {
List<NameValuePair> splitCp = ManifestHeaderProcessor.parseExportString(rawCp);
List<IFile> allFiles = null;
for (NameValuePair nvp : splitCp) {
String name = nvp.getName().trim();
if (".".equals(name)) {
result.add(bundle);
} else {
IFile f = bundle.getFile(name);
if (f == null) {
//Zip. Check to make sure
if (allFiles == null)
allFiles = bundle.listAllFiles();
for (IFile file : allFiles) {
if (file.getName().startsWith(name)) {
result.add(new ClasspathIDirectory(bundle, name));
break;
}
}
} else {
IDirectory converted = f.convertNested();
if (converted != null)
result.add(converted);
}
}
}
}
return result;
}
use of org.apache.aries.util.manifest.ManifestHeaderProcessor.NameValuePair in project aries by apache.
the class BundleManifest method getSymbolicName.
public String getSymbolicName() {
String rawSymName = manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME);
String result = null;
if (rawSymName != null) {
NameValuePair info = ManifestHeaderProcessor.parseBundleSymbolicName(rawSymName);
result = info.getName();
}
return result;
}
use of org.apache.aries.util.manifest.ManifestHeaderProcessor.NameValuePair in project aries by apache.
the class ManifestHeaderProcessorTest method testExportMandatoryAttributes.
@Test
public void testExportMandatoryAttributes() {
String exportPackage = "com.acme.foo,com.acme.bar;version=2;company=dodo;security=false;mandatory:=\"security,company\"";
List<NameValuePair> exportPackageReturn = ManifestHeaderProcessor.parseExportString(exportPackage);
int i = 0;
assertEquals("The number of the packages is wrong.", 2, exportPackageReturn.size());
for (NameValuePair nvp : exportPackageReturn) {
if (nvp.getName().equals("com.acme.foo")) {
i++;
assertTrue("The directive or attribute should not be set.", nvp.getAttributes().isEmpty());
} else if ((nvp.getName().equals("com.acme.bar")) && ("2".equals(nvp.getAttributes().get("version")))) {
i++;
assertEquals("The directive is wrong.", "dodo", nvp.getAttributes().get("company"));
assertEquals("The directive is wrong.", "false", nvp.getAttributes().get("security"));
assertEquals("The directive is wrong.", "security,company", nvp.getAttributes().get("mandatory:"));
}
}
// make sure all three packages stored
assertEquals("The names of the packages are wrong.", 2, i);
}
Aggregations