Package java.util.jar

Examples of java.util.jar.JarInputStream


     */
    private void loadImplementationsInJar(Test test, String parent, File jarfile) {

        try {
            JarEntry entry;
            JarInputStream jarStream = new JarInputStream(new FileInputStream(jarfile));

            while ((entry = jarStream.getNextJarEntry()) != null) {
                String name = entry.getName();
                if (!entry.isDirectory() && name.startsWith(parent) && name.endsWith(".class")) {
                    addIfMatching(test, name);
                }
            }
View Full Code Here


     * @throws FileNotFoundException
     * @throws IOException
     */
    private static void mergeJar(JarOutputStream jarFile, String jar, String prefix, Map<String, String> contents)
            throws FileNotFoundException, IOException {
        JarInputStream jarInput = new JarInputStream(new FileInputStream(jar));
       
        mergeJar(jarFile, jarInput, prefix, contents);
    }
View Full Code Here

        mergeJar(jarFile, jarInput, prefix, contents);
    }
   
    private static void mergeJar(JarOutputStream jarFile, URL jar, String prefix, Map<String, String> contents)
    throws FileNotFoundException, IOException {
        JarInputStream jarInput = new JarInputStream(jar.openStream());

        mergeJar(jarFile, jarInput, prefix, contents);
    }
View Full Code Here

    public List<Artifact> scan(Contribution contribution) throws ContributionReadException {

        // Assume the URL references a JAR file
        try {
            URL url = new URL(contribution.getLocation());
            JarInputStream jar = new JarInputStream(IOHelper.openStream(url));
            try {
                Set<String> names = new HashSet<String>();
                while (true) {
                    JarEntry entry = jar.getNextJarEntry();
                    if (entry == null) {
                        // EOF
                        break;
                    }

                    String name = entry.getName();
                    if (name.length() != 0 && !name.startsWith(".")) {

                        // Trim trailing /
                        if (name.endsWith("/")) {
                            name = name.substring(0, name.length() - 1);
                        }

                        // Add the entry name
                        if (!names.contains(name)) {
                            names.add(name);

                            // Add parent folder names to the list too
                            for (;;) {
                                int s = name.lastIndexOf('/');
                                if (s == -1) {
                                    name = "";
                                } else {
                                    name = name.substring(0, s);
                                }
                                if (name.length() != 0 && !names.contains(name)) {
                                    names.add(name);
                                } else {
                                    break;
                                }
                            }
                        }
                    }
                }

                // Return list of artifacts
                List<Artifact> artifacts = new ArrayList<Artifact>();
                for(String uri : names) {
                    Artifact artifact = contributionFactory.createArtifact();
                    artifact.setURI(uri);
                    artifact.setLocation(getArtifactURL(contribution, uri).toString());
                   
                    artifacts.add(artifact);
                }
               
                contribution.getTypes().add(getContributionType());
                return artifacts;

            } finally {
                jar.close();
            }
        } catch (IOException e) {
            throw new ContributionReadException(e);
        }
    }
View Full Code Here

        genericTestResolve(jarName, conf, expectedMrids, null);
    }

    private void genericTestResolve(String jarName, String conf, ModuleRevisionId[] expectedMrids,
            ModuleRevisionId[] expected2Mrids) throws Exception {
        JarInputStream in = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/"
                + jarName));
        BundleInfo bundleInfo = ManifestParser.parseManifest(in.getManifest());
        bundleInfo.addArtifact(new BundleArtifact(false, new File("test/test-repo/bundlerepo/"
                + jarName).toURI(), null));
        DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(
            OSGiManifestParser.getInstance(), null, bundleInfo, profileProvider);
        ResolveReport resolveReport = ivy.resolve(md,
View Full Code Here

        }
        assertEquals(expected, actual);
    }

    private void genericTestFailingResolve(String jarName, String conf) throws Exception {
        JarInputStream in = new JarInputStream(new FileInputStream("test/test-repo/bundlerepo/"
                + jarName));
        BundleInfo bundleInfo = ManifestParser.parseManifest(in.getManifest());
        bundleInfo.addArtifact(new BundleArtifact(false, new File("test/test-repo/bundlerepo/"
                + jarName).toURI(), null));
        DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(
            OSGiManifestParser.getInstance(), null, bundleInfo, profileProvider);
        ResolveReport resolveReport = ivy.resolve(md,
View Full Code Here

            return jar(jarFile);
        } else {
            InputStream in = url.openStream();
            in = new BufferedInputStream(in);
            try {
                JarInputStream jarStream = new JarInputStream(in);
                return jar(jarStream);
            } finally {
                in.close();
            }
        }
View Full Code Here

    private static final String ATTR_USE = "use";

    public static BundleInfo parseJarManifest(InputStream jarStream) throws IOException,
            ParseException {
        JarInputStream jis = new JarInputStream(jarStream);
        Manifest manifest = jis.getManifest();
        if (manifest == null) {
            return null;
        }
        BundleInfo bundleInfo = parseManifest(manifest);
        return bundleInfo;
View Full Code Here

                    if (jar.getUnpackedLocalFile() != null) {
                        artifact = jar.getUnpackedLocalFile();
                    } else {
                        artifact = jar.getLocalFile();
                    }
                    JarInputStream in = null;
                    try {
                        in = new JarInputStream(new FileInputStream(artifact));
                        Manifest manifest = in.getManifest();
                        if (manifest != null) {
                            next = new ManifestAndLocation(manifest, artifact.toURI(), sourceURI);
                            return true;
                        }
                        Message.debug("No manifest in jar: " + artifact);
                    } catch (FileNotFoundException e) {
                        Message.debug("Jar file just removed: " + artifact, e);
                    } catch (IOException e) {
                        Message.warn("Unreadable jar: " + artifact, e);
                    } finally {
                        if (in != null) {
                            try {
                                in.close();
                            } catch (IOException e) {
                                // Don't care
                            }
                        }
                    }
View Full Code Here

                        // remove the top of the stack and continue with a sibling.
                        dirs.pop();
                    }
                } else if (bundleCandidates.hasNext()) {
                    T bundleCandidate = bundleCandidates.next();
                    JarInputStream in = null;
                    try {
                        in = new JarInputStream(getInputStream(bundleCandidate));
                        Manifest manifest = in.getManifest();
                        if (manifest != null) {
                            next = new ManifestAndLocation(manifest,
                                    buildBundleURI(bundleCandidate), null);
                        } else {
                            Message.debug("No manifest in jar: " + bundleCandidate);
                        }
                    } catch (FileNotFoundException e) {
                        Message.debug("Jar file just removed: " + bundleCandidate, e);
                    } catch (IOException e) {
                        Message.warn("Unreadable jar: " + bundleCandidate, e);
                    } finally {
                        if (in != null) {
                            try {
                                in.close();
                            } catch (IOException e) {
                                // Don't care
                            }
                        }
                    }
View Full Code Here

TOP

Related Classes of java.util.jar.JarInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.