org.jboss.shrinkwrap.api.Node.getChildren()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(165)

本文整理了Java中org.jboss.shrinkwrap.api.Node.getChildren()方法的一些代码示例,展示了Node.getChildren()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getChildren()方法的具体详情如下:
包路径:org.jboss.shrinkwrap.api.Node
类名称:Node
方法名:getChildren

Node.getChildren介绍

暂无

代码示例

代码示例来源:origin: com.adaptavist.shrinkwrap/shrinkwrap-atlassian-plugin-impl

  1. private Stream<Node> getLibraryNodes() {
  2. final Node libNode = get(getLibraryPath());
  3. return libNode != null ? libNode.getChildren().stream() : Stream.empty();
  4. }

代码示例来源:origin: org.jboss.shrinkwrap/shrinkwrap-api

  1. @Override
  2. public String format(final Archive<?> archive) throws IllegalArgumentException {
  3. // Precondition checks
  4. if (archive == null) {
  5. throw new IllegalArgumentException("archive must be specified");
  6. }
  7. // Start the output with the name of the archive
  8. StringBuilder sb = new StringBuilder(archive.getName()).append(FormattingConstants.COLON).append(
  9. FormattingConstants.NEWLINE);
  10. // format recursively, except the parent
  11. Node rootNode = archive.get(ROOT);
  12. for (Node child : rootNode.getChildren()) {
  13. format(sb, child);
  14. }
  15. // remove the last NEWLINE
  16. sb.deleteCharAt(sb.length() - 1);
  17. return sb.toString();
  18. }

代码示例来源:origin: shrinkwrap/shrinkwrap

  1. private void format(StringBuilder sb, Node node) {
  2. sb.append(node.getPath().get());
  3. if (node.getAsset() == null) {
  4. sb.append(FormattingConstants.SLASH);
  5. }
  6. sb.append(FormattingConstants.NEWLINE);
  7. for (Node child : node.getChildren()) {
  8. format(sb, child);
  9. }
  10. }

代码示例来源:origin: shrinkwrap/shrinkwrap

  1. @Override
  2. public String format(final Archive<?> archive) throws IllegalArgumentException {
  3. // Precondition checks
  4. if (archive == null) {
  5. throw new IllegalArgumentException("archive must be specified");
  6. }
  7. // Start the output with the name of the archive
  8. StringBuilder sb = new StringBuilder(archive.getName()).append(FormattingConstants.COLON).append(
  9. FormattingConstants.NEWLINE);
  10. // format recursively, except the parent
  11. Node rootNode = archive.get(ROOT);
  12. for (Node child : rootNode.getChildren()) {
  13. format(sb, child);
  14. }
  15. // remove the last NEWLINE
  16. sb.deleteCharAt(sb.length() - 1);
  17. return sb.toString();
  18. }

代码示例来源:origin: org.jboss.shrinkwrap/shrinkwrap-api

  1. private void format(StringBuilder sb, Node node) {
  2. sb.append(node.getPath().get());
  3. if (node.getAsset() == null) {
  4. sb.append(FormattingConstants.SLASH);
  5. }
  6. sb.append(FormattingConstants.NEWLINE);
  7. for (Node child : node.getChildren()) {
  8. format(sb, child);
  9. }
  10. }

代码示例来源:origin: org.arquillian.algeron/arquillian-algeron-provider-maven-retriever

  1. private void unpack(File destination, JavaArchive file) throws IOException {
  2. final Node rootDir = file.get("/");
  3. final Set<Node> contractFiles = rootDir.getChildren();
  4. for (Node contractFile : contractFiles) {
  5. final String filename = contractFile.getPath().get().substring(1);
  6. final Asset asset = contractFile.getAsset();
  7. try (final InputStream in = asset.openStream()) {
  8. Files.copy(in, new File(destination, filename).toPath());
  9. }
  10. }
  11. }

代码示例来源:origin: io.thorntail/tools

  1. protected void filter(Set<ArchivePath> remove, Node node, ResolvedDependencies resolvedDependencies) {
  2. String path = node.getPath().get();
  3. if (path.startsWith("/WEB-INF/lib") && path.endsWith(".jar")) {
  4. if (path.contains("thorntail-runner")) {
  5. remove.add(node.getPath());
  6. }
  7. if (resolvedDependencies.isRemovable(node)) {
  8. remove.add(node.getPath());
  9. }
  10. }
  11. for (Node each : node.getChildren()) {
  12. filter(remove, each, resolvedDependencies);
  13. }
  14. }
  15. }

代码示例来源:origin: org.wildfly.swarm/tools

  1. protected void filter(Set<ArchivePath> remove, Node node, ResolvedDependencies resolvedDependencies) {
  2. String path = node.getPath().get();
  3. if (path.startsWith("/WEB-INF/lib") && path.endsWith(".jar")) {
  4. if (resolvedDependencies.isRemovable(node)) {
  5. remove.add(node.getPath());
  6. }
  7. }
  8. for (Node each : node.getChildren()) {
  9. filter(remove, each, resolvedDependencies);
  10. }
  11. }
  12. }

代码示例来源:origin: org.jboss.shrinkwrap/shrinkwrap-impl-base

  1. /**
  2. * Recursive call to process all the node hierarchy
  3. *
  4. * @param node
  5. */
  6. private void processNode(final Node node) {
  7. processNode(node.getPath(), node);
  8. Set<Node> children = node.getChildren();
  9. for (Node child : children) {
  10. processNode(child);
  11. }
  12. }

代码示例来源:origin: shrinkwrap/shrinkwrap

  1. /**
  2. * Recursive call to process all the node hierarchy
  3. *
  4. * @param node
  5. */
  6. private void processNode(final Node node) {
  7. processNode(node.getPath(), node);
  8. Set<Node> children = node.getChildren();
  9. for (Node child : children) {
  10. processNode(child);
  11. }
  12. }

代码示例来源:origin: arquillian/arquillian-core

  1. public void formatNode(Node node, StringBuilder xml) {
  2. if (node.getAsset() != null) {
  3. String source = findResourceLocation(node.getAsset());
  4. xml.append("\t<asset")
  5. .append(" type=\"").append(node.getAsset().getClass().getSimpleName()).append("\"")
  6. .append(" path=\"").append(node.getPath().get()).append("\"");
  7. if (source != null) {
  8. xml.append(" source=\"").append(source).append("\"");
  9. }
  10. if (node.getAsset().getClass() == ArchiveAsset.class) {
  11. xml.append(">");
  12. xml.append("\n");
  13. formatNode(
  14. ((ArchiveAsset) node.getAsset()).getArchive().get(ArchivePaths.root()),
  15. xml);
  16. xml.append("</asset>").append("\n");
  17. } else {
  18. xml.append("/>").append("\n");
  19. }
  20. } else {
  21. xml.append("\t<asset type=\"Directory\" path=\"").append(node.getPath().get()).append("\"/>\n");
  22. }
  23. for (Node child : node.getChildren()) {
  24. formatNode(child, xml);
  25. }
  26. }

代码示例来源:origin: org.jboss.shrinkwrap/shrinkwrap-impl-base

  1. /**
  2. * Primary method providing a template for exporting the contents of an archive
  3. */
  4. protected void doExport() {
  5. // Get archive
  6. final Archive<?> archive = getArchive();
  7. if (log.isLoggable(Level.FINE)) {
  8. log.fine("Exporting archive - " + archive.getName());
  9. }
  10. // Obtain the root
  11. final Node rootNode = archive.get(ArchivePaths.root());
  12. // Recursively process the root children
  13. for (Node child : rootNode.getChildren()) {
  14. processNode(child);
  15. }
  16. }

代码示例来源:origin: shrinkwrap/shrinkwrap

  1. /**
  2. * Primary method providing a template for exporting the contents of an archive
  3. */
  4. protected void doExport() {
  5. // Get archive
  6. final Archive<?> archive = getArchive();
  7. if (log.isLoggable(Level.FINE)) {
  8. log.fine("Exporting archive - " + archive.getName());
  9. }
  10. // Obtain the root
  11. final Node rootNode = archive.get(ArchivePaths.root());
  12. // Recursively process the root children
  13. for (Node child : rootNode.getChildren()) {
  14. processNode(child);
  15. }
  16. }

代码示例来源:origin: org.jboss.arquillian.container/container-se-managed

  1. public static void materializeSubdirectories(File entryDirectory, Node node) throws DeploymentException, IOException {
  2. for (Node child : node.getChildren()) {
  3. if (child.getAsset() == null) {
  4. materializeSubdirectories(entryDirectory, child);
  5. } else {
  6. if (ClassPathDirectory.isMarkerFileArchivePath(child.getPath())) {
  7. // Do not materialize the marker file
  8. continue;
  9. }
  10. // E.g. META-INF/my-super-descriptor.xml
  11. File resourceFile = new File(entryDirectory, child.getPath().get().replace(DELIMITER_RESOURCE_PATH, File.separatorChar));
  12. File resoureDirectory = resourceFile.getParentFile();
  13. if (!resoureDirectory.exists() && !resoureDirectory.mkdirs()) {
  14. throw new DeploymentException("Could not create class path directory: " + entryDirectory);
  15. }
  16. resourceFile.createNewFile();
  17. try (InputStream in = child.getAsset().openStream(); OutputStream out = new FileOutputStream(resourceFile)) {
  18. copy(in, out);
  19. }
  20. child.getPath().get();
  21. }
  22. }
  23. }

代码示例来源:origin: shrinkwrap/shrinkwrap

  1. private int countChildren(final Node node) {
  2. int count = 0;
  3. for (final Node child : node.getChildren()) {
  4. if (child.getAsset() != null) {
  5. count++;
  6. }
  7. count += countChildren(child);
  8. }
  9. return count;
  10. }

代码示例来源:origin: shrinkwrap/shrinkwrap

  1. /**
  2. * Asserts that the archive recursively contains the specified file in the target starting from the base position.
  3. */
  4. private void assertArchiveContainsFolderRecursively(File file, ArchivePath base, String target) throws Exception {
  5. ArchivePath testPath = new BasicPath(base, target);
  6. Assert.assertTrue("Archive should contain " + testPath, this.getArchive().contains(testPath));
  7. if (file.isDirectory()) {
  8. for (File child : file.listFiles()) {
  9. assertArchiveContainsFolderRecursively(child, base, target + "/" + child.getName());
  10. }
  11. int folderInArchiveSize = this.getArchive().get(testPath).getChildren().size();
  12. Assert.assertEquals("Wrong number of files in the archive folder: " + testPath.get(),
  13. file.listFiles().length, folderInArchiveSize);
  14. }
  15. }

代码示例来源:origin: GoogleCloudPlatform/appengine-tck

  1. protected void handleWebArchive(WebArchive war) {
  2. final Node lib = war.get("WEB-INF/lib");
  3. if (lib != null) {
  4. final Set<Node> libs = lib.getChildren();
  5. for (Node jar : libs) {
  6. if (jar.getPath().get().contains("appengine-api"))
  7. return;
  8. }
  9. }
  10. // do not add GAE jar; e.g. CapeDwarf can work off GAE module
  11. boolean ignoreGaeJar = Boolean.getBoolean("ignore.gae.jar");
  12. if (ignoreGaeJar == false) {
  13. war.addAsLibraries(Maven.resolver()
  14. .loadPomFromFile("pom.xml")
  15. .resolve("com.google.appengine:appengine-api-1.0-sdk")
  16. .withTransitivity()
  17. .as(File.class)
  18. );
  19. }
  20. }
  21. }

代码示例来源:origin: com.kumuluz.ee.testing/kumuluzee-arquillian-container

  1. /**
  2. * Explodes kumuluzee-loader library to root of the archive.
  3. *
  4. * @param javaArchive Archive with all jars in /WEB-INF/lib (war)
  5. */
  6. private static void explodeLoaderArchiveToRoot(JavaArchive javaArchive) {
  7. for (Node n : javaArchive.get("/WEB-INF/lib").getChildren()) {
  8. if (n.getAsset() instanceof ArchiveAsset &&
  9. ((ArchiveAsset) n.getAsset()).getArchive().getName().startsWith("kumuluzee-loader-")) {
  10. Archive<?> dependencyJar = ((ArchiveAsset) n.getAsset()).getArchive();
  11. LOG.fine("Found kumuluzee-loader archive: " + dependencyJar.getName());
  12. javaArchive.merge(dependencyJar);
  13. javaArchive.delete(n.getPath());
  14. break;
  15. }
  16. }
  17. }

代码示例来源:origin: com.kumuluz.ee.testing/kumuluzee-arquillian-container

  1. /**
  2. * Explodes archive marked with {@link ApplicationArchiveMarker} to root of the archive.
  3. *
  4. * @param javaArchive Archive with all jars in /WEB-INF/lib (war)
  5. */
  6. private static void explodeAppArchiveToRoot(JavaArchive javaArchive) {
  7. for (Node n : javaArchive.get("/WEB-INF/lib").getChildren()) {
  8. if (n.getAsset() instanceof ArchiveAsset) {
  9. Archive<?> dependencyJar = ((ArchiveAsset) n.getAsset()).getArchive();
  10. if (dependencyJar.contains(ApplicationArchiveMarker.MARKER_FILENAME)) {
  11. LOG.fine("Found application archive: " + dependencyJar.getName());
  12. dependencyJar.delete(ApplicationArchiveMarker.MARKER_FILENAME);
  13. javaArchive.merge(dependencyJar);
  14. javaArchive.delete(n.getPath());
  15. break;
  16. }
  17. }
  18. }
  19. }

代码示例来源:origin: com.kumuluz.ee.testing/kumuluzee-arquillian-container

  1. private static void copyDir(Archive<?> sourceArchive, Archive<?> targetArchive, String source, String target) {
  2. Node sourceNode = sourceArchive.get(source);
  3. if (sourceNode.getAsset() != null) {
  4. targetArchive.add(sourceNode.getAsset(), target);
  5. } else {
  6. for (Node child : sourceNode.getChildren()) {
  7. String childName = child.getPath().get().replaceFirst(child.getPath().getParent().get(), "");
  8. copyDir(sourceArchive, targetArchive,
  9. child.getPath().get(), ArchivePaths.create(target, childName).get());
  10. }
  11. }
  12. }
  13. }

相关文章