Class to parse the contents of an XML configuration file (using
Commons Digester) that defines and configures commands and command chains
to be registered in a Catalog . Advanced users can configure the
detailed parsing behavior by configuring the properties of an instance
of this class prior to calling the parse() method. It
is legal to call the parse() method more than once, in order
to parse more than one configuration document.
| Method from org.apache.commons.chain.config.ConfigParser Detail: |
public Digester getDigester() {
// ------------------------------------------------------------- Properties
if (digester == null) {
digester = new Digester();
RuleSet ruleSet = getRuleSet();
digester.setNamespaceAware(ruleSet.getNamespaceURI() != null);
digester.setUseContextClassLoader(getUseContextClassLoader());
digester.setValidating(false);
digester.addRuleSet(ruleSet);
}
return (digester);
}
Return the Digester instance to be used for
parsing, creating one if necessary.
|
public RuleSet getRuleSet() {
if (ruleSet == null) {
ruleSet = new ConfigRuleSet();
}
return (ruleSet);
}
Return the RuleSet to be used for configuring
our Digester parsing rules, creating one if necessary.
|
public boolean getUseContextClassLoader() {
return (this.useContextClassLoader);
}
Return the "use context class loader" flag. If set to
true, Digester will attempt to instantiate new
command and chain instances from the context class loader.
|
public void parse(URL url) throws Exception {
// Prepare our Digester instance
Digester digester = getDigester();
digester.clear();
// Parse the configuration document
digester.parse(url);
}
Parse the XML document at the specified URL using the configured
RuleSet, registering catalogs with nested chains and
commands as they are encountered. Use this method only
if you have included one or more factory elements in your
configuration resource.
|
public void parse(Catalog catalog,
URL url) throws Exception {
// Prepare our Digester instance
Digester digester = getDigester();
digester.clear();
digester.push(catalog);
// Parse the configuration document
digester.parse(url);
} Deprecated! Use - parse(URL) on a configuration resource with "factory"
element(s) embedded
Parse the XML document at the specified URL, using the configured
RuleSet, registering top level commands into the specified
Catalog . Use this method only if you have
NOT included any factory element in your
configuration resource, and wish to supply the catalog explictly.
|
public void setRuleSet(RuleSet ruleSet) {
this.digester = null;
this.ruleSet = ruleSet;
}
|
public void setUseContextClassLoader(boolean useContextClassLoader) {
this.useContextClassLoader = useContextClassLoader;
}
|