Examples of Jar


Examples of org.apache.tomcat.util.scan.Jar

                boolean isWebapp) throws IOException {
            if (!jarFound) {
                jarFound = true;
            }
            boolean found = false;
            Jar jar = JarFactory.newInstance(urlConn.getURL());
            URL jarURL = jar.getJarFileURL();
            try {
                jar.nextEntry();
                for (String entryName = jar.getEntryName();
                    entryName != null;
                    jar.nextEntry(), entryName = jar.getEntryName()) {
                    if (!(entryName.startsWith("META-INF/") &&
                            entryName.endsWith(TLD_EXT))) {
                        continue;
                    }
                    found = true;
                    TldResourcePath tldResourcePath =
                            new TldResourcePath(jarURL, webappPath, entryName);
                    try {
                        parseTld(tldResourcePath);
                    } catch (SAXException e) {
                        throw new IOException(e);
                    }
                }
            } finally {
                jar.close();
            }
            if (found) {
                tldFound = true;
            } else {
                if (log.isDebugEnabled()) {
View Full Code Here

Examples of org.apache.tomcat.util.scan.Jar

                long includeLastModified = 0;
                if (key.startsWith("jar:jar:")) {
                    // Assume we constructed this correctly
                    int entryStart = key.lastIndexOf("!/");
                    String entry = key.substring(entryStart + 2);
                    Jar jar = JarFactory.newInstance(new URL(key.substring(4, entryStart)));
                    includeLastModified = jar.getLastModified(entry);
                } else {
                    if (key.startsWith("jar:") || key.startsWith("file:")) {
                        includeUrl = new URL(key);
                    } else {
                        includeUrl = ctxt.getResource(include.getKey());
View Full Code Here

Examples of org.apache.tomcat.util.scan.Jar

                // Reading the last modified time opens an input stream so we
                // need to make sure it is closed again otherwise the TLD file
                // will be locked until GC runs.
                conn.getInputStream().close();
            }
            Jar jar = tldResourcePath.getJar();
            if (jar != null) {
                result[1] = jar.getLastModified(tldResourcePath.getEntryName());
            }
        } catch (IOException e) {
            // Ignore (shouldn't happen)
        }
        return result;
View Full Code Here

Examples of org.apache.tomcat.util.scan.Jar


    protected void processAnnotationsJar(URL url, WebXml fragment,
            boolean handlesTypesOnly) {

        Jar jar = null;
        InputStream is;

        try {
            jar = JarFactory.newInstance(url);

            jar.nextEntry();
            String entryName = jar.getEntryName();
            while (entryName != null) {
                if (entryName.endsWith(".class")) {
                    is = null;
                    try {
                        is = jar.getEntryInputStream();
                        processAnnotationsStream(
                                is, fragment, handlesTypesOnly);
                    } catch (IOException e) {
                        log.error(sm.getString("contextConfig.inputStreamJar",
                                entryName, url),e);
                    } catch (ClassFormatException e) {
                        log.error(sm.getString("contextConfig.inputStreamJar",
                                entryName, url),e);
                    } finally {
                        if (is != null) {
                            try {
                                is.close();
                            } catch (IOException ioe) {
                                // Ignore
                            }
                        }
                    }
                }
                jar.nextEntry();
                entryName = jar.getEntryName();
            }
        } catch (IOException e) {
            log.error(sm.getString("contextConfig.jarFile", url), e);
        } finally {
            if (jar != null) {
                jar.close();
            }
        }
    }
View Full Code Here

Examples of org.apache.tomcat.util.scan.Jar

     * added in web-fragment.xml priority order.
     */
    protected void processResourceJARs(Set<WebXml> fragments) {
        for (WebXml fragment : fragments) {
            URL url = fragment.getURL();
            Jar jar = null;
            try {
                if ("jar".equals(url.getProtocol())) {
                    jar = JarFactory.newInstance(url);
                    jar.nextEntry();
                    String entryName = jar.getEntryName();
                    while (entryName != null) {
                        if (entryName.startsWith("META-INF/resources/")) {
                            context.getResources().createWebResourceSet(
                                    WebResourceRoot.ResourceSetType.RESOURCE_JAR,
                                    "/", url, "/META-INF/resources");
                            break;
                        }
                        jar.nextEntry();
                        entryName = jar.getEntryName();
                    }
                } else if ("file".equals(url.getProtocol())) {
                    File file = new File(url.toURI());
                    File resources = new File(file, "META-INF/resources/");
                    if (resources.isDirectory()) {
                        context.getResources().createWebResourceSet(
                                WebResourceRoot.ResourceSetType.RESOURCE_JAR,
                                "/", file.getAbsolutePath(), null, "/");
                    }
                }
            } catch (IOException ioe) {
                log.error(sm.getString("contextConfig.resourceJarFail", url,
                        context.getName()));
            } catch (URISyntaxException e) {
                log.error(sm.getString("contextConfig.resourceJarFail", url,
                    context.getName()));
            } finally {
                if (jar != null) {
                    jar.close();
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.tomcat.util.scan.Jar

     *
     * Keep in sync with o.a.j.comiler.TldLocationsCache
     */
    private void tldScanJar(JarURLConnection jarConn) {

        Jar jar = null;
        InputStream is;
       
        try {
            jar = JarFactory.newInstance(jarConn.getURL());
           
            jar.nextEntry();
            String entryName = jar.getEntryName();
            while (entryName != null) {
                if (entryName.startsWith("META-INF/") &&
                        entryName.endsWith(".tld")) {
                    is = null;
                    try {
                        is = jar.getEntryInputStream();
                        XmlErrorHandler handler = tldScanStream(is);
                        handler.logFindings(log, jarConn.getURL() + entryName);
                    } finally {
                        if (is != null) {
                            try {
                                is.close();
                            } catch (IOException ioe) {
                                // Ignore
                            }
                        }
                    }
                }
                jar.nextEntry();
                entryName = jar.getEntryName();
            }
        } catch (IOException ioe) {
            log.warn(sm.getString("tldConfig.jarFail", jarConn.getURL()), ioe);
        } finally {
            if (jar != null) {
                jar.close();
            }
        }
    }
View Full Code Here

Examples of org.apache.tomcat.util.scan.Jar

    protected void processServletContainerInitializers(
            Set<WebXml> fragments) {
       
        for (WebXml fragment : fragments) {
            URL url = fragment.getURL();
            Jar jar = null;
            InputStream is = null;
            ServletContainerInitializer sci = null;
            try {
                if ("jar".equals(url.getProtocol())) {
                    jar = JarFactory.newInstance(url);
                    is = jar.getInputStream(SCI_LOCATION);
                } else if ("file".equals(url.getProtocol())) {
                    String path = url.getPath();
                    File file = new File(path, SCI_LOCATION);
                    if (file.exists()) {
                        is = new FileInputStream(file);
                    }
                }
                if (is != null) {
                    sci = getServletContainerInitializer(is);
                }
            } catch (IOException ioe) {
                log.error(sm.getString(
                        "contextConfig.servletContainerInitializerFail", url,
                        context.getName()));
                ok = false;
                return;
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException e) {
                        // Ignore
                    }
                }
                if (jar != null) {
                    jar.close();
                }
            }
           
            if (sci == null) {
                continue;
View Full Code Here

Examples of org.apache.tomcat.util.scan.Jar

     * added in web-fragment.xml priority order.
     */
    protected void processResourceJARs(Set<WebXml> fragments) {
        for (WebXml fragment : fragments) {
            URL url = fragment.getURL();
            Jar jar = null;
            try {
                // Note: Ignore file URLs for now since only jar URLs will be accepted
                if ("jar".equals(url.getProtocol())) {
                    jar = JarFactory.newInstance(url);
                    if (jar.entryExists("META-INF/resources/")) {
                        context.addResourceJarUrl(url);
                    }
                }
            } catch (IOException ioe) {
                log.error(sm.getString("contextConfig.resourceJarFail", url,
                        context.getName()));
            } finally {
                if (jar != null) {
                    jar.close();
                }
            }
        }
    }
View Full Code Here

Examples of org.apache.tomcat.util.scan.Jar

    }


    protected void processAnnotationsJar(URL url, WebXml fragment) {

        Jar jar = null;
        InputStream is;
       
        try {
            jar = JarFactory.newInstance(url);
           
            jar.nextEntry();
            String entryName = jar.getEntryName();
            while (entryName != null) {
                if (entryName.endsWith(".class")) {
                    is = null;
                    try {
                        is = jar.getEntryInputStream();
                        processAnnotationsStream(is, fragment);
                    } catch (IOException e) {
                        log.error(sm.getString("contextConfig.inputStreamJar",
                                entryName, url),e);
                    } finally {
                        if (is != null) {
                            try {
                                is.close();
                            } catch (IOException ioe) {
                                // Ignore
                            }
                        }
                    }
                }
                jar.nextEntry();
                entryName = jar.getEntryName();
            }
        } catch (IOException e) {
            log.error(sm.getString("contextConfig.jarFile", url), e);
        } finally {
            if (jar != null) {
                jar.close();
            }
        }
    }
View Full Code Here

Examples of org.apache.tomcat.util.scan.Jar

        @Override
        public void scan(JarURLConnection jarConn) throws IOException {
           
            URL url = jarConn.getURL();
            URL resourceURL = jarConn.getJarFileURL();
            Jar jar = null;
            InputStream is = null;
            WebXml fragment = new WebXml();

            try {
                jar = JarFactory.newInstance(url);
                is = jar.getInputStream(FRAGMENT_LOCATION);

                if (is == null) {
                    // If there is no web.xml, normal JAR no impact on
                    // distributable
                    fragment.setDistributable(true);
                } else {
                    InputSource source = new InputSource(
                            resourceURL.toString() + "!/" + FRAGMENT_LOCATION);
                    source.setByteStream(is);
                    parseWebXml(source, fragment, true);
                }
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException ioe) {
                        // Ignore
                    }
                }
                if (jar != null) {
                    jar.close();
                }
                fragment.setURL(url);
                if (fragment.getName() == null) {
                    fragment.setName(fragment.getURL().toString());
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.