public class ConfigLoader
extends java.lang.Object
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.
ConfigDecoratorMapper
,
PathMapper
Modifier and Type | Class and Description |
---|---|
private static class |
ConfigLoader.State
State visibile across threads stored in a single container so that we
can efficiently atomically access it with the guarantee that we wont see
a partially loaded configuration in the face of one thread reloading the
configuration while others are trying to read it.
|
Modifier and Type | Field and Description |
---|---|
private Config |
config |
private java.io.File |
configFile |
private java.lang.String |
configFileName |
private ConfigLoader.State |
state
Mark volatile so that the installation of new versions is guaranteed to
be visible across threads.
|
Constructor and Description |
---|
ConfigLoader(java.io.File configFile)
Create new ConfigLoader using supplied File.
|
ConfigLoader(java.lang.String configFileName,
Config config)
Create new ConfigLoader using supplied filename and config.
|
Modifier and Type | Method and Description |
---|---|
private static java.lang.String |
getAttribute(org.w3c.dom.Element element,
java.lang.String name) |
private static java.lang.String |
getContainedText(org.w3c.dom.Node parent,
java.lang.String childTagName) |
Decorator |
getDecoratorByName(java.lang.String name)
Retrieve Decorator based on name specified in configuration file.
|
java.lang.String |
getMappedName(java.lang.String path)
Get name of Decorator mapped to given path.
|
private ConfigLoader.State |
loadConfig()
Load configuration from file.
|
private void |
parseConfig(ConfigLoader.State newState,
org.w3c.dom.Document document) |
private void |
populatePathMapper(ConfigLoader.State newState,
org.w3c.dom.NodeList patternNodes,
java.lang.String role,
java.lang.String name) |
private ConfigLoader.State |
refresh()
Check if configuration file has been updated, and if so, reload.
|
private void |
storeDecorator(ConfigLoader.State newState,
Decorator d) |
private volatile ConfigLoader.State state
private java.io.File configFile
private java.lang.String configFileName
private Config config
public ConfigLoader(java.io.File configFile) throws javax.servlet.ServletException
javax.servlet.ServletException
public ConfigLoader(java.lang.String configFileName, Config config) throws javax.servlet.ServletException
javax.servlet.ServletException
public Decorator getDecoratorByName(java.lang.String name) throws javax.servlet.ServletException
javax.servlet.ServletException
public java.lang.String getMappedName(java.lang.String path) throws javax.servlet.ServletException
javax.servlet.ServletException
private ConfigLoader.State loadConfig() throws javax.servlet.ServletException
javax.servlet.ServletException
private void parseConfig(ConfigLoader.State newState, org.w3c.dom.Document document)
private void populatePathMapper(ConfigLoader.State newState, org.w3c.dom.NodeList patternNodes, java.lang.String role, java.lang.String name)
private static java.lang.String getAttribute(org.w3c.dom.Element element, java.lang.String name)
private static java.lang.String getContainedText(org.w3c.dom.Node parent, java.lang.String childTagName)
private void storeDecorator(ConfigLoader.State newState, Decorator d)
private ConfigLoader.State refresh() throws javax.servlet.ServletException
javax.servlet.ServletException