use of java.util.jar.Attributes in project tomcat by apache.
the class ManifestResource method getAvailableExtensions.
/**
* Return the set of <code>Extension</code> objects representing optional
* packages that are bundled with the application associated with the
* specified <code>Manifest</code>.
*
* @param manifest Manifest to be parsed
*
* @return List of available extensions, or null if the web application
* does not bundle any extensions
*/
private ArrayList<Extension> getAvailableExtensions(Manifest manifest) {
Attributes attributes = manifest.getMainAttributes();
String name = attributes.getValue("Extension-Name");
if (name == null)
return null;
ArrayList<Extension> extensionList = new ArrayList<>();
Extension extension = new Extension();
extension.setExtensionName(name);
extension.setImplementationURL(attributes.getValue("Implementation-URL"));
extension.setImplementationVendor(attributes.getValue("Implementation-Vendor"));
extension.setImplementationVendorId(attributes.getValue("Implementation-Vendor-Id"));
extension.setImplementationVersion(attributes.getValue("Implementation-Version"));
extension.setSpecificationVersion(attributes.getValue("Specification-Version"));
extensionList.add(extension);
return extensionList;
}
use of java.util.jar.Attributes in project buck by facebook.
the class JarContentHasher method getContentHashes.
public ImmutableMap<Path, HashCodeAndFileType> getContentHashes() throws IOException {
Manifest manifest = filesystem.getJarManifest(jarRelativePath);
if (manifest == null) {
throw new UnsupportedOperationException("Cache does not know how to return hash codes for archive members except " + "when the archive contains a META-INF/MANIFEST.MF with " + HashingDeterministicJarWriter.DIGEST_ATTRIBUTE_NAME + " attributes for each file.");
}
ImmutableMap.Builder<Path, HashCodeAndFileType> builder = ImmutableMap.builder();
for (Map.Entry<String, Attributes> nameAttributesEntry : manifest.getEntries().entrySet()) {
Path memberPath = Paths.get(nameAttributesEntry.getKey());
Attributes attributes = nameAttributesEntry.getValue();
String hashStringValue = attributes.getValue(HashingDeterministicJarWriter.DIGEST_ATTRIBUTE_NAME);
if (hashStringValue == null) {
continue;
}
HashCode memberHash = HashCode.fromString(hashStringValue);
HashCodeAndFileType memberHashCodeAndFileType = HashCodeAndFileType.ofFile(memberHash);
builder.put(memberPath, memberHashCodeAndFileType);
}
return builder.build();
}
use of java.util.jar.Attributes in project atlas by alibaba.
the class BundleClassLoader method processManifest.
/**
* process the bundle manifest.
*
* @param manifest the Manifest.
* @throws BundleException in case of parse errors.
*/
private void processManifest(final Manifest manifest) throws BundleException {
final Attributes attrs = (manifest != null) ? manifest.getMainAttributes() : new Attributes();
checkEE(readProperty(attrs, Constants.BUNDLE_REQUIREDEXECUTIONENVIRONMENT), splitString(System.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT)));
// get the exports
exports = readProperty(attrs, Constants.EXPORT_PACKAGE);
if (exports != null) {
int pos = 0;
for (int x = 0; x < exports.length; x++) {
if ((pos = exports[x].indexOf("*")) > -1) {
exports[x] = exports[x].substring(0, pos);
}
Log.d("BundleClassLoader", String.format("%s dependency: %s", location, exports[x]));
}
}
// set the bundle headers
final Hashtable<String, String> headers = new Hashtable<String, String>(attrs.size());
final Object[] entries = attrs.keySet().toArray(new Object[attrs.keySet().size()]);
for (int i = 0; i < entries.length; i++) {
headers.put(entries[i].toString(), attrs.get(entries[i]).toString());
}
bundle.headers = headers;
}
use of java.util.jar.Attributes in project atlas by alibaba.
the class TPatchTool method createManifest.
/**
* 创建tpatch的manifest信息
*
* @return
*/
private Manifest createManifest() {
Manifest manifest = new Manifest();
Attributes main = manifest.getMainAttributes();
main.putValue("Manifest-Version", "1.0");
main.putValue("Created-By", "1.0 (DexPatch)");
main.putValue("Created-Time", new Date(System.currentTimeMillis()).toGMTString());
return manifest;
}
use of java.util.jar.Attributes in project buck by facebook.
the class DeterministicJarManifestWriterTest method testLinesSplitLikeJavaImpl.
@Test
public void testLinesSplitLikeJavaImpl() throws IOException {
final String entryName = "test";
final String key = "12345678";
final String value = "138-char value + 8 char key + 2 char padding = 148 chars. |" + "69-character second line |" + "last line";
manifestWriter.setEntryAttribute(entryName, key, value);
manifestWriter.write();
Manifest jdkManifest = new Manifest();
Attributes attrs = new Attributes();
attrs.putValue(key, value);
jdkManifest.getEntries().put(entryName, attrs);
ByteArrayOutputStream expected = new ByteArrayOutputStream();
jdkManifest.write(expected);
assertArrayEquals(expected.toByteArray(), outputStream.toByteArray());
}
Aggregations