本文整理了Java中org.jboss.shrinkwrap.api.exporter.ZipExporter
类的一些代码示例,展示了ZipExporter
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipExporter
类的具体详情如下:
包路径:org.jboss.shrinkwrap.api.exporter.ZipExporter
类名称:ZipExporter
[英]Exporter used to represent an Assignable in ZIP format.
[中]Exporter用于以ZIP格式表示可分配项。
代码示例来源:origin: crashub/crash
public void testDuplicateResource() throws Exception {
java.io.File file = java.io.File.createTempFile("test", ".jar");
file.deleteOnExit();
JavaArchive jar = ShrinkWrap.create(JavaArchive.class);
jar.addClass(FSTestCase.class);
jar.as(ZipExporter.class).exportTo(file, true);
URLDriver driver = new URLDriver();
driver.merge(file.toURI().toURL());
driver.merge(file.toURI().toURL());
Node node = driver.child(driver.child(driver.child(driver.child(driver.root(), "org"), "crsh"), "vfs"), "FSTestCase.class");
Iterator<InputStream> i = driver.open(node);
assertTrue(i.hasNext());
i.next();
assertTrue(i.hasNext());
i.next();
assertFalse(i.hasNext());
}
代码示例来源:origin: cbeust/testng
public static File generateJar(
Class<?>[] classes, String[] resources, String prefix, String archiveName)
throws IOException {
File jarFile = File.createTempFile(prefix, ".jar");
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, archiveName).addClasses(classes);
for (String resource : resources) {
archive = archive.addAsResource(resource);
}
archive.as(ZipExporter.class).exportTo(jarFile, true);
return jarFile;
}
代码示例来源:origin: org.wildfly.swarm/container
File getFile(Entry entry) {
if (entry.file == null) {
try {
entry.file = this.tempDir.createFile(entry.archive.getName(), entry.archive.as(ZipExporter.class).exportAsInputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
return entry.file;
}
代码示例来源:origin: org.infinispan.server/infinispan-server-testsuite
@BeforeClass
public static void before() throws Exception {
JavaArchive deployedCacheStore = ShrinkWrap.create(JavaArchive.class);
deployedCacheStore.addPackage(MyCustomCacheStore.class.getPackage());
deployedCacheStore.addAsServiceProvider(ExternalStore.class, MyCustomCacheStore.class);
deployment = new File(System.getProperty("server1.dist"), "/standalone/deployments/custom-store.jar");
deployedCacheStore.as(ZipExporter.class).exportTo(deployment, true);
}
代码示例来源:origin: crashub/crash
@Override
protected void setUp() throws Exception {
java.io.File warFile = java.io.File.createTempFile("test", ".war");
warFile.deleteOnExit();
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "foo.jar");
jar.addClass(FSTestCase.class);
WebArchive war = ShrinkWrap.create(WebArchive.class);
war.addAsLibraries(jar);
ZipExporter exporter = war.as(ZipExporter.class);
exporter.exportTo(warFile, true);
this.warFile = warFile;
}
代码示例来源:origin: crashub/crash
public static File toFile(Archive archive, String ext) {
File tmp = assertTmpFile(ext);
if (tmp.delete()) {
ZipExporter exporter = archive.as(ZipExporter.class);
exporter.exportTo(tmp);
tmp.deleteOnExit();
return tmp;
} else {
throw failure("Could not delete tmp file " + tmp.getAbsolutePath());
}
}
代码示例来源:origin: org.wildfly/wildfly-testsuite-shared
/**
* Exports given archive to the given folder.
*
* @param archive archive to export (not-<code>null</code>)
* @param folderPath
*/
public static void saveArchiveToFolder(Archive<?> archive, String folderPath) {
final File exportFile = new File(folderPath, archive.getName());
LOGGER.trace("Exporting archive: " + exportFile.getAbsolutePath());
archive.as(ZipExporter.class).exportTo(exportFile, true);
}
代码示例来源:origin: org.infinispan.server/infinispan-server-testsuite
@BeforeClass
public static void before() throws Exception {
String serverDir = System.getProperty("server1.dist");
JavaArchive jar = ShrinkWrap.create(JavaArchive.class);
jar.addClass(LocalTestServerTask.class);
jar.addClass(LocalExceptionalServerTask.class);
jar.addClass(LocalMapReduceServerTask.class);
jar.addClass(JSExecutingServerTask.class);
jar.addClass(GreetingServerTask.class);
jar.addClass(Greeting.class);
jar.addAsServiceProvider(ServerTask.class, LocalTestServerTask.class,
LocalExceptionalServerTask.class, LocalMapReduceServerTask.class, JSExecutingServerTask.class, GreetingServerTask.class);
jar.addAsResource(new File("/stream_serverTask.js"));
jar.addAsManifestResource("MANIFEST.MF");
File f = new File(serverDir, "/standalone/deployments/custom-task.jar");
jar.as(ZipExporter.class).exportTo(f, true);
}
代码示例来源:origin: org.wildfly.swarm/tools
public void repackageWar(File file) throws IOException {
this.log.info("Repackaging .war: " + file);
Path backupPath = get(file);
move(file, backupPath, this.log);
Archive original = ShrinkWrap.create(JavaArchive.class);
try (InputStream inputStream = Files.newInputStream(backupPath)) {
original.as(ZipImporter.class).importFrom(inputStream);
}
WebInfLibFilteringArchive repackaged = new WebInfLibFilteringArchive(original, this.dependencyManager);
repackaged.as(ZipExporter.class).exportTo(file, true);
this.log.info("Repackaged .war: " + file);
}
代码示例来源:origin: org.infinispan.server/infinispan-server-testsuite
@BeforeClass
public static void deploy() throws IOException {
String protoFile = Util.getResourceAsString("/sample_bank_account/bank.proto", HotRodCustomMarshallerIteratorIT.class.getClassLoader());
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, FILTER_MARSHALLER_DEPLOYMENT_JAR)
// Add custom marshaller classes
.addClasses(HotRodClientException.class, UserMarshaller.class, GenderMarshaller.class, User.class, Address.class)
// Add marshaller dependencies
.add(new StringAsset(protoFile), "/sample_bank_account/bank.proto")
.add(new StringAsset("Dependencies: org.infinispan.protostream, org.infinispan.remote-query.client"), "META-INF/MANIFEST.MF")
.addClass(ServerCtxInitializer.class)
.addAsServiceProvider(ProtostreamSerializationContextInitializer.class, ServerCtxInitializer.class)
// Add custom filterConverter classes
.addClasses(CustomFilterFactory.class, CustomFilterFactory.CustomFilter.class, ParamCustomFilterFactory.class,
ParamCustomFilterFactory.ParamCustomFilter.class)
// Register custom filterConverterFactories
.addAsServiceProviderAndClasses(KeyValueFilterConverterFactory.class, ParamCustomFilterFactory.class, CustomFilterFactory.class);
File deployment = new File(System.getProperty("server1.dist"), "/standalone/deployments/" + FILTER_MARSHALLER_DEPLOYMENT_JAR);
archive.as(ZipExporter.class).exportTo(deployment, true);
}
代码示例来源:origin: org.infinispan.server/infinispan-server-testsuite
@BeforeClass
public static void before() {
// We put the entity class in one jar and the marshaller in another jar, just to make things more interesting.
JavaArchive entityArchive = ShrinkWrap.create(JavaArchive.class)
.addClasses(TestEntity.class)
.add(new StringAsset("Dependencies: org.hibernate.search.engine"), "META-INF/MANIFEST.MF"); // we need the Hibernate Search annotations
JavaArchive marshallerArchive = ShrinkWrap.create(JavaArchive.class)
.addClasses(CustomCompatModeMarshaller.class)
.add(new StringAsset("Dependencies: org.jboss.marshalling, " +
"org.infinispan.commons, " +
"org.infinispan.remote-query.client, " +
"deployment.custom-test-entity.jar"), // We depend on the jar containing the entity, so we can instantiate it.
"META-INF/MANIFEST.MF")
.addAsServiceProvider(Marshaller.class, CustomCompatModeMarshaller.class);
File deployment1 = new File(System.getProperty("server1.dist"), "/standalone/deployments/custom-test-entity.jar");
entityArchive.as(ZipExporter.class).exportTo(deployment1, true);
deployments.add(deployment1);
File deployment2 = new File(System.getProperty("server1.dist"), "/standalone/deployments/custom-compat-marshaller.jar");
marshallerArchive.as(ZipExporter.class).exportTo(deployment2, true);
deployments.add(deployment2);
}
代码示例来源:origin: org.juzu/juzu-core
private File explode(File targetDir, JavaArchive classes, JavaArchive lib) {
WebArchive archive = ShrinkWrap.create(WebArchive.class);
archive.merge(classes, "WEB-INF/classes");
archive.addAsDirectory("WEB-INF/lib");
File explodedDir = archive.as(ExplodedExporter.class).exportExploded(targetDir);
File libJar = new File(explodedDir, "WEB-INF/lib/lib.jar");
lib.as(ZipExporter.class).exportTo(libJar);
return explodedDir;
}
代码示例来源:origin: hibernate/hibernate-ogm
public PackagingRule(String persistenceConfResource, Class<?>... entities) {
try {
create();
archive = ShrinkWrap.create( JavaArchive.class, "jtastandalone.jar" );
archive.addClasses( entities );
archive.addAsManifestResource( persistenceConfResource, persistencePath );
testPackage = newFile();
}
catch ( IOException e ) {
throw new RuntimeException( e );
}
archive.as( ZipExporter.class ).exportTo( testPackage, true );
try {
URL url = testPackage.toURL();
classLoader = new URLClassLoader( new URL[]{ url }, originalClassLoader );
}
catch (MalformedURLException e) {
throw new RuntimeException( e );
}
}
代码示例来源:origin: org.jboss.as/jboss-as-demos-legacy
public Deployment(String archiveName, Package pkg, boolean show) {
this.archiveName = archiveName;
ArchivePath metaInf = ArchivePaths.create("META-INF");
archive = ShrinkWrap.create(JavaArchive.class, archiveName);
archive.addPackage(pkg);
File sourceMetaInf = getSourceMetaInfDir();
addFiles(archive, sourceMetaInf, metaInf);
System.out.println(archive.toString(show));
realArchive = new File(getOutputDir(), archive.getName());
archive.as(ZipExporter.class).exportTo(realArchive, true);
}
代码示例来源:origin: uk.co.qorr/hvalspik-deployables-war
public WarDeployable build() {
File warFile = new File(workingDir, name + ".war");
WebArchive war = ShrinkWrap.create(WebArchive.class, name + ".war");
packages.forEach(war::addPackage);
war.setWebXML(new File(webXml));
war.addAsLibraries(dependencies);
LOG.debug("Built WAR Deployable: {}", war.toString(true));
war.as(ZipExporter.class).exportTo(warFile, true);
return new WarDeployable(warFile);
}
代码示例来源:origin: org.jboss.osgi/jboss-osgi-spi
public static VirtualFile toVirtualFile(Archive<?> archive) throws IOException, MalformedURLException
{
ZipExporter exporter = archive.as(ZipExporter.class);
return AbstractVFS.toVirtualFile(archive.getName(), exporter.exportZip());
}
代码示例来源:origin: crashub/crash
@Override
public ClassLoader getClassLoader(final JavaArchive jar) throws Exception {
WebArchive war = ShrinkWrap.create(WebArchive.class);
war.setManifest(Thread.currentThread().getContextClassLoader().getResource("META-INF/MANIFEST.MF"));
war.addAsLibrary(jar);
final File tmp = File.createTempFile("crash", ".war");
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: wildfly-swarm-archive/ARCHIVE-wildfly-swarm
@Override
public InputStream openStream() {
return filter(ShrinkWrap.create(ZipImporter.class)
.importFrom(this.delegate.openStream())
.as(JavaArchive.class))
.as(ZipExporter.class)
.exportAsInputStream();
}
代码示例来源:origin: thorntail/thorntail
@Override
public InputStream openInputStream(VirtualFile mountPoint, VirtualFile target) throws IOException {
return getEntry(mountPoint, target)
.map(e -> e.archive.as(ZipExporter.class).exportAsInputStream()).orElse(null);
}
代码示例来源:origin: shrinkwrap/shrinkwrap
/**
* Test to ensure that the {@link ZipExporter} does not accept an empty archive as input
*
* SHRINKWRAP-93
*
* @throws Exception
*/
@Test(expected = IllegalArgumentException.class)
public void exportEmptyArchiveAsZip() throws Exception {
// Attempt to export an empty archive, should fail
ShrinkWrap.create(JavaArchive.class, NAME_ARCHIVE).as(ZipExporter.class).exportAsInputStream();
}
内容来源于网络,如有侵权,请联系作者删除!