*/
public void parse(Element root, Configuration config, Locator locator)
throws Exception {
l_out:
for (Iterator it = root.getElements().iterator(); it.hasNext();) {
final Element el = (Element)it.next();
final String elnm = el.getName();
if ("listener".equals(elnm)) {
parseListener(config, el);
} else if ("richlet".equals(elnm)) {
final String clsnm =
IDOMs.getRequiredElementValue(el, "richlet-class");
final Map params =
IDOMs.parseParams(el, "init-param", "param-name", "param-value");
String path = el.getElementValue("richlet-url", true);
if (path != null) {
//deprecated since 2.4.0, but backward compatible
final int cnt;
synchronized (this) {
cnt = _richletnm++;
}
final String name = "z_obs_" + Integer.toHexString(cnt);
try {
config.addRichlet(name, clsnm, params);
config.addRichletMapping(name, path);
} catch (Throwable ex) {
log.error("Illegal richlet definition at "+el.getLocator(), ex);
}
} else { //syntax since 2.4.0
final String nm =
IDOMs.getRequiredElementValue(el, "richlet-name");
try {
config.addRichlet(nm, clsnm, params);
} catch (Throwable ex) {
log.error("Illegal richlet definition at "+el.getLocator(), ex);
}
}
} else if ("richlet-mapping".equals(elnm)) { //syntax since 2.4.0
final String nm =
IDOMs.getRequiredElementValue(el, "richlet-name");
final String path =
IDOMs.getRequiredElementValue(el, "url-pattern");
try {
config.addRichletMapping(nm, path);
} catch (Throwable ex) {
log.error("Illegal richlet mapping at "+el.getLocator(), ex);
}
} else if ("desktop-config".equals(elnm)) {
//desktop-config
// desktop-timeout
// disable-theme-uri
// file-check-period
// extendlet-check-period
// theme-provider-class
// theme-uri
// repeat-uuid
parseDesktopConfig(config, el);
parseClientConfig(config, el); //backward compatible with 2.4
} else if ("client-config".equals(elnm)) { //since 3.0.0
//client-config
// click-filter-delay
// keep-across-visits
// processing-prompt-delay
// error-reload
// tooltip-delay
// resend-delay
// debug-js
parseClientConfig(config, el);
} else if ("session-config".equals(elnm)) {
//session-config
// session-timeout
// max-desktops-per-session
// max-requests-per-session
// max-pushes-per-session
// timer-keep-alive
// timeout-uri
// automatic-timeout
Integer v = parseInteger(el, "session-timeout", false);
if (v != null) config.setSessionMaxInactiveInterval(v.intValue());
v = parseInteger(el, "max-desktops-per-session", false);
if (v != null) config.setSessionMaxDesktops(v.intValue());
v = parseInteger(el, "max-requests-per-session", false);
if (v != null) config.setSessionMaxRequests(v.intValue());
v = parseInteger(el, "max-pushes-per-session", false);
if (v != null) config.setSessionMaxPushes(v.intValue());
String s = el.getElementValue("timer-keep-alive", true);
if (s != null) config.setTimerKeepAlive("true".equals(s));
parseTimeoutURI(config, el);
} else if ("language-config".equals(elnm)) {
//language-config
// addon-uri
parseLangAddon(locator, el);
} else if ("language-mapping".equals(elnm)) {
//language-mapping
// language-name/extension
DefinitionLoaders.addExtension(
IDOMs.getRequiredElementValue(el, "extension"),
IDOMs.getRequiredElementValue(el, "language-name"));
//Note: we don't add it to LanguageDefinition now
//since addon-uri might be specified later
//(so we cannot load definitions now)
} else if ("system-config".equals(elnm)) {
//system-config
// disable-event-thread
// max-spare-threads
// max-suspended-threads
// event-time-warning
// max-upload-size
// upload-charset
// upload-charset-finder-class
// max-process-time
// response-charset
// cache-provider-class
// ui-factory-class
// failover-manager-class
// engine-class
// id-generator-class
// web-app-class
// method-cache-class
// url-encoder-class
// au-writer-class
// au-decoder-class
parseSystemConfig(config, el);
} else if ("xel-config".equals(elnm)) {
//xel-config
// evaluator-class
Class cls = parseClass(el, "evaluator-class", ExpressionFactory.class);
if (cls != null) config.setExpressionFactoryClass(cls);
} else if ("zscript-config".equals(elnm)) {
//zscript-config
Interpreters.add(el);
//Note: zscript-config is applied to the whole system, not just langdef
} else if ("device-config".equals(elnm)) {
//device-config
Devices.add(el);
//Note: device-config is applied to the whole system, not just langdef
parseTimeoutURI(config, el);
//deprecated since 3.6.3, but to be backward-compatible
} else if ("log".equals(elnm)) {
final String base = el.getElementValue("log-base", true);
if (base != null)
org.zkoss.util.logging.LogService.init(base, null); //start the log service
} else if ("error-page".equals(elnm)) {
//error-page
final Class cls =
parseClass(el, "exception-type", Throwable.class, true);
final String loc =
IDOMs.getRequiredElementValue(el, "location");
String deviceType = el.getElementValue("device-type", true);
if (deviceType == null) deviceType = "ajax";
else if (deviceType.length() == 0)
log.error("device-type not specified at "+el.getLocator());
config.addErrorPage(deviceType, cls, loc);
} else if ("preference".equals(elnm)) {
parsePreference(config, el);
} else if ("library-property".equals(elnm)) {
parseLibProperty(el);
} else if ("system-property".equals(elnm)) {
parseSysProperty(el);
} else {
if (_parsers != null)
for (Iterator e = _parsers.iterator(); e.hasNext();) {
org.zkoss.zk.ui.util.ConfigParser parser =
(org.zkoss.zk.ui.util.ConfigParser)e.next();
if (parser.parse(config, el))
continue l_out;
}
log.error("Unknown element: "+elnm+", at "+el.getLocator());
}
}
}