本文整理汇总了Java中org.jboss.shrinkwrap.api.container.ManifestContainer.addAsManifestResource方法的典型用法代码示例。如果您正苦于以下问题:Java ManifestContainer.addAsManifestResource方法的具体用法?Java ManifestContainer.addAsManifestResource怎么用?Java ManifestContainer.addAsManifestResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.shrinkwrap.api.container.ManifestContainer
的用法示例。
在下文中一共展示了ManifestContainer.addAsManifestResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleDependencies
import org.jboss.shrinkwrap.api.container.ManifestContainer; //导入方法依赖的package包/类
public static void handleDependencies(Archive<?> archive) {
if (archive instanceof ManifestContainer<?> == false) {
throw new IllegalArgumentException("ManifestContainer expected: " + archive);
}
final Manifest manifest = getOrCreateManifest(archive);
ManifestContainer manifestContainer = ManifestContainer.class.cast(archive);
Attributes attributes = manifest.getMainAttributes();
if (attributes.getValue(Attributes.Name.MANIFEST_VERSION.toString()) == null) {
attributes.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
}
String value = attributes.getValue("Dependencies");
StringBuilder moduleDeps = new StringBuilder(value != null && value.trim().length() > 0 ? value : "");
moduleDeps.append(defaultDependencies[0]);
for (int i = 1; i < defaultDependencies.length; i++) {
moduleDeps.append(",").append(defaultDependencies[i]);
}
attributes.putValue("Dependencies", moduleDeps.toString());
// Add the manifest to the archive
ArchivePath manifestPath = ArchivePaths.create(JarFile.MANIFEST_NAME);
archive.delete(manifestPath);
manifestContainer.addAsManifestResource(new Asset() {
public InputStream openStream() {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
manifest.write(baos);
return new ByteArrayInputStream(baos.toByteArray());
} catch (IOException ex) {
throw new IllegalStateException("Cannot write manifest", ex);
}
}
}, "MANIFEST.MF");
}
示例2: addMarker
import org.jboss.shrinkwrap.api.container.ManifestContainer; //导入方法依赖的package包/类
static void addMarker(ManifestContainer<?> manifestContainer, String markerName) {
manifestContainer.addAsManifestResource(new StringAsset("marker"), ArchivePaths.create(PATH_MARKERS, markerName));
}