sylvain 01/12/06 05:13:47
Modified: . changes.xml
src/org/apache/cocoon/components/store StoreJanitor.java
StoreJanitorImpl.java
src/org/apache/cocoon/generation StatusGenerator.java
webapp/stylesheets/system status2html.xsl
Log:
StatusGenerator outputs detailed information on cache contents
Submitted by: Sebastien Koechlin <[EMAIL PROTECTED]>
Revision Changes Path
1.53 +5 -1 xml-cocoon2/changes.xml
Index: changes.xml
===================================================================
RCS file: /home/cvs/xml-cocoon2/changes.xml,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- changes.xml 2001/11/28 11:45:38 1.52
+++ changes.xml 2001/12/06 13:13:47 1.53
@@ -4,7 +4,7 @@
<!--
History of Cocoon changes
- $Id: changes.xml,v 1.52 2001/11/28 11:45:38 cziegeler Exp $
+ $Id: changes.xml,v 1.53 2001/12/06 13:13:47 sylvain Exp $
-->
<changes title="History of Changes">
@@ -27,6 +27,10 @@
</devs>
<release version="2.1-dev" date="@date@">
+ <action dev="SW" type="add">
+ Status generator outputs a detailed description of what's in the cache. Patch
submitted by
+ Sebastien Koechlin [[EMAIL PROTECTED]]
+ </action>
<action dev="CZ" type="update">
Applied patch adding advanced error handling to SQLTransformer plus
escape-string element
from Peter Seiderer [[EMAIL PROTECTED]]
1.5 +4 -0
xml-cocoon2/src/org/apache/cocoon/components/store/StoreJanitor.java
Index: StoreJanitor.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/store/StoreJanitor.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- StoreJanitor.java 2001/11/22 10:21:11 1.4
+++ StoreJanitor.java 2001/12/06 13:13:47 1.5
@@ -8,6 +8,7 @@
package org.apache.cocoon.components.store;
import org.apache.avalon.framework.component.Component;
+import java.util.Iterator;
/**
* Interface for the StoreJanitors
@@ -23,4 +24,7 @@
/** unregister method for the stores */
void unregister(Store store);
+
+ /** get an iterator to list registered stores */
+ Iterator iterator();
}
1.8 +17 -0
xml-cocoon2/src/org/apache/cocoon/components/store/StoreJanitorImpl.java
Index: StoreJanitorImpl.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/components/store/StoreJanitorImpl.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- StoreJanitorImpl.java 2001/11/22 10:02:42 1.7
+++ StoreJanitorImpl.java 2001/12/06 13:13:47 1.8
@@ -16,6 +16,7 @@
import org.apache.avalon.framework.thread.ThreadSafe;
import java.util.ArrayList;
+import java.util.Iterator;
/**
* This class is a implentation of a StoreJanitor. Store classes
@@ -170,6 +171,22 @@
}
}
+ /**
+ * This method return a java.util.Iterator of every registered stores
+ *
+ * <i>The iterators returned is fail-fast: if list is structurally
+ * modified at any time after the iterator is created, in any way, the
+ * iterator will throw a ConcurrentModificationException. Thus, in the
+ * face of concurrent modification, the iterator fails quickly and
+ * cleanly, rather than risking arbitrary, non-deterministic behavior at
+ * an undetermined time in the future.</i>
+ *
+ * @return a java.util.Iterator
+ */
+ public Iterator iterator() {
+ return this.getStoreList().iterator();
+ }
+
/**
* Round Robin alghorithm for freeing the registerd caches.
*/
1.8 +77 -5
xml-cocoon2/src/org/apache/cocoon/generation/StatusGenerator.java
Index: StatusGenerator.java
===================================================================
RCS file:
/home/cvs/xml-cocoon2/src/org/apache/cocoon/generation/StatusGenerator.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- StatusGenerator.java 2001/10/11 07:28:21 1.7
+++ StatusGenerator.java 2001/12/06 13:13:47 1.8
@@ -7,7 +7,15 @@
*****************************************************************************/
package org.apache.cocoon.generation;
+import org.apache.avalon.framework.component.ComponentException;
+import org.apache.avalon.framework.component.ComponentManager;
+import org.apache.avalon.framework.component.Composable;
+
import org.apache.avalon.excalibur.pool.Recyclable;
+
+import org.apache.cocoon.components.store.StoreJanitor;
+import org.apache.cocoon.components.store.Store;
+
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
@@ -16,10 +24,7 @@
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.StringTokenizer;
+import java.util.*;
/** Generates an XML representation of the current status of Cocoon.
* Potted DTD:
@@ -47,10 +52,14 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Paul Russell</a> (Luminas Limited)
* @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
- * @version CVS $Revision: 1.7 $ $Date: 2001/10/11 07:28:21 $
+ * @version CVS $Revision: 1.8 $ $Date: 2001/12/06 13:13:47 $
*/
public class StatusGenerator extends ComposerGenerator implements Recyclable {
+ /** The StoreJanitor used to get cache statistics
+ */
+ protected StoreJanitor storejanitor;
+
/** The XML namespace for the output document.
*/
protected static final String namespace =
@@ -61,6 +70,20 @@
protected static final String xlinkNamespace =
"http://www.w3.org/1999/xlink";
+ /**
+ * Set the current <code>ComponentManager</code> instance used by this
+ * <code>Composable</code>.
+ * Need to get statistics about cache hits
+ */
+ public void compose(ComponentManager manager) throws ComponentException {
+ super.compose(manager);
+ try {
+ this.storejanitor = (StoreJanitor)manager.lookup(StoreJanitor.ROLE);
+ } catch(ComponentException ce) {
+ getLogger().info("StoreJanitor is not available. Sorry, no cache
statistics");
+ }
+ }
+
/** Generate the status information in XML format.
* @throws SAXException
* when there is a problem creating the output SAX events.
@@ -149,6 +172,55 @@
paths.add(tokenizer.nextToken());
}
addMultilineValue(ch, "classpath", paths);
+ // END ClassPath
+
+ // BEGIN Cache
+ startGroup(ch, "Store-Janitor");
+
+ // For each element in StoreJanitor
+ Iterator i = this.storejanitor.iterator();
+ while( i.hasNext() ) {
+ Store store = (Store) i.next();
+ startGroup(ch, store.getClass().getName()+" (hash =
"+store.hashCode()+")" );
+ int size = 0;
+ atts.addAttribute(namespace, "name", "name", "CDATA", "cached");
+ ch.startElement(namespace, "value", "value", atts);
+ // For each element in Store
+ Enumeration e = store.keys();
+ List cachelist = new ArrayList();
+ while( e.hasMoreElements() ) {
+ size++;
+ atts.clear();
+
+ ch.startElement(namespace, "line", "line", atts);
+
+ Object o = e.nextElement();
+ String value =
+ o.toString() + " (hash: " +
+ o.hashCode() + " | class: " +
+ o.getClass().getName() +
+ ")" ;
+
+ ch.characters(value.toCharArray(), 0, value.length());
+ ch.endElement(namespace, "line", "line");
+
+ };
+
+ if (size == 0) {
+ atts.clear();
+ ch.startElement(namespace, "line", "line", atts);
+ String value = "[empty]";
+ ch.characters(value.toCharArray(), 0, value.length());
+ ch.endElement(namespace, "line", "line");
+ }
+
+ ch.endElement(namespace, "value", "value");
+
+ addValue(ch, "size", String.valueOf(size) + " items in cache");
+ endGroup(ch);
+ };
+ endGroup(ch);
+ // END Cache
// BEGIN OS info
endGroup(ch);
1.4 +40 -2 xml-cocoon2/webapp/stylesheets/system/status2html.xsl
Index: status2html.xsl
===================================================================
RCS file: /home/cvs/xml-cocoon2/webapp/stylesheets/system/status2html.xsl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- status2html.xsl 2001/11/14 08:37:10 1.3
+++ status2html.xsl 2001/12/06 13:13:47 1.4
@@ -71,7 +71,7 @@
</xsl:template>
- <xsl:template match="status:value">
+ <!--xsl:template match="status:value">
<tr>
<td bgcolor="#0086b2" valign="top" align="left">
<FONT face="arial,helvetica,sanserif" color="#ffffff">
@@ -85,8 +85,46 @@
</td>
</tr>
- </xsl:template>
+ </xsl:template-->
+ <xsl:template match="status:value[count(status:line) <= 1]">
+ <tr>
+ <td bgcolor="#0086b2" valign="top" align="left">
+ <font face="arial,helvetica,sanserif"
color="#ffffff">
+ <xsl:value-of select="@status:name"/>
+ </font>
+ </td>
+ <td bgcolor="ffffff" width="100%">
+ <font face="arial,helvetica,sanserif">
+ <xsl:value-of select="status:line" />
+ </font>
+ </td>
+ </tr>
+ </xsl:template>
+
+ <xsl:template match="status:value[count(status:line) > 1]">
+ <tr>
+ <td bgcolor="#0086b2" valign="top" align="left">
+ <font face="arial,helvetica,sanserif"
color="#ffffff">
+ <xsl:value-of select="@status:name"/>
+ </font>
+ </td>
+ <td bgcolor="ffffff" width="100%">
+ <ul>
+ <xsl:apply-templates />
+ </ul>
+ </td>
+ </tr>
+ </xsl:template>
+
+
+ <xsl:template match="status:line">
+ <li>
+ <font face="arial,helvetica,sanserif">
+ <xsl:value-of select="." />
+ </font>
+ </li>
+ </xsl:template>
<xsl:template match="status:value[../@status:name='memory' and (
@status:name='total' or @status:name='free')]">
<tr>
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]