Package java.util.jar

Examples of java.util.jar.JarFile$JarEntryIterator


            int total = 0;
            int threshold = 10240;
            URLConnection uc = url.openConnection();
            int filesize = uc.getContentLength();
            InputStream net = uc.getInputStream();
            JarFile jar = null;
            File download = null;
            try {
                download = File.createTempFile("geronimo-driver-download", ".zip");
                OutputStream out = new BufferedOutputStream(new FileOutputStream(download));
                if (monitor != null) {
                    monitor.writeStarted("Download driver archive to " + download, filesize);
                }
                try {
                    while ((size = net.read(buf)) > -1) {
                        out.write(buf, 0, size);
                        if (monitor != null) {
                            total += size;
                            if (total > threshold) {
                                monitor.writeProgress(total);
                                threshold += 10240;
                            }
                        }
                    }
                    out.flush();
                    out.close();
                } finally {
                    if (monitor != null) {
                        monitor.writeComplete(total);
                    }
                }
                jar = new JarFile(download);
                JarEntry entry = jar.getJarEntry(driver.unzipPath);
                if (entry == null) {
                    log.error("Cannot extract driver JAR " + driver.unzipPath + " from download file " + url);
                } else {
                    in = jar.getInputStream(entry);
                    repo.copyToRepository(in, (int)entry.getSize(), Artifact.create(uri), monitor);
                }
            } finally {
                if (jar != null) try {
                    jar.close();
                } catch (IOException e) {
                    log.error("Unable to close JAR file", e);
                }
                if (download != null) {
                    download.delete();
View Full Code Here


    }

    public void XtestOldFormatPackaged() throws Exception {
        URL war = classLoader.getResource("deployables/war6.war");
        assertTrue(war != null);
        JarFile moduleFile = new JarFile(new File(war.getFile()));
        JettyWebAppType jettyWebApp = builder.getJettyWebApp(null, moduleFile, true, null, null);
        moduleFile.close();
        assertEquals(1, jettyWebApp.getResourceRefArray().length);
    }
View Full Code Here

        addEnvironment(webApp);
        webApp.setContextRoot("myContextRoot");

        URL war = classLoader.getResource("deployables/war2.war");
        assertTrue(war != null);
        JarFile dummyFile = new JarFile(new File(war.getFile()));

        webApp = builder.getJettyWebApp(webApp, dummyFile, true, null, null);

        assertEquals("myContextRoot", webApp.getContextRoot());
View Full Code Here

    public void testContextRootWithoutPlanStandAlone() throws Exception {

        URL war = classLoader.getResource("deployables/war2.war");
        assertTrue(war != null);
        JarFile dummyFile = new JarFile(new File(war.getFile()));
        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, true, null, null);
        WebAppType webApp = getWebApp(dummyFile);
        String contextRoot = builder.getContextRoot(GerWebAppType, null, webApp, true, dummyFile, null);

        assertEquals("/war2", contextRoot);
View Full Code Here

    public void testContextRootWithoutPlanAndTargetPath() throws Exception {

        URL war = classLoader.getResource("deployables/war2.war");
        assertTrue(war != null);
        JarFile dummyFile = new JarFile(new File(war.getFile()));
        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, false, "myTargetPath", null);
        WebAppType webApp = getWebApp(dummyFile);
        String contextRoot = builder.getContextRoot(GerWebAppType, null, webApp, false, dummyFile, "myTargetPath");
        assertEquals("myTargetPath", contextRoot);
View Full Code Here

        WebAppType webAppType = webAppDocument.addNewWebApp();
        webAppType.setId("myId");

        URL war = classLoader.getResource("deployables/war2.war");
        assertTrue(war != null);
        JarFile dummyFile = new JarFile(new File(war.getFile()));
        JettyWebAppType GerWebAppType = builder.getJettyWebApp(null, dummyFile, false, "myTargetPath", webAppType);
//        WebAppType webApp = getWebApp(dummyFile);
        String contextRoot = builder.getContextRoot(GerWebAppType, null, webAppType, false, dummyFile, "myTargetPath");

        assertEquals("myId", contextRoot);
View Full Code Here

            earData = new EarData();
            earContext.getGeneralData().put(EarData.class, earData);
        }
        earData.addEjbModule((EjbModule) module);

        JarFile moduleFile = module.getModuleFile();
        try {
            // extract the ejbJar file into a standalone packed jar file and add the contents to the output
            earContext.addIncludeAsPackedJar(URI.create(module.getTargetPath()), moduleFile);
        } catch (IOException e) {
            throw new DeploymentException("Unable to copy ejb module jar into configuration: " + moduleFile.getName(), e);
        }
    }
View Full Code Here

                                Map servletLocations,
                                Environment environment,
                                Map sharedContext) throws DeploymentException {
        Map portMap = null;
        String path = isEJB ? "META-INF/webservices.xml" : "WEB-INF/webservices.xml";
        JarFile moduleFile = module.getModuleFile();
        try {
            URL wsDDUrl = DeploymentUtil.createJarURL(moduleFile, path);
            InputStream in = wsDDUrl.openStream();
            portMap = parseWebServiceDescriptor(in, wsDDUrl, moduleFile, isEJB, servletLocations);
        } catch (IOException e) {
View Full Code Here

                tmpDir = DeploymentUtil.createTempDir();
                /*
                 * This is needed becuase DeploymentUtil.unzipToDirectory()
                 * always closes the passed JarFile.
                 */
                JarFile module = new JarFile(moduleFile.getName());
                DeploymentUtil.unzipToDirectory(module, tmpDir);
            } catch (IOException e) {
                if (tmpDir != null) {
                    DeploymentUtil.recursiveDelete(tmpDir);
                }
View Full Code Here

        try {
            // only handle .jar files
            if (!artifact.getPath().endsWith(".jar")) {
                return false;
            }
            JarFile jar = new JarFile(artifact);
            try {
                // only handle non OSGi jar
                Manifest manifest = jar.getManifest();
                if (manifest != null &&
                    manifest.getMainAttributes().getValue(new Attributes.Name("Bundle-SymbolicName")) != null &&
                    manifest.getMainAttributes().getValue(new Attributes.Name("Bundle-Version")) != null) {
                    return false;
                }
                return true;
            } finally {
                jar.close();
            }
        } catch (Exception e) {
            return false;
        }
    }
View Full Code Here

TOP

Related Classes of java.util.jar.JarFile$JarEntryIterator

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.