You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2005/04/20 05:06:21 UTC
svn commit: r162006 -
cocoon/trunk/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java
Author: vgritsenko
Date: Tue Apr 19 20:06:20 2005
New Revision: 162006
URL: http://svn.apache.org/viewcvs?view=rev&rev=162006
Log:
implement 'cache-expressions' configuration parameter promised in the javadoc.
sync javadoc with code.
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java?view=diff&r1=162005&r2=162006
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/modules/input/XMLFileModule.java Tue Apr 19 20:06:20 2005
@@ -67,18 +67,18 @@
* Sources can be held in memory for better performance and reloaded if
* changed.
*
- * <p>Caching and reloading can be turned on / off (default: on)
- * through <code><reloadable>false</reloadable></code> and
- * <code><cacheable>false</cacheable></code>. The file
+ * <p>Caching and reloading can be turned on / off (default: caching on,
+ * reloading off) through <code><reloadable>false</reloadable></code>
+ * and <code><cacheable>false</cacheable></code>. The file
* (source) to use is specified through <code><file
* src="protocol:path/to/file.xml" reloadable="true"
* cacheable="true"/></code> optionally overriding defaults for
- * caching and or reloading.</p>
+ * caching and/or reloading.</p>
*
* <p>In addition, xpath expressions are cached for higher performance.
* Thus, if an expression has been evaluated for a file, the result
* is cached and will be reused, the expression is not evaluated
- * a second time. This can be turned off using the <code>cache-xpaths</code>
+ * a second time. This can be turned off using the <code>cache-expressions</code>
* configuration option.</p>
*
* @author <a href="mailto:jefft@apache.org">Jeff Turner</a>
@@ -97,11 +97,11 @@
/** Default value for reloadability of sources. Defaults to false. */
boolean reloadAll;
- /** Default value for cachability of sources. Defaults to true. */
+ /** Default value for cacheability of sources. Defaults to true. */
boolean cacheAll;
- /** Default value for cachability of xpath expressions. Defaults to true. */
- boolean cacheExpressions = true;
+ /** Default value for cacheability of xpath expressions. Defaults to true. */
+ boolean cacheExpressions;
/** Default src */
String src;
@@ -238,33 +238,18 @@
}
/**
- * Dispose this component
- */
- public void dispose() {
- super.dispose();
- if (this.manager != null) {
- this.manager.release(this.resolver);
- this.resolver = null;
- this.manager = null;
- }
-
- this.documents = null;
- this.expressionCache = null;
- this.expressionValuesCache = null;
- }
-
- /**
* 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"/>
+ * <...>
+ * <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
+ * </...>
+ *
+ * Each <file/> element 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(Configuration, Map)}
*
* @param config a <code>Configuration</code> value, as described above.
@@ -284,7 +269,6 @@
this.cacheAll = config.getChild("cacheable").getValueAsBoolean(true);
this.documents = Collections.synchronizedMap(new HashMap());
-
Configuration[] files = config.getChildren("file");
for (int i = 0; i < files.length; i++) {
boolean reload = files[i].getAttributeAsBoolean("reloadable", this.reloadAll);
@@ -297,11 +281,31 @@
}
// init caches
- this.expressionCache = new ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.SOFT);
- this.expressionValuesCache = new ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.SOFT);
+ this.cacheExpressions = config.getChild("cache-expressions").getValueAsBoolean(true);
+ if (this.cacheExpressions) {
+ this.expressionCache = new ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.SOFT);
+ this.expressionValuesCache = new ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.SOFT);
+ }
}
/**
+ * Dispose this component
+ */
+ public void dispose() {
+ super.dispose();
+ if (this.manager != null) {
+ this.manager.release(this.resolver);
+ this.resolver = null;
+ this.manager = null;
+ }
+
+ this.documents = null;
+ this.expressionCache = null;
+ this.expressionValuesCache = null;
+ }
+
+
+ /**
* Retrieve document helper
*/
private DocumentHelper getDocumentHelper(Configuration modeConf)
@@ -436,11 +440,13 @@
}
protected void flushCache() {
- synchronized(this.expressionCache) {
- this.expressionCache.clear();
- }
- synchronized(this.expressionValuesCache) {
- this.expressionValuesCache.clear();
+ if (this.cacheExpressions) {
+ synchronized(this.expressionCache) {
+ this.expressionCache.clear();
+ }
+ synchronized(this.expressionValuesCache) {
+ this.expressionValuesCache.clear();
+ }
}
}