Package java.util.jar

Examples of java.util.jar.JarEntry


            }

            // create URL list
            Enumeration<JarEntry> jarEnum = moduleFile.entries();
            while (jarEnum.hasMoreElements()) {
                JarEntry entry = jarEnum.nextElement();
                String name = entry.getName();
                if (name.equals("WEB-INF/classes/")) {
                    // ensure it is first
                    File classesDir = new File(tmpDir, "WEB-INF/classes/");
                    try {
                        urlList.add(0, classesDir.toURL());
View Full Code Here


    public NestedJarFile(JarFile jarFile, String path) throws IOException {
        super(DeploymentUtil.DUMMY_JAR_FILE);

        // verify that the jar actually contains that path
        JarEntry targetEntry = jarFile.getJarEntry(path + "/");
        if (targetEntry == null) {
            targetEntry = jarFile.getJarEntry(path);
            if (targetEntry == null) {
                throw new IOException("Jar entry does not exist: jarFile=" + jarFile.getName() + ", path=" + path);
            }
        }

        if (targetEntry.isDirectory()) {
          if(targetEntry instanceof UnpackedJarEntry) {
            //unpacked nested module inside unpacked ear
            File targetFile = ((UnpackedJarEntry) targetEntry).getFile();
            baseJar = new UnpackedJarFile(targetFile);
                basePath = "";
          } else {
            baseJar = jarFile;
            if (!path.endsWith("/")) {
                    path += "/";
                }
                basePath = path;
          }
        } else {
            if (targetEntry instanceof UnpackedJarEntry) {
                // for unpacked jars we don't need to copy the jar file
                // out to a temp directory, since it is already available
                // as a raw file
                File targetFile = ((UnpackedJarEntry) targetEntry).getFile();
                baseJar = new JarFile(targetFile);
                basePath = "";
            } else {
                tempFile = DeploymentUtil.toFile(jarFile, targetEntry.getName());
                baseJar = new JarFile(tempFile);
                basePath = "";
            }
        }
    }
View Full Code Here

        if (isClosed) {
            throw new IllegalStateException("NestedJarFile is closed");
        }

        if (!manifestLoaded) {
            JarEntry manifestEntry = getBaseEntry("META-INF/MANIFEST.MF");

            if (manifestEntry != null && !manifestEntry.isDirectory()) {
                InputStream in = null;
                try {
                    in = baseJar.getInputStream(manifestEntry);
                    manifest = new Manifest(in);
                } finally {
View Full Code Here

    public NestedJarEntry getNestedJarEntry(String name) {
        if (isClosed) {
            throw new IllegalStateException("NestedJarFile is closed");
        }

        JarEntry baseEntry = getBaseEntry(name);
        if (baseEntry == null) {
            return null;
        }
        return new NestedJarEntry(name, baseEntry, getManifestSafe());
    }
View Full Code Here

        }

        Collection baseEntries = Collections.list(baseJar.entries());
        Collection entries = new LinkedList();
        for (Iterator iterator = baseEntries.iterator(); iterator.hasNext();) {
            JarEntry baseEntry = (JarEntry) iterator.next();
            String path = baseEntry.getName();
            if (path.startsWith(basePath)) {
                entries.add(new NestedJarEntry(path.substring(basePath.length()), baseEntry, getManifestSafe()));
            }
        }
        return Collections.enumeration(entries);
View Full Code Here

    public InputStream getInputStream(ZipEntry zipEntry) throws IOException {
        if (isClosed) {
            throw new IllegalStateException("NestedJarFile is closed");
        }

        JarEntry baseEntry;
        if (zipEntry instanceof NestedJarEntry) {
            baseEntry = ((NestedJarEntry)zipEntry).getBaseEntry();
        } else {
            baseEntry = getBaseEntry(zipEntry.getName());
        }

        if (baseEntry == null) {
            throw new IOException("Entry not found: name=" + baseEntry.getName());
        } else if (baseEntry.isDirectory()) {
            return new DeploymentUtil.EmptyInputStream();
        }
        return baseJar.getInputStream(baseEntry);
    }
View Full Code Here

                if (file.isDirectory()) {
                    if (!StringUtils.isEmpty(name)) {
                        if (!name.endsWith("/")) {
                            name += "/";
                        }
                        JarEntry entry = new JarEntry(name);
                        entry.setTime(file.lastModified());
                        jarout.putNextEntry(entry);
                        jarout.closeEntry();
                    }
                    createClientJar(file, jarout);
                    continue;
                }
                JarEntry entry = new JarEntry(name);
                entry.setTime(file.lastModified());
                jarout.putNextEntry(entry);
                InputStream input = new BufferedInputStream(new FileInputStream(file));
                IOUtils.copy(input, jarout);
                input.close();
                jarout.closeEntry();
View Full Code Here

        if (deploymentExists(contextPath))
            return;
       
        // Checking for a nested /META-INF/context.xml
        JarFile jar = null;
        JarEntry entry = null;
        InputStream istream = null;
        BufferedOutputStream ostream = null;
        File xml = new File
            (configBase, file.substring(0, file.lastIndexOf(".")) + ".xml");
        if (deployXML && !xml.exists()) {
View Full Code Here

                        Enumeration<JarEntry> entries = jf.entries();
                        // read all entries in jar file and return the first
                        // wsdl file that matches
                        // the relative path
                        while (entries.hasMoreElements()) {
                            JarEntry je = entries.nextElement();
                            String name = je.getName();
                            if (name.endsWith(".wsdl")) {
                                String relativePath = relativeURL.getPath();
                                if (relativePath.endsWith(name)) {
                                    String path = f.getAbsolutePath();
                                    // This check is necessary because Unix/Linux file paths begin
                                    // with a '/'. When adding the prefix 'jar:file:/' we may end
                                    // up with '//' after the 'file:' part. This causes the URL
                                    // object to treat this like a remote resource
                                    if(path != null && path.indexOf("/") == 0) {
                                        path = path.substring(1, path.length());
                                    }

                                    URL absoluteUrl = new URL("jar:file:/"
                                            + path + "!/"
                                            + je.getName());
                                    return absoluteUrl;
                                }
                            }
                        }
                    } catch (Exception e) {
View Full Code Here

        File xml = new File(host.getAppBaseFile(),
                cn.getBaseName() + "/META-INF/context.xml");

        boolean xmlInWar = false;
        JarEntry entry = null;
        try {
            jar = new JarFile(war);
            entry = jar.getJarEntry(Constants.ApplicationContextXml);
            if (entry != null) {
                xmlInWar = true;
View Full Code Here

TOP

Related Classes of java.util.jar.JarEntry

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.