Class ConfigLoader
java.lang.Object
com.opensymphony.module.sitemesh.mapper.ConfigLoader
The ConfigLoader reads a configuration XML file that contains Decorator definitions
(name, url, init-params) and path-mappings (pattern, name).
These can then be accessed by the getDecoratorByName() methods and getMappedName() methods respectively.
The DTD for the configuration file in old (deprecated) format is located at http://www.opensymphony.com/dtds/sitemesh_1_0_decorators.dtd .
The DTD for the configuration file in new format is located at http://www.opensymphony.com/dtds/sitemesh_1_5_decorators.dtd .
Editing the config file will cause it to be auto-reloaded.
This class is used by ConfigDecoratorMapper, and uses PathMapper for pattern matching.
- Version:
- $Revision: 1.4 $
- Author:
- Joe Walnes, Mathias Bogaert
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Configprivate Fileprivate Stringprivate longprivate Mapprivate PathMapper -
Constructor Summary
ConstructorsConstructorDescriptionConfigLoader(File configFile) Create new ConfigLoader using supplied File.ConfigLoader(String configFileName, Config config) Create new ConfigLoader using supplied filename and config. -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringgetAttribute(Element element, String name) Override default behavior of element.getAttribute (returns the empty string) to return null.private static StringgetContainedText(Node parent, String childTagName) With a given parent XML Element, find the text contents of the child element with supplied name.getDecoratorByName(String name) Retrieve Decorator based on name specified in configuration file.getMappedName(String path) Get name of Decorator mapped to given path.private voidLoad configuration from file.private voidparseConfig(Document document) Parse configuration from XML document.private voidpopulatePathMapper(NodeList patternNodes, String role, String name) Extracts each URL pattern and adds it to the pathMapper map.private voidrefresh()Check if configuration file has been updated, and if so, reload.private voidStore Decorator in Map
-
Field Details
-
decorators
-
configLastModified
private long configLastModified -
configFile
-
configFileName
-
pathMapper
-
config
-
-
Constructor Details
-
ConfigLoader
Create new ConfigLoader using supplied File.- Throws:
jakarta.servlet.ServletException
-
ConfigLoader
Create new ConfigLoader using supplied filename and config.- Throws:
jakarta.servlet.ServletException
-
-
Method Details
-
getDecoratorByName
Retrieve Decorator based on name specified in configuration file.- Throws:
jakarta.servlet.ServletException
-
getMappedName
Get name of Decorator mapped to given path.- Throws:
jakarta.servlet.ServletException
-
loadConfig
private void loadConfig() throws jakarta.servlet.ServletExceptionLoad configuration from file.- Throws:
jakarta.servlet.ServletException
-
parseConfig
Parse configuration from XML document. -
populatePathMapper
Extracts each URL pattern and adds it to the pathMapper map. -
getAttribute
Override default behavior of element.getAttribute (returns the empty string) to return null. -
getContainedText
With a given parent XML Element, find the text contents of the child element with supplied name. -
storeDecorator
Store Decorator in Map -
refresh
private void refresh() throws jakarta.servlet.ServletExceptionCheck if configuration file has been updated, and if so, reload.- Throws:
jakarta.servlet.ServletException
-