Class TldScanner

  • Direct Known Subclasses:
    TldPreScanned

    public class TldScanner
    extends Object
    Scans for and loads Tag Library Descriptors contained in a web application.
    • Constructor Summary

      Constructors 
      Constructor Description
      TldScanner​(ServletContext context, boolean namespaceAware, boolean validation, boolean blockExternal)
      Initialise with the application's ServletContext.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      List<String> getListeners()
      Returns a list of all listeners declared by scanned TLDs.
      Map<org.apache.tomcat.util.descriptor.tld.TldResourcePath,org.apache.tomcat.util.descriptor.tld.TaglibXml> getTldResourcePathTaglibXmlMap()
      Returns the map of TldResourcePath to parsed XML files built by this scanner.
      Map<String,org.apache.tomcat.util.descriptor.tld.TldResourcePath> getUriTldResourcePathMap()
      Returns the map of URI to TldResourcePath built by this scanner.
      protected void parseTld​(String resourcePath)  
      protected void parseTld​(org.apache.tomcat.util.descriptor.tld.TldResourcePath path)  
      void scan()
      Scan for TLDs in all places defined by the specification: Tag libraries defined by the platform Entries from <jsp-config> in web.xml A resources under /WEB-INF In jar files from /WEB-INF/lib Additional entries from the container
      void scanJars()
      Scan for TLDs in JARs in /WEB-INF/lib.
      protected void scanJspConfig()
      Scan for TLDs defined in <jsp-config>.
      protected void scanPlatform()
      Scan for TLDs required by the platform specification.
      protected void scanResourcePaths​(String startPath)
      Scan web application resources for TLDs, recursively.
      void setClassLoader​(ClassLoader classLoader)
      Set the class loader used by the digester to create objects as a result of this scan.
    • Constructor Detail

      • TldScanner

        public TldScanner​(ServletContext context,
                          boolean namespaceAware,
                          boolean validation,
                          boolean blockExternal)
        Initialise with the application's ServletContext.
        Parameters:
        context - the application's servletContext
        namespaceAware - should the XML parser used to parse TLD files be configured to be name space aware
        validation - should the XML parser used to parse TLD files be configured to use validation
        blockExternal - should the XML parser used to parse TLD files be configured to be block references to external entities
    • Method Detail

      • scan

        public void scan()
                  throws IOException,
                         SAXException
        Scan for TLDs in all places defined by the specification:
        1. Tag libraries defined by the platform
        2. Entries from <jsp-config> in web.xml
        3. A resources under /WEB-INF
        4. In jar files from /WEB-INF/lib
        5. Additional entries from the container
        Throws:
        IOException - if there was a problem scanning for or loading a TLD
        SAXException - if there was a problem parsing a TLD
      • getUriTldResourcePathMap

        public Map<String,org.apache.tomcat.util.descriptor.tld.TldResourcePath> getUriTldResourcePathMap()
        Returns the map of URI to TldResourcePath built by this scanner.
        Returns:
        the map of URI to TldResourcePath
      • getTldResourcePathTaglibXmlMap

        public Map<org.apache.tomcat.util.descriptor.tld.TldResourcePath,org.apache.tomcat.util.descriptor.tld.TaglibXml> getTldResourcePathTaglibXmlMap()
        Returns the map of TldResourcePath to parsed XML files built by this scanner.
        Returns:
        the map of TldResourcePath to parsed XML files
      • getListeners

        public List<String> getListeners()
        Returns a list of all listeners declared by scanned TLDs.
        Returns:
        a list of listener class names
      • setClassLoader

        public void setClassLoader​(ClassLoader classLoader)
        Set the class loader used by the digester to create objects as a result of this scan. Normally this only needs to be set when using JspC.
        Parameters:
        classLoader - Class loader to use when creating new objects while parsing TLDs
      • scanPlatform

        protected void scanPlatform()
        Scan for TLDs required by the platform specification.
      • scanResourcePaths

        protected void scanResourcePaths​(String startPath)
                                  throws IOException,
                                         SAXException
        Scan web application resources for TLDs, recursively.
        Parameters:
        startPath - the directory resource to scan
        Throws:
        IOException - if there was a problem scanning for or loading a TLD
        SAXException - if there was a problem parsing a TLD
      • scanJars

        public void scanJars()
        Scan for TLDs in JARs in /WEB-INF/lib.