Class DefaultFactory
- java.lang.Object
-
- com.opensymphony.module.sitemesh.Factory
-
- com.opensymphony.module.sitemesh.factory.BaseFactory
-
- com.opensymphony.module.sitemesh.factory.DefaultFactory
-
public class DefaultFactory extends BaseFactory
DefaultFactory, reads configuration from/WEB-INF/sitemesh.xml, or uses the default configuration ifsitemesh.xmldoes not exist.- Version:
- $Revision: 1.3 $
- Author:
- Joe Walnes, Mathias Bogaert
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.io.FileconfigFile(package private) java.lang.StringconfigFileName(package private) longconfigLastModified(package private) java.util.MapconfigProps(package private) java.io.FileexcludesFile(package private) java.lang.StringexcludesFileName-
Fields inherited from class com.opensymphony.module.sitemesh.factory.BaseFactory
config, decoratorMapper, excludeUrls, pageParsers
-
-
Constructor Summary
Constructors Constructor Description DefaultFactory(Config config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DecoratorMappergetDecoratorMapper()Refresh config before delegating to superclass.PageParsergetPageParser(java.lang.String contentType)Refresh config before delegating to superclass.booleanisPathExcluded(java.lang.String path)Returnstrueif the supplied path matches one of the exclude URLs specified in sitemesh.xml, otherwise returnsfalse.private voidloadConfig()Load configuration from file.private voidloadDecoratorMappers(org.w3c.dom.NodeList nodes)private voidloadExcludes()private voidloadExcludeUrls(org.w3c.dom.NodeList nodes)Reads in all the url patterns to exclude from decoration.private voidloadPageParsers(org.w3c.dom.NodeList nodes)Loop through children of 'page-parsers' element and add all 'parser' mappings.private org.w3c.dom.ElementloadSitemeshXML()private voidrefresh()Check if configuration file has been modified, and if so reload it.private java.lang.StringreplaceProperties(java.lang.String str)Replaces any properties that appear in the supplied string with their actual valuesbooleanshouldParsePage(java.lang.String contentType)Refresh config before delegating to superclass.-
Methods inherited from class com.opensymphony.module.sitemesh.factory.BaseFactory
addExcludeUrl, clearDecoratorMappers, clearExcludeUrls, clearParserMappings, mapParser, pushDecoratorMapper
-
Methods inherited from class com.opensymphony.module.sitemesh.Factory
getInstance, report
-
-
-
-
Constructor Detail
-
DefaultFactory
public DefaultFactory(Config config)
-
-
Method Detail
-
getDecoratorMapper
public DecoratorMapper getDecoratorMapper()
Refresh config before delegating to superclass.- Overrides:
getDecoratorMapperin classBaseFactory
-
getPageParser
public PageParser getPageParser(java.lang.String contentType)
Refresh config before delegating to superclass.- Overrides:
getPageParserin classBaseFactory- Parameters:
contentType- The MIME content-type of the data to be parsed- Returns:
- Appropriate
PageParserfor reading data, ornullif no suitable parser was found.
-
shouldParsePage
public boolean shouldParsePage(java.lang.String contentType)
Refresh config before delegating to superclass.- Overrides:
shouldParsePagein classBaseFactory
-
isPathExcluded
public boolean isPathExcluded(java.lang.String path)
Returnstrueif the supplied path matches one of the exclude URLs specified in sitemesh.xml, otherwise returnsfalse. This method refreshes the config before delgating to the superclass.- Overrides:
isPathExcludedin classBaseFactory- 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.ParserConfigurationExceptionjava.io.IOExceptionorg.xml.sax.SAXException
-
loadExcludes
private void loadExcludes() throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException- Throws:
javax.xml.parsers.ParserConfigurationExceptionjava.io.IOExceptionorg.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
-
-