gpt4 book ai didi

org.jboss.shrinkwrap.api.importer.ZipImporter类的使用及代码示例

转载 作者:知者 更新时间:2024-03-16 13:40:40 28 4
gpt4 key购买 nike

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

ZipImporter介绍

[英]Assignable type capable of importing ZIP content.
[中]能够导入ZIP内容的可分配类型。

代码示例

代码示例来源:origin: javaee/security-soteria

public static WebArchive mavenWar() {
  return 
    create(ZipImporter.class, getProperty("finalName") + ".war")
      .importFrom(new File("target/" + getProperty("finalName") + ".war"))
      .as(WebArchive.class);
}

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

protected static Stream<Archive> archives(Collection<Path> paths) {
  return paths.stream()
      .map(path -> {
        String simpleName = path.getFileName().toString();
        Archive archive = ShrinkWrap.create(JavaArchive.class, simpleName);
        archive.as(ZipImporter.class).importFrom(path.toFile());
        return archive;
      });
}

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

/**
   * SHRINKWRAP-259
   */
  @Test
  public void createZipImporter() {
    final GenericArchive importer = ShrinkWrap.create(ZipImporter.class).as(GenericArchive.class);
    Assert.assertTrue("Archive did not have expected suffix", importer.getName().endsWith(".jar"));
  }
}

代码示例来源:origin: org.jboss.arquillian.testenricher/arquillian-testenricher-jmx

@Override
public Archive<?> getClientDeployment(String name)
{
 InputStream input = getClientDeploymentAsStream(name);
 ClassLoader ctxLoader = SecurityActions.getThreadContextClassLoader();
 try
 {
   // Create the archive in the context of the arquillian-osgi-bundle
   SecurityActions.setThreadContextClassLoader(ArchiveBase.class.getClassLoader());
   JavaArchive archive = ShrinkWrap.create(JavaArchive.class, name);
   ZipImporter zipImporter = archive.as(ZipImporter.class);
   zipImporter.importZip(new ZipInputStream(input));
   return archive;
 }
 finally
 {
   SecurityActions.setThreadContextClassLoader(ctxLoader);
 }
}

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

protected boolean setupUsingAppArtifact(Archive<?> archive) throws IOException {
  final String appArtifact = System.getProperty(APP_ARTIFACT);
  if (appArtifact != null) {
    try (InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream("_bootstrap/" + appArtifact)) {
      archive.as(ZipImporter.class)
          .importFrom(in);
    }
    return true;
  }
  return false;
}

代码示例来源:origin: org.jboss.arquillian.daemon/arquillian-daemon-server

@Override
  public void inboundBufferUpdated(final ChannelHandlerContext ctx, final ByteBuf in) throws Exception {
    if (log.isLoggable(Level.FINEST)) {
      log.finest("Using the " + this.getClass().getSimpleName());
    }
    try {
      // Read in the archive using the isolated CL context of this domain
      final InputStream instream = new ByteBufInputStream(in);
      final GenericArchive archive = NettyServer.this.getShrinkwrapDomain().getArchiveFactory()
        .create(ZipImporter.class).importFrom(instream).as(GenericArchive.class);
      instream.close();
      if (log.isLoggable(Level.FINEST)) {
        log.finest("Got archive: " + archive.toString(true));
      }
      // Store the archive
      final String id = archive.getId();
      NettyServer.this.getDeployedArchives().put(id, archive);
      // Tell the client OK, and let it know the ID of the archive (so it may be undeployed)
      final ByteBuf out = ctx.nextOutboundByteBuffer();
      NettyServer.sendResponse(ctx, out, WireProtocol.RESPONSE_OK_PREFIX + WireProtocol.COMMAND_DEPLOY_PREFIX
        + id);
    } finally {
      NettyServer.this.resetPipeline(ctx.pipeline());
    }
  }
}

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

protected static Stream<Archive> archives(Collection<Path> paths) {
  return paths.stream()
      .map(path -> {
        String simpleName = path.getFileName().toString();
        Archive archive = ShrinkWrap.create(JavaArchive.class, simpleName);
        archive.as(ZipImporter.class).importFrom(path.toFile());
        return archive;
      });
}

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

protected boolean setupUsingAppArtifact(Archive<?> archive) throws IOException {
  final String appArtifact = System.getProperty(APP_ARTIFACT);
  if (appArtifact != null) {
    try (InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream("_bootstrap/" + appArtifact)) {
      archive.as(ZipImporter.class)
          .importFrom(in);
    }
    return true;
  }
  return false;
}

代码示例来源:origin: org.glassfish.soteria.test/common

public static WebArchive mavenWar() {
  return 
    create(ZipImporter.class, getProperty("finalName") + ".war")
      .importFrom(new File("target/" + getProperty("finalName") + ".war"))
      .as(WebArchive.class);
}

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

protected static Stream<Archive> archives(Collection<Path> paths) {
  return paths.stream()
      .map(path -> {
        String simpleName = path.getFileName().toString();
        Archive archive = ShrinkWrap.create(JavaArchive.class, simpleName);
        archive.as(ZipImporter.class).importFrom(path.toFile());
        return archive;
      });
}

代码示例来源:origin: wildfly-swarm-archive/ARCHIVE-wildfly-swarm

protected boolean setupUsingAppArtifact(Archive<?> archive) throws IOException {
  final String appArtifact = System.getProperty(BootstrapProperties.APP_ARTIFACT);
  if (appArtifact != null) {
    try (InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream("_bootstrap/" + appArtifact)) {
      archive.as(ZipImporter.class)
          .importFrom(in);
    }
    return true;
  }
  return false;
}

代码示例来源:origin: org.wildfly.swarm/container-api

public JavaArchive artifact(String gav, String asName) throws IOException, ModuleLoadException {
  final File file = findFile(gav);
  if (file == null) {
    throw new RuntimeException("Artifact '" + gav + "' not found.");
  }
  return ShrinkWrap.create(ZipImporter.class, asName == null ? file.getName() : asName)
      .importFrom(file)
      .as(JavaArchive.class);
}

代码示例来源:origin: org.jboss.jbossas.as7-cdi-tck/jbossas-container

public boolean deploy(InputStream archive, String name) throws IOException {
  exception = null;
  if (name.endsWith("ear")) {
    swArchive = ShrinkWrap.create(EnterpriseArchive.class, name);
  } else if (name.endsWith("war")) {
    swArchive = ShrinkWrap.create(WebArchive.class, name);
  } else if (name.endsWith("jar")) {
    swArchive = ShrinkWrap.create(JavaArchive.class, name);
  } else {
    throw new RuntimeException("Unkown archive extension: " + name);
  }
  swArchive.as(ZipImporter.class).importFrom(archive);
  try {
    deployableContainer.deploy(this.swArchive);
    return true;
  } catch (org.jboss.arquillian.container.spi.client.container.DeploymentException e) {
    exception = e;
    return false;
  }
}

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

protected boolean setupUsingAppPath(Archive<?> archive) throws IOException {
  final String appPath = System.getProperty(APP_PATH);
  if (appPath != null) {
    final Path path = Paths.get(appPath);
    if (Files.isDirectory(path)) {
      Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
          Path simple = path.relativize(file);
          archive.add(new FileAsset(file.toFile()), convertSeparators(simple));
          return super.visitFile(file, attrs);
        }
      });
    } else {
      archive.as(ZipImporter.class)
          .importFrom(path.toFile());
    }
    return true;
  }
  return false;
}

代码示例来源:origin: wildfly-swarm-archive/ARCHIVE-wildfly-swarm

public JavaArchive artifact(String gav, String asName) throws IOException, ModuleLoadException {
  final File file = findFile(gav);
  if (file == null) {
    throw new RuntimeException("Artifact not found.");
  }
  return ShrinkWrap.create(ZipImporter.class, asName == null ? file.getName() : asName)
      .importFrom(file)
      .as(JavaArchive.class);
}

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

private InputStream getKeycloakJson(URI keycloakJsonUri) {
  final String resourceName = keycloakJsonUri != null && "classpath".equals(keycloakJsonUri.getScheme())
    ? keycloakJsonUri.getSchemeSpecificPart() : "keycloak.json";
  InputStream keycloakJson = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
  if (keycloakJson == null) {
    String appArtifact = System.getProperty(BootstrapProperties.APP_ARTIFACT);
    if (appArtifact != null) {
      try (InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream("_bootstrap/" + appArtifact)) {
        Archive<?> tmpArchive = ShrinkWrap.create(JARArchive.class);
        tmpArchive.as(ZipImporter.class).importFrom(in);
        Node jsonNode = tmpArchive.get(resourceName);
        if (jsonNode == null) {
          jsonNode = getKeycloakJsonNodeFromWebInf(tmpArchive, resourceName, true);
        }
        if (jsonNode == null) {
          jsonNode = getKeycloakJsonNodeFromWebInf(tmpArchive, resourceName, false);
        }
        if (jsonNode != null && jsonNode.getAsset() != null) {
          keycloakJson = jsonNode.getAsset().openStream();
        }
      } catch (IOException e) {
        // ignore
      }
    }
  }
  return keycloakJson;
}

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

protected boolean setupUsingAppPath(Archive<?> archive) throws IOException {
  final String appPath = System.getProperty(APP_PATH);
  if (appPath != null) {
    final Path path = Paths.get(appPath);
    if (Files.isDirectory(path)) {
      Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
          Path simple = path.relativize(file);
          archive.add(new FileAsset(file.toFile()), convertSeparators(simple));
          return super.visitFile(file, attrs);
        }
      });
    } else {
      archive.as(ZipImporter.class)
          .importFrom(path.toFile());
    }
    return true;
  }
  return false;
}

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

@Override
  public <TYPE extends Assignable> TYPE as(Class<TYPE> typeClass) {
    try {
      ByteArrayOutputStream baos = new ByteArrayOutputStream();

      jar.write(baos);

      return ShrinkWrap.create(ZipImporter.class).
          importFrom(new ByteArrayInputStream(baos.toByteArray())).
          as(typeClass);

    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
}

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

private static InputStream getKeycloakJsonFromClasspath(String resourceName) {
  InputStream keycloakJson = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName);
  if (keycloakJson == null) {
    String appArtifact = System.getProperty(BootstrapProperties.APP_ARTIFACT);
    if (appArtifact != null) {
      try (InputStream in = ClassLoader.getSystemClassLoader().getResourceAsStream("_bootstrap/" + appArtifact)) {
        Archive<?> tmpArchive = ShrinkWrap.create(JARArchive.class);
        tmpArchive.as(ZipImporter.class).importFrom(in);
        Node jsonNode = tmpArchive.get(resourceName);
        if (jsonNode == null) {
          jsonNode = getKeycloakJsonNodeFromWebInf(tmpArchive, resourceName, true);
        }
        if (jsonNode == null) {
          jsonNode = getKeycloakJsonNodeFromWebInf(tmpArchive, resourceName, false);
        }
        if (jsonNode != null && jsonNode.getAsset() != null) {
          keycloakJson = jsonNode.getAsset().openStream();
        }
      } catch (IOException e) {
        // ignore
      }
    }
  }
  return keycloakJson;
}

代码示例来源:origin: wildfly-swarm-archive/ARCHIVE-wildfly-swarm

protected boolean setupUsingAppPath(Archive<?> archive) throws IOException {
  final String appPath = System.getProperty(BootstrapProperties.APP_PATH);
  if (appPath != null) {
    final Path path = Paths.get(appPath);
    if (Files.isDirectory(path)) {
      Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
          Path simple = path.relativize(file);
          archive.add(new FileAsset(file.toFile()), convertSeparators(simple));
          return super.visitFile(file, attrs);
        }
      });
    } else {
      archive.as(ZipImporter.class)
          .importFrom(path.toFile());
    }
    return true;
  }
  return false;
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com