Class DefaultFactory


  • public class DefaultFactory
    extends BaseFactory
    DefaultFactory, reads configuration from /WEB-INF/sitemesh.xml, or uses the default configuration if sitemesh.xml does not exist.
    Version:
    $Revision: 1.3 $
    Author:
    Joe Walnes, Mathias Bogaert
    • Field Detail

      • configFileName

        java.lang.String configFileName
      • configFile

        java.io.File configFile
      • configLastModified

        long configLastModified
      • configProps

        java.util.Map configProps
      • excludesFileName

        java.lang.String excludesFileName
      • excludesFile

        java.io.File excludesFile
    • Constructor Detail

      • DefaultFactory

        public DefaultFactory​(Config config)
    • Method Detail

      • getPageParser

        public PageParser getPageParser​(java.lang.String contentType)
        Refresh config before delegating to superclass.
        Overrides:
        getPageParser in class BaseFactory
        Parameters:
        contentType - The MIME content-type of the data to be parsed
        Returns:
        Appropriate PageParser for reading data, or null if no suitable parser was found.
      • shouldParsePage

        public boolean shouldParsePage​(java.lang.String contentType)
        Refresh config before delegating to superclass.
        Overrides:
        shouldParsePage in class BaseFactory
      • isPathExcluded

        public boolean isPathExcluded​(java.lang.String path)
        Returns true if the supplied path matches one of the exclude URLs specified in sitemesh.xml, otherwise returns false. This method refreshes the config before delgating to the superclass.
        Overrides:
        isPathExcluded in class BaseFactory
        Returns:
        whether the path is excluded
      • loadConfig

        private void loadConfig()
        Load configuration from file.
      • loadSitemeshXML

        private org.w3c.dom.Element loadSitemeshXML()
                                             throws javax.xml.parsers.ParserConfigurationException,
                                                    java.io.IOException,
                                                    org.xml.sax.SAXException
        Throws:
        javax.xml.parsers.ParserConfigurationException
        java.io.IOException
        org.xml.sax.SAXException
      • loadExcludes

        private void loadExcludes()
                           throws javax.xml.parsers.ParserConfigurationException,
                                  java.io.IOException,
                                  org.xml.sax.SAXException
        Throws:
        javax.xml.parsers.ParserConfigurationException
        java.io.IOException
        org.xml.sax.SAXException
      • loadPageParsers

        private void loadPageParsers​(org.w3c.dom.NodeList nodes)
        Loop through children of 'page-parsers' element and add all 'parser' mappings.
      • loadDecoratorMappers

        private void loadDecoratorMappers​(org.w3c.dom.NodeList nodes)
      • loadExcludeUrls

        private void loadExcludeUrls​(org.w3c.dom.NodeList nodes)
        Reads in all the url patterns to exclude from decoration.
      • refresh

        private void refresh()
        Check if configuration file has been modified, and if so reload it.
      • replaceProperties

        private java.lang.String replaceProperties​(java.lang.String str)
        Replaces any properties that appear in the supplied string with their actual values
        Parameters:
        str - the string to replace the properties in
        Returns:
        the same string but with any properties expanded out to their actual values