org.jboss.shrinkwrap.api.asset.Asset.openStream()方法的使用及代码示例

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

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

Asset.openStream介绍

[英]Get a input stream for the resource content. The caller is responsible for closing the stream.
[中]获取资源内容的输入流。调用方负责关闭流。

代码示例

代码示例来源:origin: oracle/helidon

Files.copy(n.getAsset().openStream(), f, StandardCopyOption.REPLACE_EXISTING);

代码示例来源:origin: crashub/crash

assertTrue(tmp.delete());
war.as(ZipExporter.class).exportTo(tmp);
final byte[] bytes = Utils.readAsBytes(jar.get("foo/A.class").getAsset().openStream());
return new ClassLoader(Thread.currentThread().getContextClassLoader()) {
 Class<?> aClass = null;

代码示例来源:origin: org.apache.openejb/arquillian-openejb-embedded-4

@Override
  public InputStream get() throws IOException {
    return asset.openStream();
  }
}

代码示例来源:origin: org.apache.openejb/arquillian-openejb-embedded-4

@Override
  public InputStream getInputStream() throws IOException {
    final InputStream input = asset.openStream();
    final Collection<Closeable> c = closeables.get(arName);
    c.add(input);
    return input;
  }
};

代码示例来源:origin: org.apache.tomee/arquillian-openejb-embedded

@Override
  public InputStream getInputStream() throws IOException {
    final InputStream input = asset.openStream();
    final Collection<Closeable> c = closeables.get(arName);
    c.add(input);
    return input;
  }
};

代码示例来源:origin: org.agiso.tempel/tempel-support-test

@Override
  public InputStream getInputStream() throws Exception {
    return jarEntry.getAsset().openStream();
  }
}

代码示例来源:origin: org.jboss.arquillian.extension/arquillian-jacoco

public InputStream openStream() {
    try {
      ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
      JACOCO_SIG_REMOVER.filterEntry("META-INF/MANIFEST.MF", asset.openStream(), out);

      return new ByteArrayInputStream(out.toByteArray());
    } catch (Exception e) {
      throw new RuntimeException("Could not instrument MANIFEST.MF Asset " + asset, e);
    }
  }
}

代码示例来源: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: org.jboss.as/jboss-as-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: org.jboss.arquillian.extension/arquillian-jacoco

public InputStream openStream() {
    try {
      final IRuntime runtime = ArquillianRuntime.getInstance();
      final Instrumenter instrumenter = new Instrumenter(runtime);
      final byte[] instrumented = instrumenter.instrument(asset.openStream(), EX_STRING);
      return new ByteArrayInputStream(instrumented);
    } catch (Exception e) {
      throw new RuntimeException("Could not instrument Asset " + asset, e);
    }
  }
}

代码示例来源: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.arquillian.osgi/arquillian-osgi-protocol

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-extension-glassfish

@Override
public Manifest getManifest() throws IOException
{
 ArchivePath manifestPath = ArchivePaths.create("META-INF/MANIFEST.MF");
 final Archive<?> archive = this.getArchive();
 if (archive.contains(manifestPath))
 {
   return new Manifest(archive.get(manifestPath).getAsset().openStream());
 }
 return 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

@Test
public void shouldBeAbleToReadFile() throws Exception {
  Asset asset = new FileAsset(new File(EXISTING_FILE));
  InputStream io = asset.openStream();
  Assert.assertNotNull(io);
  Assert.assertEquals("Should be able to read the content of the resource", "shrinkwrap=true",
    ApiTestUtils.convertToString(io));
}

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

@Test
public void shouldBeAbleToReadResource() throws Exception {
  Asset asset = new ClassLoaderAsset(EXISTING_RESOURCE);
  InputStream io = asset.openStream();
  Assert.assertNotNull(io);
  Assert.assertEquals("Should be able to read the content of the resource", "shrinkwrap=true",
    ApiTestUtils.convertToString(io));
}

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

@Override
public void undeploy(Archive<?> archive) throws DeploymentException {
  try {
    Manifest manifest = new Manifest(archive.get("/META-INF/MANIFEST.MF").getAsset().openStream());
    OSGiMetaData metadata = OSGiMetaDataBuilder.load(manifest);
    undeploy(metadata.getBundleSymbolicName());
  }
  catch (IOException e) {
    throw new DeploymentException("Cannot undeploy: " + archive.getName(), e);
  }
}

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

@Test
public void shouldBeAbleToReadURL() throws Exception {
  Asset asset = new UrlAsset(getThreadContextClassLoader().getResource(EXISTING_RESOURCE));
  InputStream io = asset.openStream();
  Assert.assertNotNull(io);
  Assert.assertEquals("Should be able to read the content of the resource", "shrinkwrap=true",
    ApiTestUtils.convertToString(io));
}

代码示例来源:origin: org.juzu/juzu-core

public static WebArchive createDeployment(String packageName) throws IOException {
 WebArchive war = createPortletDeployment(packageName);
 Node node = war.get("WEB-INF/portlet.xml");
 ArchivePath path = node.getPath();
 String s = Tools.read(node.getAsset().openStream(), Tools.UTF_8);
 s = s.replace("<portlet-info>", "<resource-bundle>bundle</resource-bundle>" + "<portlet-info>");
 war.delete(path);
 war.add(new StringAsset(s), path);
 war.addAsResource(new StringAsset("abc=def"), "bundle_fr_FR.properties");
 return war;
}

相关文章

微信公众号

最新文章

更多

Asset类方法