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

x33g5p2x  于2022-01-15 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(112)

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

Archive.get介绍

[英]Obtains the Node located at the specified path
[中]获取位于指定路径的节点

代码示例

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

private static Node getKeycloakJsonNodeFromWebInf(Archive<?> tmpArchive, String resourceName, boolean useForwardSlash) {
  String webInfPath = useForwardSlash ? "/WEB-INF" : "WEB-INF";
  if (!resourceName.startsWith("/")) {
    resourceName = "/" + resourceName;
  }
  Node jsonNode = tmpArchive.get(webInfPath + resourceName);
  if (jsonNode == null) {
    jsonNode = tmpArchive.get(webInfPath + "/classes" + resourceName);
  }
  return jsonNode;
}

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

public String format(Archive<?> archive) throws IllegalArgumentException {
  StringBuilder xml = new StringBuilder();
  xml.append("<?xml version=\"1.0\"?>\n<deployment")
    .append(" name=\"").append(archive.getName()).append("\"")
    .append(" testclass=\"").append(testClass.getName()).append("\"")
    .append(">\n");
  formatNode(archive.get(ArchivePaths.root()), xml);
  xml.append("</deployment>").append("\n");
  return xml.toString();
}

代码示例来源:origin: org.jboss.arquillian.container/arquillian-container-test-impl-base

public String format(Archive<?> archive) throws IllegalArgumentException {
  StringBuilder xml = new StringBuilder();
  xml.append("<?xml version=\"1.0\"?>\n<deployment")
    .append(" name=\"").append(archive.getName()).append("\"")
    .append(" testclass=\"").append(testClass.getName()).append("\"")
    .append(">\n");
  formatNode(archive.get(ArchivePaths.root()), xml);
  xml.append("</deployment>").append("\n");
  return xml.toString();
}

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

private static Node getKeycloakJsonNodeFromWebInf(Archive<?> tmpArchive, String resourceName, boolean useForwardSlash) {
  String webInfPath = useForwardSlash ? "/WEB-INF" : "WEB-INF";
  if (!resourceName.startsWith("/")) {
    resourceName = "/" + resourceName;
  }
  Node jsonNode = tmpArchive.get(webInfPath + resourceName);
  if (jsonNode == null) {
    jsonNode = tmpArchive.get(webInfPath + "/classes" + resourceName);
  }
  return jsonNode;
}

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

public void process() {
  if (archive.get("META-INF/arquillian-testable") == null) {
    return;
  }
  archive.add(new StringAsset(archive.getName()), "META-INF/arquillian-testable");
  archive.as(JARArchive.class)
      .addModule("org.wildfly.swarm.arquillian.adapter");
  archive.as(JARArchive.class)
      .addModule("org.wildfly.swarm.arquillian", "deployment");
  archive.as(ServiceActivatorArchive.class)
      .addServiceActivator("org.wildfly.swarm.arquillian.deployment.TestableArchiveServiceActivator");
}

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

/**
 * {@inheritDoc}
 *
 * @see org.jboss.shrinkwrap.api.Archive#get(org.jboss.shrinkwrap.api.ArchivePath)
 */
@Override
public Node get(ArchivePath path) {
  return this.getArchive().get(path);
}

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

public void process() {
  if (archive.get("META-INF/arquillian-testable") == null) {
    return;
  }
  archive.add(new StringAsset(archive.getName()), "META-INF/arquillian-testable");
  archive.as(JARArchive.class)
      .addModule("org.wildfly.swarm.arquillian.adapter");
  archive.as(JARArchive.class)
      .addModule("org.wildfly.swarm.arquillian", "deployment");
  archive.as(ServiceActivatorArchive.class)
      .addServiceActivator("org.wildfly.swarm.arquillian.deployment.TestableArchiveServiceActivator");
}

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

/**
 * {@inheritDoc}
 *
 * @see org.jboss.shrinkwrap.api.Archive#get(java.lang.String)
 */
@Override
public Node get(String path) throws IllegalArgumentException {
  return this.getArchive().get(path);
}

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

/**
 * {@inheritDoc}
 *
 * @see org.jboss.shrinkwrap.api.Archive#get(java.lang.String)
 */
@Override
public Node get(String path) throws IllegalArgumentException {
  return this.getArchive().get(path);
}

代码示例来源:origin: org.jboss.arquillian.osgi/arquillian-osgi-common

private Manifest getBundleManifest(Archive<?> archive) {
  try {
    Node node = archive.get(JarFile.MANIFEST_NAME);
    if (node == null)
      return null;
    Manifest manifest = new Manifest(node.getAsset().openStream());
    return manifest;
  } catch (Exception ex) {
    return null;
  }
}

代码示例来源:origin: org.wildfly/wildfly-arquillian-common

public static Manifest getManifest(Archive<?> archive) {
  try {
    Node node = archive.get(JarFile.MANIFEST_NAME);
    if (node != null && node.getAsset() != null) {
      return new Manifest(node.getAsset().openStream());
    }
  } catch (Exception ex) {
    throw new IllegalStateException("Cannot obtain manifest", ex);
  }
  return null;
}

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

private static boolean hasApplicationServletMapping(Archive<?> archive) {
  Node webXmlNode = archive.get(PATH_WEB_XML);
  if (webXmlNode != null) {
    return hasApplicationServletMapping(webXmlNode.getAsset());
  }
  return false;
}

代码示例来源:origin: org.jboss.arquillian.protocol/arquillian-protocol-osgi

private void validateBundleArchive(Archive<?> archive) throws Exception {
    Manifest manifest = null;
    Node node = archive.get(JarFile.MANIFEST_NAME);
    if (node != null) {
      manifest = new Manifest(node.getAsset().openStream());
    }
    OSGiManifestBuilder.validateBundleManifest(manifest);
  }
}

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

/**
 * {@inheritDoc}
 *
 * @see java.nio.file.attribute.BasicFileAttributes#isDirectory()
 */
@Override
public boolean isDirectory() {
  final ArchivePath archivePath = ArchivePaths.create(path.toString());
  Node node = archive.get(archivePath);
  return node.getAsset() == null;
}

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

/**
* {@inheritDoc}
* @see org.glassfish.api.deployment.archive.ReadableArchive#getEntry(java.lang.String)
*/
@Override
public InputStream getEntry(String path) throws IOException
{
 return this.getArchive().get(ArchivePaths.create(path)).getAsset().openStream();
}

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

private String readStringAsset(final ArchivePath path) throws IOException {
    Asset addedAsset = getArchive().get(path).getAsset();
    return new BufferedReader(new InputStreamReader(addedAsset.openStream())).readLine();
  }
}

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

@Test
public void moveDirectory() throws IOException {
  final String source = "dir";
  this.getArchive().addAsDirectory(source);
  final String dest = "newPath";
  final Path src = fs.getPath(source);
  final Path dst = fs.getPath(dest);
  final Path moved = Files.move(src, dst);
  Assert.assertEquals(dest, moved.toString());
  Assert.assertNull("Directory expected after move", this.getArchive().get(dest).getAsset());
}

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

@Test
public void shouldMoveAsset() {
  final Archive<JavaArchive> archive = ShrinkWrap.create(JavaArchive.class, "archive.jar");
  final String sourcePath = "path1";
  final String targetPath = "path2";
  archive.add(EmptyAsset.INSTANCE, sourcePath);
  archive.move(sourcePath, targetPath);
  Assert.assertEquals("The archive should have only one asset", 1, numAssets(archive));
  Assert.assertNotNull("The asset should be at the target path", archive.get(targetPath));
}

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

@Test
public void ensureShallowCopyOperatesOnNestedAssets() {
  Archive<T> archive = getArchive();
  Asset asset = new ClassLoaderAsset(NAME_TEST_PROPERTIES);
  archive.add(asset, "location/sublocation");
  Archive<T> copyArchive = archive.shallowCopy();
  Assert.assertTrue(copyArchive.contains("location"));
  Assert.assertTrue(copyArchive.contains("location/sublocation"));
  Assert.assertSame(copyArchive.get("location/sublocation").getAsset(), archive.get("location/sublocation")
    .getAsset());
}

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

@Test
@ArchiveType(ManifestContainer.class)
public void testAddServiceProviderString() throws Exception {
  String[] impls = { "do.not.exist.impl.Dummy1", "do.not.exist.impl.Dummy2", "do.not.exist.impl.Dummy3" };
  String serviceInterface = "do.not.exist.api.Dummy";
  getManifestContainer().addAsServiceProvider(serviceInterface, impls);
  ArchivePath testPath = new BasicPath(getManifestPath(), "services/" + serviceInterface);
  Assert.assertTrue("Archive should contain " + testPath, getArchive().contains(testPath));
  assertServiceProviderContent(getArchive().get(testPath), impls);
}

相关文章