001: /*
002: * Copyright 2004, 2005, 2006 Odysseus Software GmbH
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package de.odysseus.calyxo.panels.conf.impl;
017:
018: import java.net.URL;
019:
020: import org.apache.commons.digester.Digester;
021: import org.apache.commons.logging.Log;
022: import org.apache.commons.logging.LogFactory;
023:
024: import de.odysseus.calyxo.base.ModuleContext;
025: import de.odysseus.calyxo.base.conf.ConfigException;
026: import de.odysseus.calyxo.base.conf.impl.RootConfigImpl;
027: import de.odysseus.calyxo.base.conf.impl.RootConfigImplParser;
028: import de.odysseus.calyxo.panels.conf.PanelsRootConfig;
029:
030: /**
031: * Panels configuration parser.
032: *
033: * @author Christoph Beck
034: */
035: public class PanelsRootConfigParser extends RootConfigImplParser {
036: private static final Log log = LogFactory
037: .getLog(PanelsRootConfigParser.class);
038:
039: private static final SchemaResolver SCHEMA_RESOLVER = new SchemaResolver(
040: "/de/odysseus/calyxo/panels/conf/impl/calyxo-panels-config.xsd");
041:
042: private static final DTDResolver DTD_RESOLVER = new DTDResolver(
043: "-//Odysseus Software GmbH//DTD Calyxo Panels 0.9//EN",
044: "/de/odysseus/calyxo/panels/conf/impl/calyxo-panels-config.dtd");
045:
046: /**
047: * Constructor.
048: */
049: public PanelsRootConfigParser(ModuleContext context) {
050: super (context);
051: }
052:
053: /*
054: * (non-Javadoc)
055: * @see de.odysseus.calyxo.base.conf.impl.RootConfigImplParser#createRoot()
056: */
057: protected RootConfigImpl createRoot() {
058: return new PanelsRootConfigImpl();
059: }
060:
061: /* (non-Javadoc)
062: * @see org.apache.commons.digester.RuleSet#addRuleInstances(org.apache.commons.digester.Digester)
063: */
064: public void addRuleInstances(Digester digester) {
065: digester
066: .setRuleNamespaceURI("http://calyxo.odysseus.de/xml/ns/panels");
067:
068: // Handle panels element
069: digester.addObjectCreate("*/panels", PanelsConfigImpl.class
070: .getName());
071: digester.addSetProperties("*/panels");
072: digester.addSetNext("*/panels", "add", PanelsConfigImpl.class
073: .getName());
074:
075: // Handle panel element
076: digester.addObjectCreate("*/panel", PanelConfigImpl.class
077: .getName());
078: digester.addSetProperties("*/panel");
079: digester.addSetNext("*/panel", "add", PanelConfigImpl.class
080: .getName());
081:
082: // Handle param elements
083: digester.addObjectCreate("*/param", ParamConfigImpl.class
084: .getName());
085: digester.addSetProperties("*/param");
086: digester.addSetNext("*/param", "add", ParamConfigImpl.class
087: .getName());
088:
089: // Handle list elements
090: digester.addObjectCreate("*/list", ListConfigImpl.class
091: .getName());
092: digester.addSetProperties("*/list");
093: digester.addSetNext("*/list", "add", ListConfigImpl.class
094: .getName());
095:
096: // Handle item elements
097: digester.addObjectCreate("*/item", ItemConfigImpl.class
098: .getName());
099: digester.addSetProperties("*/item");
100: digester.addSetNext("*/item", "add", ItemConfigImpl.class
101: .getName());
102:
103: }
104:
105: /**
106: * Parse panels configuration files..
107: * @param urls pointing to xml configuration files
108: * @return Panels configuration
109: * @throws ConfigException on error during parse or initialization
110: */
111: public PanelsRootConfig parse(URL[] urls) throws ConfigException {
112: return (PanelsRootConfigImpl) parseAll(urls);
113: }
114:
115: /* (non-Javadoc)
116: * @see de.odysseus.calyxo.base.conf.impl.RootConfigImplParser#getDtdResolver()
117: */
118: protected DTDResolver getDtdResolver() {
119: return DTD_RESOLVER;
120: }
121:
122: /* (non-Javadoc)
123: * @see de.odysseus.calyxo.base.conf.impl.RootConfigImplParser#getSchemaResolver()
124: */
125: protected SchemaResolver getSchemaResolver() {
126: return SCHEMA_RESOLVER;
127: }
128:
129: /*
130: * (non-Javadoc)
131: * @see de.odysseus.calyxo.base.conf.impl.RootConfigImplParser#getLog()
132: */
133: protected Log getLog() {
134: return log;
135: }
136:
137: }
|