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;
@Override public InputStream getInputStream() throws Exception { return jarEntry.getAsset().openStream(); } }
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; }
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; }
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; } }
@Override public Manifest getManifest(JavaArchive javaArchive) throws IOException { Node manifestNode = javaArchive.get(JarFile.MANIFEST_NAME); Asset manifestAsset = manifestNode.getAsset(); return new Manifest(manifestAsset.openStream()); }
public void removeManifestDigests(Archive<?> archive) { Map<ArchivePath, Node> manifests = getManifestFiles(archive); for (Entry<ArchivePath, Node> entry : manifests.entrySet()) { Asset original = entry.getValue().getAsset(); archive.delete(entry.getKey()); archive.add(new ManifestAsset(original), entry.getKey()); } }
private static boolean hasApplicationPathAnnotation(Archive<?> archive) { Map<ArchivePath, Node> content = archive.getContent(); for (Map.Entry<ArchivePath, Node> entry : content.entrySet()) { Node node = entry.getValue(); Asset asset = node.getAsset(); if (hasApplicationPathAnnotation(node.getPath(), asset)) { return true; } } return false; }
private static void addOpenEJbJarXml(final Archive<?> archive, final String prefix, final EjbModule ejbModule) { final Node openejbJarXml = archive.get(prefix.concat(OPENEJB_JAR_XML)); if (openejbJarXml != null) { ejbModule.getAltDDs().put(OPENEJB_JAR_XML, new AssetSource(openejbJarXml.getAsset(), null)); } }
@Override public List<String> getBundleActivators(Archive archive, String fileName) throws IOException { Node node = archive.get(fileName); List<String> bundleActivators = new ArrayList<>(); if (node != null) { Asset asset = node.getAsset(); bundleActivators.addAll(_getBundleActivators(asset.openStream())); } return bundleActivators; }
private void format(StringBuilder sb, Node node) { sb.append(node.getPath().get()); if (node.getAsset() == null) { sb.append(FormattingConstants.SLASH); } sb.append(FormattingConstants.NEWLINE); for (Node child : node.getChildren()) { format(sb, child); } }
private void format(StringBuilder sb, Node node) { sb.append(node.getPath().get()); if (node.getAsset() == null) { sb.append(FormattingConstants.SLASH); } sb.append(FormattingConstants.NEWLINE); for (Node child : node.getChildren()) { format(sb, child); } }
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); } }
private void unpack(File destination, JavaArchive file) throws IOException { final Node rootDir = file.get("/"); final Set<Node> contractFiles = rootDir.getChildren(); for (Node contractFile : contractFiles) { final String filename = contractFile.getPath().get().substring(1); final Asset asset = contractFile.getAsset(); try (final InputStream in = asset.openStream()) { Files.copy(in, new File(destination, filename).toPath()); } } }
/** * {@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; }
protected void assertServiceProviderContent(Node node, String[] impls) throws IOException { BufferedReader reader = createReader(node.getAsset()); try { for (String impl : impls) { Assert.assertEquals("Wrong entry in service provider: " + impl, impl, reader.readLine()); } } finally { reader.close(); } }
@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; }
@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); } }
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; }