You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by je...@apache.org on 2003/05/03 13:17:44 UTC
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/modules/input XMLFileModule.java
jefft 2003/05/03 04:17:44
Modified: src/java/org/apache/cocoon/components/modules/input
XMLFileModule.java
Log:
- Improve Javadocs
- Add a decent error message if the <file> dynamic configuration is missing.
Revision Changes Path
1.5 +47 -7 cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java
Index: XMLFileModule.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- XMLFileModule.java 16 Mar 2003 17:49:12 -0000 1.4
+++ XMLFileModule.java 3 May 2003 11:17:44 -0000 1.5
@@ -199,7 +199,20 @@
/**
- * @param config a <code>Configuration</code> value
+ * Static (cocoon.xconf) configuration.
+ * Configuration is expected to be of the form:
+ * <...>
+ * <reloadable>true|<b>false</b></reloadable>
+ * <cacheable><b>true</b>|false</cacheable>
+ * <file src="<i>src1</i>" reloadable="true|<b>false</b>" cacheable="<b>true</b>|false"/>
+ * <file src="<i>src2</i>" reloadable="true|<b>false</b>" cacheable="<b>true</b>|false"/>
+ * ...
+ * </...>
+ * Each <file> pre-loads an XML DOM for querying. Typically only one
+ * <file> is specified, and its <i>src</i> is used as a default if not
+ * overridden in the {@link #getContextObject dynamic configuration}
+ *
+ * @param config a <code>Configuration</code> value, as described above.
* @exception ConfigurationException if an error occurs
*/
public void configure(Configuration config) throws ConfigurationException {
@@ -231,22 +244,49 @@
}
+ /**
+ * Get the DOM object that JXPath will operate on when evaluating
+ * attributes. This DOM is loaded from a Source, specified in the
+ * modeConf, or (if modeConf is null) from the {@link #configure static
+ * configuration}.
+ * @param modeConf The dynamic configuration for the current operation. May
+ * be <code>null</code>, in which case static (cocoon.xconf) configuration
+ * is used. Configuration is expected to have a <file> child node, and
+ * be of the form:
+ * <...>
+ * <file src="..." reloadable="true|false"/>
+ * </...>
+ * @param objectModel Object Model for the current module operation.
+ */
protected Object getContextObject(Configuration modeConf,
Map objectModel) throws ConfigurationException {
String src = this.src;
boolean reload = this.reloadAll;
boolean cache = this.cacheAll;
-
- if (modeConf != null)
- src = modeConf.getChild("file").getAttribute("src",src);
+ boolean hasDynamicConf = false; // whether we have a <file src="..."> dynamic configuration
+ Configuration fileConf = null; // the nested <file>, if any
+ if (modeConf != null) {
+ fileConf = modeConf.getChild("file", false);
+ if (fileConf == null) {
+ getLogger().error("Error: missing 'file' child element at "+modeConf.getLocation());
+ throw new ConfigurationException(
+ "Error in dynamic configuration of XMLFileModule: " +
+ "missing 'file' child element at " +
+ modeConf.getLocation());
+ }
+ hasDynamicConf = true;
+ }
+
+ if (hasDynamicConf) {
+ src = fileConf.getAttribute("src");
+ }
if (this.documents == null)
this.documents = Collections.synchronizedMap(new HashMap());
if (!this.documents.containsKey(src)) {
- if (modeConf != null) {
- final Configuration fileConf = modeConf.getChild("file");
+ if (hasDynamicConf) {
reload = fileConf.getAttributeAsBoolean("reloadable",reload);
cache = fileConf.getAttributeAsBoolean("cacheable",cache);
if (fileConf.getAttribute("cachable", null) != null) {