Search in sources :

Example 6 with TldResourcePath

use of org.apache.tomcat.util.descriptor.tld.TldResourcePath in project tomcat by apache.

the class Parser method parseTaglibDirective.

/*
     * Parses a taglib directive with the following syntax: Directive ::= ( S
     * Attribute)*
     */
private void parseTaglibDirective(Node parent) throws JasperException {
    Attributes attrs = parseAttributes();
    String uri = attrs.getValue("uri");
    String prefix = attrs.getValue("prefix");
    if (prefix != null) {
        Mark prevMark = pageInfo.getNonCustomTagPrefix(prefix);
        if (prevMark != null) {
            err.jspError(reader.mark(), "jsp.error.prefix.use_before_dcl", prefix, prevMark.getFile(), "" + prevMark.getLineNumber());
        }
        if (uri != null) {
            String uriPrev = pageInfo.getURI(prefix);
            if (uriPrev != null && !uriPrev.equals(uri)) {
                err.jspError(reader.mark(), "jsp.error.prefix.refined", prefix, uri, uriPrev);
            }
            if (pageInfo.getTaglib(uri) == null) {
                TagLibraryInfoImpl impl = null;
                if (ctxt.getOptions().isCaching()) {
                    impl = (TagLibraryInfoImpl) ctxt.getOptions().getCache().get(uri);
                }
                if (impl == null) {
                    TldResourcePath tldResourcePath = ctxt.getTldResourcePath(uri);
                    impl = new TagLibraryInfoImpl(ctxt, parserController, pageInfo, prefix, uri, tldResourcePath, err);
                    if (ctxt.getOptions().isCaching()) {
                        ctxt.getOptions().getCache().put(uri, impl);
                    }
                }
                pageInfo.addTaglib(uri, impl);
            }
            pageInfo.addPrefixMapping(prefix, uri);
        } else {
            String tagdir = attrs.getValue("tagdir");
            if (tagdir != null) {
                String urnTagdir = URN_JSPTAGDIR + tagdir;
                if (pageInfo.getTaglib(urnTagdir) == null) {
                    pageInfo.addTaglib(urnTagdir, new ImplicitTagLibraryInfo(ctxt, parserController, pageInfo, prefix, tagdir, err));
                }
                pageInfo.addPrefixMapping(prefix, urnTagdir);
            }
        }
    }
    @SuppressWarnings("unused") Node unused = new Node.TaglibDirective(attrs, start, parent);
}
Also used : TldResourcePath(org.apache.tomcat.util.descriptor.tld.TldResourcePath) Attributes(org.xml.sax.Attributes)

Example 7 with TldResourcePath

use of org.apache.tomcat.util.descriptor.tld.TldResourcePath in project tomee by apache.

the class TomEETldScanner method scanPlatform.

@Override
protected void scanPlatform() {
    super.scanPlatform();
    if (URLClassLoaderFirst.shouldSkipJsf(Thread.currentThread().getContextClassLoader(), "javax.faces.FactoryFinder")) {
        uriTldResourcePathMapParent.putAll(URI_TLD_RESOURCE);
        tldResourcePathTaglibXmlMapParent.putAll(TLD_RESOURCE_TAG_LIB);
    } else {
        // exclude myfaces
        for (final Map.Entry<String, TldResourcePath> entry : URI_TLD_RESOURCE.entrySet()) {
            final TldResourcePath path = entry.getValue();
            if (path.getUrl() != MYFACES_URL) {
                // ref works
                uriTldResourcePathMapParent.put(entry.getKey(), path);
                final TaglibXml tl = TLD_RESOURCE_TAG_LIB.get(path);
                if (tl != null) {
                    tldResourcePathTaglibXmlMapParent.put(path, tl);
                }
            }
        }
    }
}
Also used : TldResourcePath(org.apache.tomcat.util.descriptor.tld.TldResourcePath) TaglibXml(org.apache.tomcat.util.descriptor.tld.TaglibXml) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

TldResourcePath (org.apache.tomcat.util.descriptor.tld.TldResourcePath)7 TaglibXml (org.apache.tomcat.util.descriptor.tld.TaglibXml)3 URL (java.net.URL)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 JspConfigDescriptor (javax.servlet.descriptor.JspConfigDescriptor)1 TaglibDescriptor (javax.servlet.descriptor.TaglibDescriptor)1 FunctionInfo (javax.servlet.jsp.tagext.FunctionInfo)1 TagAttributeInfo (javax.servlet.jsp.tagext.TagAttributeInfo)1 TagLibraryInfo (javax.servlet.jsp.tagext.TagLibraryInfo)1 TagXml (org.apache.tomcat.util.descriptor.tld.TagXml)1 ValidatorXml (org.apache.tomcat.util.descriptor.tld.ValidatorXml)1 Attributes (org.xml.sax.Attributes)1