本文整理了Java中org.jboss.shrinkwrap.api.Node.getChildren()
方法的一些代码示例,展示了Node.getChildren()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getChildren()
方法的具体详情如下:
包路径:org.jboss.shrinkwrap.api.Node
类名称:Node
方法名:getChildren
暂无
代码示例来源:origin: com.adaptavist.shrinkwrap/shrinkwrap-atlassian-plugin-impl
private Stream<Node> getLibraryNodes() {
final Node libNode = get(getLibraryPath());
return libNode != null ? libNode.getChildren().stream() : Stream.empty();
}
代码示例来源:origin: org.jboss.shrinkwrap/shrinkwrap-api
@Override
public String format(final Archive<?> archive) throws IllegalArgumentException {
// Precondition checks
if (archive == null) {
throw new IllegalArgumentException("archive must be specified");
}
// Start the output with the name of the archive
StringBuilder sb = new StringBuilder(archive.getName()).append(FormattingConstants.COLON).append(
FormattingConstants.NEWLINE);
// format recursively, except the parent
Node rootNode = archive.get(ROOT);
for (Node child : rootNode.getChildren()) {
format(sb, child);
}
// remove the last NEWLINE
sb.deleteCharAt(sb.length() - 1);
return sb.toString();
}
代码示例来源:origin: shrinkwrap/shrinkwrap
private void format(StringBuilder sb, Node node) {
sb.append(node.getPath().get());
if (node.getAsset() == null) {
sb.append(FormattingConstants.SLASH);
}
sb.append(FormattingConstants.NEWLINE);
for (Node child : node.getChildren()) {
format(sb, child);
}
}
代码示例来源:origin: shrinkwrap/shrinkwrap
@Override
public String format(final Archive<?> archive) throws IllegalArgumentException {
// Precondition checks
if (archive == null) {
throw new IllegalArgumentException("archive must be specified");
}
// Start the output with the name of the archive
StringBuilder sb = new StringBuilder(archive.getName()).append(FormattingConstants.COLON).append(
FormattingConstants.NEWLINE);
// format recursively, except the parent
Node rootNode = archive.get(ROOT);
for (Node child : rootNode.getChildren()) {
format(sb, child);
}
// remove the last NEWLINE
sb.deleteCharAt(sb.length() - 1);
return sb.toString();
}
代码示例来源:origin: org.jboss.shrinkwrap/shrinkwrap-api
private void format(StringBuilder sb, Node node) {
sb.append(node.getPath().get());
if (node.getAsset() == null) {
sb.append(FormattingConstants.SLASH);
}
sb.append(FormattingConstants.NEWLINE);
for (Node child : node.getChildren()) {
format(sb, child);
}
}
代码示例来源:origin: org.arquillian.algeron/arquillian-algeron-provider-maven-retriever
private void unpack(File destination, JavaArchive file) throws IOException {
final Node rootDir = file.get("/");
final Set<Node> contractFiles = rootDir.getChildren();
for (Node contractFile : contractFiles) {
final String filename = contractFile.getPath().get().substring(1);
final Asset asset = contractFile.getAsset();
try (final InputStream in = asset.openStream()) {
Files.copy(in, new File(destination, filename).toPath());
}
}
}
代码示例来源:origin: io.thorntail/tools
protected void filter(Set<ArchivePath> remove, Node node, ResolvedDependencies resolvedDependencies) {
String path = node.getPath().get();
if (path.startsWith("/WEB-INF/lib") && path.endsWith(".jar")) {
if (path.contains("thorntail-runner")) {
remove.add(node.getPath());
}
if (resolvedDependencies.isRemovable(node)) {
remove.add(node.getPath());
}
}
for (Node each : node.getChildren()) {
filter(remove, each, resolvedDependencies);
}
}
}
代码示例来源:origin: org.wildfly.swarm/tools
protected void filter(Set<ArchivePath> remove, Node node, ResolvedDependencies resolvedDependencies) {
String path = node.getPath().get();
if (path.startsWith("/WEB-INF/lib") && path.endsWith(".jar")) {
if (resolvedDependencies.isRemovable(node)) {
remove.add(node.getPath());
}
}
for (Node each : node.getChildren()) {
filter(remove, each, resolvedDependencies);
}
}
}
代码示例来源:origin: org.jboss.shrinkwrap/shrinkwrap-impl-base
/**
* Recursive call to process all the node hierarchy
*
* @param node
*/
private void processNode(final Node node) {
processNode(node.getPath(), node);
Set<Node> children = node.getChildren();
for (Node child : children) {
processNode(child);
}
}
代码示例来源:origin: shrinkwrap/shrinkwrap
/**
* Recursive call to process all the node hierarchy
*
* @param node
*/
private void processNode(final Node node) {
processNode(node.getPath(), node);
Set<Node> children = node.getChildren();
for (Node child : children) {
processNode(child);
}
}
代码示例来源:origin: arquillian/arquillian-core
public void formatNode(Node node, StringBuilder xml) {
if (node.getAsset() != null) {
String source = findResourceLocation(node.getAsset());
xml.append("\t<asset")
.append(" type=\"").append(node.getAsset().getClass().getSimpleName()).append("\"")
.append(" path=\"").append(node.getPath().get()).append("\"");
if (source != null) {
xml.append(" source=\"").append(source).append("\"");
}
if (node.getAsset().getClass() == ArchiveAsset.class) {
xml.append(">");
xml.append("\n");
formatNode(
((ArchiveAsset) node.getAsset()).getArchive().get(ArchivePaths.root()),
xml);
xml.append("</asset>").append("\n");
} else {
xml.append("/>").append("\n");
}
} else {
xml.append("\t<asset type=\"Directory\" path=\"").append(node.getPath().get()).append("\"/>\n");
}
for (Node child : node.getChildren()) {
formatNode(child, xml);
}
}
代码示例来源:origin: org.jboss.shrinkwrap/shrinkwrap-impl-base
/**
* Primary method providing a template for exporting the contents of an archive
*/
protected void doExport() {
// Get archive
final Archive<?> archive = getArchive();
if (log.isLoggable(Level.FINE)) {
log.fine("Exporting archive - " + archive.getName());
}
// Obtain the root
final Node rootNode = archive.get(ArchivePaths.root());
// Recursively process the root children
for (Node child : rootNode.getChildren()) {
processNode(child);
}
}
代码示例来源:origin: shrinkwrap/shrinkwrap
/**
* Primary method providing a template for exporting the contents of an archive
*/
protected void doExport() {
// Get archive
final Archive<?> archive = getArchive();
if (log.isLoggable(Level.FINE)) {
log.fine("Exporting archive - " + archive.getName());
}
// Obtain the root
final Node rootNode = archive.get(ArchivePaths.root());
// Recursively process the root children
for (Node child : rootNode.getChildren()) {
processNode(child);
}
}
代码示例来源:origin: org.jboss.arquillian.container/container-se-managed
public static void materializeSubdirectories(File entryDirectory, Node node) throws DeploymentException, IOException {
for (Node child : node.getChildren()) {
if (child.getAsset() == null) {
materializeSubdirectories(entryDirectory, child);
} else {
if (ClassPathDirectory.isMarkerFileArchivePath(child.getPath())) {
// Do not materialize the marker file
continue;
}
// E.g. META-INF/my-super-descriptor.xml
File resourceFile = new File(entryDirectory, child.getPath().get().replace(DELIMITER_RESOURCE_PATH, File.separatorChar));
File resoureDirectory = resourceFile.getParentFile();
if (!resoureDirectory.exists() && !resoureDirectory.mkdirs()) {
throw new DeploymentException("Could not create class path directory: " + entryDirectory);
}
resourceFile.createNewFile();
try (InputStream in = child.getAsset().openStream(); OutputStream out = new FileOutputStream(resourceFile)) {
copy(in, out);
}
child.getPath().get();
}
}
}
代码示例来源:origin: shrinkwrap/shrinkwrap
private int countChildren(final Node node) {
int count = 0;
for (final Node child : node.getChildren()) {
if (child.getAsset() != null) {
count++;
}
count += countChildren(child);
}
return count;
}
代码示例来源:origin: shrinkwrap/shrinkwrap
/**
* Asserts that the archive recursively contains the specified file in the target starting from the base position.
*/
private void assertArchiveContainsFolderRecursively(File file, ArchivePath base, String target) throws Exception {
ArchivePath testPath = new BasicPath(base, target);
Assert.assertTrue("Archive should contain " + testPath, this.getArchive().contains(testPath));
if (file.isDirectory()) {
for (File child : file.listFiles()) {
assertArchiveContainsFolderRecursively(child, base, target + "/" + child.getName());
}
int folderInArchiveSize = this.getArchive().get(testPath).getChildren().size();
Assert.assertEquals("Wrong number of files in the archive folder: " + testPath.get(),
file.listFiles().length, folderInArchiveSize);
}
}
代码示例来源:origin: GoogleCloudPlatform/appengine-tck
protected void handleWebArchive(WebArchive war) {
final Node lib = war.get("WEB-INF/lib");
if (lib != null) {
final Set<Node> libs = lib.getChildren();
for (Node jar : libs) {
if (jar.getPath().get().contains("appengine-api"))
return;
}
}
// do not add GAE jar; e.g. CapeDwarf can work off GAE module
boolean ignoreGaeJar = Boolean.getBoolean("ignore.gae.jar");
if (ignoreGaeJar == false) {
war.addAsLibraries(Maven.resolver()
.loadPomFromFile("pom.xml")
.resolve("com.google.appengine:appengine-api-1.0-sdk")
.withTransitivity()
.as(File.class)
);
}
}
}
代码示例来源:origin: com.kumuluz.ee.testing/kumuluzee-arquillian-container
/**
* Explodes kumuluzee-loader library to root of the archive.
*
* @param javaArchive Archive with all jars in /WEB-INF/lib (war)
*/
private static void explodeLoaderArchiveToRoot(JavaArchive javaArchive) {
for (Node n : javaArchive.get("/WEB-INF/lib").getChildren()) {
if (n.getAsset() instanceof ArchiveAsset &&
((ArchiveAsset) n.getAsset()).getArchive().getName().startsWith("kumuluzee-loader-")) {
Archive<?> dependencyJar = ((ArchiveAsset) n.getAsset()).getArchive();
LOG.fine("Found kumuluzee-loader archive: " + dependencyJar.getName());
javaArchive.merge(dependencyJar);
javaArchive.delete(n.getPath());
break;
}
}
}
代码示例来源:origin: com.kumuluz.ee.testing/kumuluzee-arquillian-container
/**
* Explodes archive marked with {@link ApplicationArchiveMarker} to root of the archive.
*
* @param javaArchive Archive with all jars in /WEB-INF/lib (war)
*/
private static void explodeAppArchiveToRoot(JavaArchive javaArchive) {
for (Node n : javaArchive.get("/WEB-INF/lib").getChildren()) {
if (n.getAsset() instanceof ArchiveAsset) {
Archive<?> dependencyJar = ((ArchiveAsset) n.getAsset()).getArchive();
if (dependencyJar.contains(ApplicationArchiveMarker.MARKER_FILENAME)) {
LOG.fine("Found application archive: " + dependencyJar.getName());
dependencyJar.delete(ApplicationArchiveMarker.MARKER_FILENAME);
javaArchive.merge(dependencyJar);
javaArchive.delete(n.getPath());
break;
}
}
}
}
代码示例来源:origin: com.kumuluz.ee.testing/kumuluzee-arquillian-container
private static void copyDir(Archive<?> sourceArchive, Archive<?> targetArchive, String source, String target) {
Node sourceNode = sourceArchive.get(source);
if (sourceNode.getAsset() != null) {
targetArchive.add(sourceNode.getAsset(), target);
} else {
for (Node child : sourceNode.getChildren()) {
String childName = child.getPath().get().replaceFirst(child.getPath().getParent().get(), "");
copyDir(sourceArchive, targetArchive,
child.getPath().get(), ArchivePaths.create(target, childName).get());
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!