@Override public JavaArchive add(Asset asset, ArchivePath target, String name) throws IllegalArgumentException { return delegate.add(asset, target, name); }
protected static Archive<?> createFilterArchive() { return ShrinkWrap.create(JavaArchive.class, "filter.jar") .addClasses(StaticCacheEventFilterFactory.class, DynamicCacheEventFilterFactory.class, CustomPojoEventFilterFactory.class) .addAsServiceProvider(CacheEventFilterFactory.class, StaticCacheEventFilterFactory.class, DynamicCacheEventFilterFactory.class, CustomPojoEventFilterFactory.class) .add(new StringAsset("Dependencies: deployment.pojo.jar"), "META-INF/MANIFEST.MF"); }
@Override protected Archive<?> buildArchive() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "my.jar"); jar.addClass(DummyClassA.class); jar.add(new StringAsset("stuff"), "WEB-INF/classes/stuff.txt"); return jar; }
@BeforeClass public static void before() { JavaArchive programmaticSearchMappingProviderArchive = ShrinkWrap.create(JavaArchive.class) .addClass(TestSearchMappingFactory.class) .addClass(TestSearchMappingFactory.MySearchableEntity.class) .add(new StringAsset("Dependencies: org.infinispan.query, org.hibernate.search.engine"), "META-INF/MANIFEST.MF") .addAsServiceProvider(ProgrammaticSearchMappingProvider.class); deployment = new File(System.getProperty("server1.dist"), "/standalone/deployments/" + TEST_PROGRAMMATIC_SEARCH_MAPPING_PROVIDER_JAR); programmaticSearchMappingProviderArchive.as(ZipExporter.class).exportTo(deployment, true); }
protected static Archive<?> createKeyValueFilterConverterArchive() { return ShrinkWrap.create(JavaArchive.class, "key-value-filter-converter.jar") .addClasses(TestKeyValueFilterConverterFactory.class, SampleEntity.class, Summary.class, SampleEntity.SampleEntityExternalizer.class, Summary.SummaryExternalizer.class) .addAsServiceProvider(KeyValueFilterConverterFactory.class, TestKeyValueFilterConverterFactory.class) .add(new StringAsset("Dependencies: deployment.pojo.jar"), "META-INF/MANIFEST.MF"); }
@BeforeClass public static void before() { httpClient = HttpClients.createDefault(); String serverDir = System.getProperty("server1.dist"); JavaArchive jar = ShrinkWrap.create(JavaArchive.class).addClass(Currency.class) .add(new StringAsset("Dependencies: org.infinispan.commons"), "META-INF/MANIFEST.MF"); File f = new File(serverDir, DEPLOY_PATH); jar.as(ZipExporter.class).exportTo(f, true); }
private void doTestImport(ClassLoaderFactory factory) throws Exception { Compiler compiler = new Compiler(); List<JavaClassFileObject> files = compiler.compile("foo.A", "package foo;\n public class A {}"); assertEquals(1, files.size()); JavaClassFileObject aFile = files.get(0); JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "crash.jar"); jar.add(new ByteArrayAsset(aFile.getBytes()), "foo/A.class"); jar.setManifest(Thread.currentThread().getContextClassLoader().getResource("META-INF/MANIFEST.MF")); ClassLoader cl = factory.getClassLoader(jar); // compiler = new Compiler(cl); files = compiler.compile("B", "import foo.A;\n" + "public class B implements java.util.concurrent.Callable<A> {\n" + "public A call() {\n" + "return new A();\n" + "}\n" + "}"); assertEquals(1, files.size()); LoadingClassLoader loader = new LoadingClassLoader(cl, files); Class<?> B = loader.findClass("B"); Callable<?> asCallable = (Callable<?>)B.newInstance(); Object ret = asCallable.call(); assertNotNull(ret); Class<?> A = ret.getClass(); assertEquals("foo.A", A.getName()); assertEquals(cl, A.getClassLoader()); }
protected static Archive<?> createConverterArchive() { return ShrinkWrap.create(JavaArchive.class, "converter.jar") .addClasses(StaticCacheEventConverterFactory.class, DynamicCacheEventConverterFactory.class, CustomPojoEventConverterFactory.class, CustomEvent.class) .addAsServiceProvider(CacheEventConverterFactory.class, StaticCacheEventConverterFactory.class, DynamicCacheEventConverterFactory.class, CustomPojoEventConverterFactory.class) .add(new StringAsset("Dependencies: deployment.pojo.jar"), "META-INF/MANIFEST.MF"); }
@SuppressWarnings("UnusedParameters") private void addProjectAsset(ResolvedDependencies resolvedDependencies) { if (this.hollow) { return; } this.archive.add(new WebInfLibFilteringArchiveAsset(this.projectAsset, this.dependencyManager)); }
protected static Archive<?> createFilterConverterArchive() { return ShrinkWrap.create(JavaArchive.class, "filter-converter.jar") .addClasses(FilterConverterFactory.class, CustomEvent.class, CustomPojoFilterConverterFactory.class) .addAsServiceProvider(CacheEventFilterConverterFactory.class, FilterConverterFactory.class, CustomPojoFilterConverterFactory.class) .add(new StringAsset("Dependencies: deployment.pojo.jar"), "META-INF/MANIFEST.MF"); }
private void addManifest() throws IOException { UberJarManifestAsset manifest = new UberJarManifestAsset(this.mainClass); this.archive.add(manifest); }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { //System.err.println( basePath.relativize(file).toString() ); archive.add(new FileAsset(file.toFile()), basePath.relativize(file).toString()); return FileVisitResult.CONTINUE; } });
@SuppressWarnings("UnusedParameters") private void addProjectAsset(ResolvedDependencies resolvedDependencies) { if (this.hollow) { return; } this.archive.add(new WebInfLibFilteringArchiveAsset(this.projectAsset, this.dependencyManager)); }
private static JavaArchive generateWar(Archive<?> archive, List<String> deploymentLibraries) { JavaArchive javaArchive = archive.as(JavaArchive.class); Archive<?>[] requiredLibraries = RequiredLibraries.getRequiredLibraries(deploymentLibraries); Arrays.stream(requiredLibraries).forEach(f -> javaArchive.add(new ArchiveAsset(f, ZipExporter.class), "/WEB-INF/lib/" + f.getName())); return javaArchive; }
private ShrinkWrapFileAttributeView getAttributesView(final String pathName) { archive.add(EmptyAsset.INSTANCE, pathName); return Files.getFileAttributeView(this.fs.getPath(pathName), ShrinkWrapFileAttributeView.class, (LinkOption) null); } }
private void addWildFlyBootstrapConf() throws Exception { WildFlySwarmBootstrapConf bootstrapConf = this.dependencyManager.getWildFlySwarmBootstrapConf(); this.archive.add(new StringAsset(bootstrapConf.toString()), WildFlySwarmBootstrapConf.CLASSPATH_LOCATION); }
private void addWildFlySwarmApplicationConf() throws Exception { WildFlySwarmApplicationConf appConf = this.dependencyManager.getWildFlySwarmApplicationConf(this.projectAsset); this.archive.add(new StringAsset(appConf.toString()), WildFlySwarmApplicationConf.CLASSPATH_LOCATION); }
private void addWildFlySwarmApplicationManifest() { WildFlySwarmManifest manifest = this.dependencyManager.getWildFlySwarmManifest(); this.properties.put("swarm.uberjar.build.user", System.getProperty("user.name")); if (!this.hollow) { this.properties.put(BootstrapProperties.APP_ARTIFACT, this.projectAsset.getSimpleName()); } manifest.setProperties(this.properties); manifest.bundleDependencies(this.bundleDependencies); manifest.setMainClass(this.mainClass); manifest.setHollow(this.hollow); this.archive.add(new ByteArrayAsset(manifest.toString().getBytes(StandardCharsets.UTF_8)), WildFlySwarmManifest.CLASSPATH_LOCATION); }
private void addWildFlySwarmApplicationManifest() { WildFlySwarmManifest manifest = this.dependencyManager.getWildFlySwarmManifest(); this.properties.put("thorntail.uberjar.build.user", System.getProperty("user.name")); if (!this.hollow) { this.properties.put(BootstrapProperties.APP_ARTIFACT, this.projectAsset.getSimpleName()); } manifest.setProperties(this.properties); manifest.bundleDependencies(this.bundleDependencies); manifest.setMainClass(this.mainClass); manifest.setHollow(this.hollow); this.archive.add(new ByteArrayAsset(manifest.toString().getBytes(StandardCharsets.UTF_8)), WildFlySwarmManifest.CLASSPATH_LOCATION); }
@Test public void size() throws IOException { final int size = 1024; final Asset kiloAsset = new Asset() { @Override public InputStream openStream() { return new ByteArrayInputStream(new byte[size]); } }; final String path = "path"; this.archive.add(kiloAsset, path); Assert.assertEquals("Size not reported as expected", size, this.getAttributes(path, false).size()); }