• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Jar类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.tomcat.util.scan.Jar的典型用法代码示例。如果您正苦于以下问题:Java Jar类的具体用法?Java Jar怎么用?Java Jar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Jar类属于org.apache.tomcat.util.scan包,在下文中一共展示了Jar类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: JspServletWrapper

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
public JspServletWrapper(ServletContext servletContext,
                         Options options,
                         String tagFilePath,
                         TagInfo tagInfo,
                         JspRuntimeContext rctxt,
                         Jar tagJar) {

    this.isTagFile = true;
    this.config = null;        // not used
    this.options = options;
    this.jspUri = tagFilePath;
    this.tripCount = 0;
    unloadByCount = options.getMaxLoadedJsps() > 0 ? true : false;
    unloadByIdle = options.getJspIdleTimeout() > 0 ? true : false;
    unloadAllowed = unloadByCount || unloadByIdle ? true : false;
    ctxt = new JspCompilationContext(jspUri, tagInfo, options,
                                     servletContext, this, rctxt,
                                     tagJar);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:20,代码来源:JspServletWrapper.java


示例2: getInputStream

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
public static InputStream getInputStream(String fname, Jar jar,
        JspCompilationContext ctxt) throws IOException {

    InputStream in = null;

    if (jar != null) {
        String jarEntryName = fname.substring(1, fname.length());
        in = jar.getInputStream(jarEntryName);
    } else {
        in = ctxt.getResourceAsStream(fname);
    }

    if (in == null) {
        throw new FileNotFoundException(Localizer.getMessage(
                "jsp.error.file.not.found", fname));
    }

    return in;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:20,代码来源:JspUtil.java


示例3: getReader

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
static InputStreamReader getReader(String fname, String encoding,
        Jar jar, JspCompilationContext ctxt, ErrorDispatcher err, int skip)
        throws JasperException, IOException {

    InputStreamReader reader = null;
    InputStream in = getInputStream(fname, jar, ctxt);
    for (int i = 0; i < skip; i++) {
        in.read();
    }
    try {
        reader = new InputStreamReader(in, encoding);
    } catch (UnsupportedEncodingException ex) {
        err.jspError("jsp.error.unsupported.encoding", encoding);
    }

    return reader;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:18,代码来源:JspUtil.java


示例4: createTagFileInfo

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
private TagFileInfo createTagFileInfo(TagFileXml tagFileXml, Jar jar) throws JasperException {

        String name = tagFileXml.getName();
        String path = tagFileXml.getPath();

        if (path == null) {
            // path is required
            err.jspError("jsp.error.tagfile.missingPath");
        } else if (!path.startsWith("/META-INF/tags") && !path.startsWith("/WEB-INF/tags")) {
            err.jspError("jsp.error.tagfile.illegalPath", path);
        }

        TagInfo tagInfo =
                TagFileProcessor.parseTagFileDirectives(parserController, name, path, jar, this);
        return new TagFileInfo(name, path, tagInfo);
    }
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:17,代码来源:TagLibraryInfoImpl.java


示例5: processResourceJARs

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
/**
 * Scan JARs that contain web-fragment.xml files that will be used to
 * configure this application to see if they also contain static resources.
 * If static resources are found, add them to the context. Resources are
 * 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();
            }
        }
    }
}
 
开发者ID:WhiteBearSolutions,项目名称:WBSAirback,代码行数:29,代码来源:ContextConfig.java


示例6: scan

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
@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);
        if (parseRequired || context.getXmlValidation()) {
            is = jar.getInputStream(FRAGMENT_LOCATION);
        }

        if (is == null) {
            // If there is no web-fragment.xml to process there is no
            // impact on distributable
            fragment.setDistributable(true);
        } else {
            InputSource source = new InputSource(
                    "jar:" + resourceURL.toString() + "!/" +
                    FRAGMENT_LOCATION);
            source.setByteStream(is);
            parseWebXml(source, fragment, true);
        }
    } finally {
        if (jar != null) {
            jar.close();
        }
        fragment.setURL(url);
        if (fragment.getName() == null) {
            fragment.setName(fragment.getURL().toString());
        }
        fragment.setJarName(extractJarFileName(url));
        fragments.put(fragment.getName(), fragment);
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:39,代码来源:ContextConfig.java


示例7: scan

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
@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);
		if (parseRequired || context.getXmlValidation()) {
			is = jar.getInputStream(FRAGMENT_LOCATION);
		}

		if (is == null) {
			// If there is no web-fragment.xml to process there is no
			// impact on distributable
			fragment.setDistributable(true);
		} else {
			InputSource source = new InputSource("jar:" + resourceURL.toString() + "!/" + FRAGMENT_LOCATION);
			source.setByteStream(is);
			parseWebXml(source, fragment, true);
		}
	} finally {
		if (jar != null) {
			jar.close();
		}
		fragment.setURL(url);
		if (fragment.getName() == null) {
			fragment.setName(fragment.getURL().toString());
		}
		fragment.setJarName(extractJarFileName(url));
		fragments.put(fragment.getName(), fragment);
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:37,代码来源:ContextConfig.java


示例8: openJar

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
public Jar openJar() throws IOException {
    if (entryName == null) {
        return null;
    } else {
        return JarFactory.newInstance(url);
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:8,代码来源:TldResourcePath.java


示例9: scan

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
@Override
public void scan(JarURLConnection urlConn, String webappPath,
        boolean isWebapp) throws IOException {
    if (!jarFound) {
        jarFound = true;
    }
    boolean found = false;
    URL jarURL = null;
    try (Jar jar = JarFactory.newInstance(urlConn.getURL())) {
        jarURL = jar.getJarFileURL();
        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);
            }
        }
    }
    if (found) {
        tldFound = true;
    } else {
        if (log.isDebugEnabled()) {
            log.debug(Localizer.getMessage("jsp.tldCache.noTldInJar",
                    jarURL.toString()));
        }
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:38,代码来源:TldScanner.java


示例10: JspCompilationContext

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
private JspCompilationContext(String jspUri, TagInfo tagInfo,
        Options options, ServletContext context, JspServletWrapper jsw,
        JspRuntimeContext rctxt, Jar tagJar, boolean isTagFile) {

    this.jspUri = canonicalURI(jspUri);
    this.options = options;
    this.jsw = jsw;
    this.context = context;

    String baseURI = jspUri.substring(0, jspUri.lastIndexOf('/') + 1);
    // hack fix for resolveRelativeURI
    if (baseURI == null) {
        baseURI = "/";
    } else if (baseURI.charAt(0) != '/') {
        // strip the base slash since it will be combined with the
        // uriBase to generate a file
        baseURI = "/" + baseURI;
    }
    if (baseURI.charAt(baseURI.length() - 1) != '/') {
        baseURI += '/';
    }
    this.baseURI = baseURI;

    this.rctxt = rctxt;
    this.basePackageName = Constants.JSP_PACKAGE_NAME;

    this.tagInfo = tagInfo;
    this.tagJar = tagJar;
    this.isTagFile = isTagFile;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:31,代码来源:JspCompilationContext.java


示例11: getInputSource

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
public static InputSource getInputSource(String fname, Jar jar, JspCompilationContext ctxt)
    throws IOException {
    InputSource source;
    if (jar != null) {
        String jarEntryName = fname.substring(1, fname.length());
        source = new InputSource(jar.getInputStream(jarEntryName));
        source.setSystemId(jar.getURL(jarEntryName));
    } else {
        source = new InputSource(ctxt.getResourceAsStream(fname));
        source.setSystemId(ctxt.getResource(fname).toExternalForm());
    }
    return source;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:14,代码来源:JspUtil.java


示例12: Parser

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
/**
 * The constructor
 */
private Parser(ParserController pc, JspReader reader, boolean isTagFile,
        boolean directivesOnly, Jar jar) {
    this.parserController = pc;
    this.ctxt = pc.getJspCompilationContext();
    this.pageInfo = pc.getCompiler().getPageInfo();
    this.err = pc.getCompiler().getErrorDispatcher();
    this.reader = reader;
    this.scriptlessCount = 0;
    this.isTagFile = isTagFile;
    this.directivesOnly = directivesOnly;
    this.jar = jar;
    start = reader.mark();
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:17,代码来源:Parser.java


示例13: parse

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
/**
 * The main entry for Parser
 *
 * @param pc
 *            The ParseController, use for getting other objects in compiler
 *            and for parsing included pages
 * @param reader
 *            To read the page
 * @param parent
 *            The parent node to this page, null for top level page
 * @return list of nodes representing the parsed page
 */
public static Node.Nodes parse(ParserController pc, JspReader reader,
        Node parent, boolean isTagFile, boolean directivesOnly,
        Jar jar, String pageEnc, String jspConfigPageEnc,
        boolean isDefaultPageEncoding, boolean isBomPresent)
        throws JasperException {

    Parser parser = new Parser(pc, reader, isTagFile, directivesOnly, jar);

    Node.Root root = new Node.Root(reader.mark(), parent, false);
    root.setPageEncoding(pageEnc);
    root.setJspConfigPageEncoding(jspConfigPageEnc);
    root.setIsDefaultPageEncoding(isDefaultPageEncoding);
    root.setIsBomPresent(isBomPresent);

    // For the Top level page, add include-prelude and include-coda
    PageInfo pageInfo = pc.getCompiler().getPageInfo();
    if (parent == null && !isTagFile) {
        parser.addInclude(root, pageInfo.getIncludePrelude());
    }
    if (directivesOnly) {
        parser.parseFileDirectives(root);
    } else {
        while (reader.hasMoreInput()) {
            parser.parseElements(root);
        }
    }
    if (parent == null && !isTagFile) {
        parser.addInclude(root, pageInfo.getIncludeCoda());
    }

    Node.Nodes page = new Node.Nodes(root);
    return page;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:46,代码来源:Parser.java


示例14: getLastModified

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
private long[] getLastModified(TldResourcePath tldResourcePath) {
    long[] result = new long[2];
    result[0] = -1;
    result[1] = -1;
    try {
        String webappPath = tldResourcePath.getWebappPath();
        if (webappPath != null) {
            // webappPath will be null for JARs containing TLDs that are on
            // the class path but not part of the web application
            URL url = servletContext.getResource(tldResourcePath.getWebappPath());
            URLConnection conn = url.openConnection();
            result[0] = conn.getLastModified();
            if ("file".equals(url.getProtocol())) {
                // 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();
            }
        }
        try (Jar jar = tldResourcePath.openJar()) {
            if (jar != null) {
                result[1] = jar.getLastModified(tldResourcePath.getEntryName());
            }
        }
    } catch (IOException e) {
        // Ignore (shouldn't happen)
    }
    return result;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:30,代码来源:TldCache.java


示例15: parseTagFileDirectives

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
/**
 * Extracts tag file directive information from the given tag file.
 *
 * This is invoked by the compiler
 *
 * @param inFileName    The name of the tag file to be parsed.
 * @param jar The location of the tag file.
 */
public Node.Nodes parseTagFileDirectives(String inFileName, Jar jar)
        throws FileNotFoundException, JasperException, IOException {
    boolean isTagFileSave = isTagFile;
    boolean directiveOnlySave = directiveOnly;
    isTagFile = true;
    directiveOnly = true;
    Node.Nodes page = doParse(inFileName, null, jar);
    directiveOnly = directiveOnlySave;
    isTagFile = isTagFileSave;
    return page;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:20,代码来源:ParserController.java


示例16: visit

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
@Override
public void visit(Node.CustomTag n) throws JasperException {
    TagFileInfo tagFileInfo = n.getTagFileInfo();
    if (tagFileInfo != null) {
        String tagFilePath = tagFileInfo.getPath();
        if (tagFilePath.startsWith("/META-INF/")) {
            // For tags in JARs, add the TLD and the tag as a dependency
            TldResourcePath tldResourcePath =
                compiler.getCompilationContext().getTldResourcePath(
                    tagFileInfo.getTagInfo().getTagLibrary().getURI());

            try (Jar jar = tldResourcePath.openJar()) {

                if (jar != null) {
                    // Add TLD
                    pageInfo.addDependant(jar.getURL(tldResourcePath.getEntryName()),
                                          Long.valueOf(jar.getLastModified(tldResourcePath.getEntryName())));
                    // Add Tag
                    pageInfo.addDependant(jar.getURL(tagFilePath.substring(1)),
                                          Long.valueOf(jar.getLastModified(tagFilePath.substring(1))));
                } else {
                    pageInfo.addDependant(tagFilePath,
                                          compiler.getCompilationContext().getLastModified(
                                                                                           tagFilePath));
                }
            } catch (IOException ioe) {
                throw new JasperException(ioe);
            }
        } else {
            pageInfo.addDependant(tagFilePath,
                    compiler.getCompilationContext().getLastModified(
                            tagFilePath));
        }
        Class<?> c = loadTagFile(compiler, tagFilePath, n.getTagInfo(),
                pageInfo);
        n.setTagHandlerClass(c);
    }
    visitBody(n);
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:40,代码来源:TagFileProcessor.java


示例17: testClassParserPerformance

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
@Test
public void testClassParserPerformance() throws IOException {
    File libDir = new File(JAR_LOCATION);
    String[] libs = libDir.list();

    Set<URL> jarURLs = new HashSet<URL>();

    for (String lib : libs) {
        if (!lib.toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
            continue;
        }
        jarURLs.add(new URL("jar:" + new File (libDir, lib).toURI().toURL().toExternalForm() + "!/"));
    }

    long duration = 0;

    for (URL jarURL : jarURLs) {
        Jar jar = JarFactory.newInstance(jarURL);
        jar.nextEntry();
        String jarEntryName = jar.getEntryName();
        while (jarEntryName != null) {
            if (jarEntryName.endsWith(".class")) {
                InputStream is = jar.getEntryInputStream();
                long start = System.nanoTime();
                ClassParser cp = new ClassParser(is);
                cp.parse();
                duration += System.nanoTime() - start;
            }
            jar.nextEntry();
            jarEntryName = jar.getEntryName();
        }
    }

    System.out.println("ClassParser performance test took: " + duration + "ns");
}
 
开发者ID:sdw2330976,项目名称:apache-tomcat-7.0.57,代码行数:36,代码来源:TesterPerformance.java


示例18: tldScanJar

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
private void tldScanJar(JarURLConnection jarConn) throws IOException {

        Jar jar = null;
        InputStream is;
        boolean foundTld = false;
        
        URL resourceURL = jarConn.getJarFileURL();
        String resourcePath = resourceURL.toString();
        
        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();
                        foundTld = true;
                        tldScanStream(resourcePath, entryName, is);
                    } finally {
                        if (is != null) {
                            try {
                                is.close();
                            } catch (IOException ioe) {
                                // Ignore
                            }
                        }
                    }
                }
                jar.nextEntry();
                entryName = jar.getEntryName();
            }
        } finally {
            if (jar != null) {
                jar.close();
            }
        }

        if (!foundTld) {
            if (log.isDebugEnabled()) {
                log.debug(Localizer.getMessage("jsp.tldCache.noTldInJar",
                        resourcePath));
            } else if (showTldScanWarning) {
                // Not entirely thread-safe but a few duplicate log messages are
                // not a huge issue
                showTldScanWarning = false;
                log.info(Localizer.getMessage("jsp.tldCache.noTldSummary"));
            }
        }
    }
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:54,代码来源:TldLocationsCache.java


示例19: testClassParserPerformance

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
@Test
public void testClassParserPerformance() throws IOException {
    File libDir = new File(JAR_LOCATION);
    String[] libs = libDir.list();

    Assert.assertNotNull(libs);

    Set<URL> jarURLs = new HashSet<URL>();

    for (String lib : libs) {
        if (!lib.toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
            continue;
        }
        jarURLs.add(new URL("jar:" + new File (libDir, lib).toURI().toURL().toExternalForm() + "!/"));
    }

    long duration = 0;

    for (URL jarURL : jarURLs) {
        Jar jar = JarFactory.newInstance(jarURL);
        try {
            jar.nextEntry();
            String jarEntryName = jar.getEntryName();
            while (jarEntryName != null) {
                if (jarEntryName.endsWith(".class")) {
                    InputStream is = jar.getEntryInputStream();
                    long start = System.nanoTime();
                    ClassParser cp = new ClassParser(is);
                    cp.parse();
                    duration += System.nanoTime() - start;
                }
                jar.nextEntry();
                jarEntryName = jar.getEntryName();
            }
        } finally {
            jar.close();
        }
    }

    System.out.println("ClassParser performance test took: " + duration + " ns");
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:42,代码来源:TesterPerformance.java


示例20: tldScanJar

import org.apache.tomcat.util.scan.Jar; //导入依赖的package包/类
private void tldScanJar(JarURLConnection jarConn) throws IOException {

		Jar jar = null;
		InputStream is;
		boolean foundTld = false;

		URL resourceURL = jarConn.getJarFileURL();
		String resourcePath = resourceURL.toString();

		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();
						foundTld = true;
						tldScanStream(resourcePath, entryName, is);
					} finally {
						if (is != null) {
							try {
								is.close();
							} catch (IOException ioe) {
								// Ignore
							}
						}
					}
				}
				jar.nextEntry();
				entryName = jar.getEntryName();
			}
		} finally {
			if (jar != null) {
				jar.close();
			}
		}

		if (!foundTld) {
			if (log.isDebugEnabled()) {
				log.debug(Localizer.getMessage("jsp.tldCache.noTldInJar", resourcePath));
			} else if (showTldScanWarning) {
				// Not entirely thread-safe but a few duplicate log messages are
				// not a huge issue
				showTldScanWarning = false;
				log.info(Localizer.getMessage("jsp.tldCache.noTldSummary"));
			}
		}
	}
 
开发者ID:how2j,项目名称:lazycat,代码行数:52,代码来源:TldLocationsCache.java



注:本文中的org.apache.tomcat.util.scan.Jar类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Tools类代码示例发布时间:2022-05-23
下一篇:
Java PrincipalNameTransformer类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap