joerg 2003/06/24 17:55:32
Modified: src/java/org/apache/cocoon/generation
DirectoryGenerator.java
Log:
fixed cache key generation (creating a String from the parameters)
Revision Changes Path
1.5 +28 -4
cocoon-2.1/src/java/org/apache/cocoon/generation/DirectoryGenerator.java
Index: DirectoryGenerator.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/DirectoryGenerator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DirectoryGenerator.java 21 Jun 2003 13:34:03 -0000 1.4
+++ DirectoryGenerator.java 25 Jun 2003 00:55:31 -0000 1.5
@@ -150,6 +150,15 @@
/** Convenience object, so we don't need to create an AttributesImpl for every
element. */
protected AttributesImpl attributes;
+ /**
+ * The cache key needs to be generated for the configuration of this
+ * generator, so storing the parameters for generateKey().
+ * Using the member variables after setup() would not work I guess. I don't
+ * know a way from the regular expressions back to the pattern or at least
+ * a useful string.
+ */
+ protected List cacheKeyParList;
+
/** The depth parameter determines how deep the DirectoryGenerator should
delve. */
protected int depth;
/**
@@ -196,9 +205,14 @@
}
super.setup(resolver, objectModel, src, par);
+ this.cacheKeyParList = new ArrayList();
+ this.cacheKeyParList.add(src);
+
this.depth = par.getParameterAsInteger("depth", 1);
+ this.cacheKeyParList.add(String.valueOf(this.depth));
String dateFormatString = par.getParameter("dateFormat", null);
+ this.cacheKeyParList.add(dateFormatString);
if (dateFormatString != null) {
this.dateFormatter = new SimpleDateFormat(dateFormatString);
} else {
@@ -206,10 +220,13 @@
}
this.sort = par.getParameter("sort", "name");
+ this.cacheKeyParList.add(this.sort);
this.reverse = par.getParameterAsBoolean("reverse", false);
+ this.cacheKeyParList.add(String.valueOf(this.reverse));
this.refreshDelay = par.getParameterAsLong("refreshDelay", 1L) * 1000L;
+ this.cacheKeyParList.add(String.valueOf(this.refreshDelay));
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("depth: " + this.depth);
@@ -222,20 +239,22 @@
String rePattern = null;
try {
rePattern = par.getParameter("root", null);
+ this.cacheKeyParList.add(rePattern);
this.rootRE = (rePattern == null) ? null : new RE(rePattern);
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("root pattern: " + rePattern);
}
rePattern = par.getParameter("include", null);
+ this.cacheKeyParList.add(rePattern);
this.includeRE = (rePattern == null) ? null : new RE(rePattern);
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("include pattern: " + rePattern);
}
rePattern = par.getParameter("exclude", null);
+ this.cacheKeyParList.add(rePattern);
this.excludeRE = (rePattern == null) ? null : new RE(rePattern);
-
if (this.getLogger().isDebugEnabled()) {
this.getLogger().debug("exclude pattern: " + rePattern);
}
@@ -254,8 +273,12 @@
* the key generation is buggy!!
*/
public Serializable getKey() {
- return super.source + this.depth + this.dateFormatter + this.sort
- + this.reverse + this.rootRE + this.excludeRE + this.includeRE;
+ StringBuffer buffer = new StringBuffer();
+ int len = this.cacheKeyParList.size();
+ for (int i = 0; i < len; i++) {
+ buffer.append((String)this.cacheKeyParList.get(i) + ":");
+ }
+ return buffer.toString();
}
/**
@@ -529,6 +552,7 @@
*/
public void recycle() {
super.recycle();
+ this.cacheKeyParList = null;
this.attributes = null;
this.dateFormatter = null;
this.rootRE = null;