Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 47759 invoked by uid 500); 11 Dec 2001 21:09:41 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 47736 invoked by uid 500); 11 Dec 2001 21:09:41 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 11 Dec 2001 21:09:40 -0000 Message-ID: <20011211210940.85199.qmail@icarus.apache.org> From: giacomo@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/webapp/stylesheets/system status2html.xsl X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N giacomo 01/12/11 13:09:40 Modified: src/org/apache/cocoon/components/store Tag: cocoon_20_branch StoreJanitor.java StoreJanitorImpl.java src/org/apache/cocoon/generation Tag: cocoon_20_branch StatusGenerator.java webapp/stylesheets/system Tag: cocoon_20_branch status2html.xsl Log: splaying status Submitted by: Sebastien Koechlin Revision Changes Path No revision No revision 1.1.2.4 +3 -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.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- StoreJanitor.java 2001/11/22 10:20:51 1.1.2.3 +++ StoreJanitor.java 2001/12/11 21:09:40 1.1.2.4 @@ -23,4 +23,7 @@ /** unregister method for the stores */ void unregister(Store store); + + /** get an iterator to list registered stores */ + java.util.Iterator iterator(); } 1.1.2.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.1.2.7 retrieving revision 1.1.2.8 diff -u -r1.1.2.7 -r1.1.2.8 --- StoreJanitorImpl.java 2001/11/22 10:02:04 1.1.2.7 +++ StoreJanitorImpl.java 2001/12/11 21:09:40 1.1.2.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 + * + * 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. + * + * @return a java.util.Iterator + */ + public Iterator iterator() { + return this.getStoreList().iterator(); + } + /** * Round Robin alghorithm for freeing the registerd caches. */ No revision No revision 1.4.2.4 +81 -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.4.2.3 retrieving revision 1.4.2.4 diff -u -r1.4.2.3 -r1.4.2.4 --- StatusGenerator.java 2001/10/11 08:56:12 1.4.2.3 +++ StatusGenerator.java 2001/12/11 21:09:40 1.4.2.4 @@ -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,8 @@ 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 +53,15 @@ * * @author Paul Russell (Luminas Limited) * @author Stefano Mazzocchi - * @version CVS $Revision: 1.4.2.3 $ $Date: 2001/10/11 08:56:12 $ + * @author Sébastien Kœchlin (iVision) + * @version CVS $Revision: 1.4.2.4 $ $Date: 2001/12/11 21:09:40 $ */ 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 +72,20 @@ protected static final String xlinkNamespace = "http://www.w3.org/1999/xlink"; + /** + * Set the current ComponentManager instance used by this + * Composable. + * 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 +174,57 @@ 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 = 0x"+Integer.toHexString(store.hashCode())+")" ); + int size = 0; + int empty = 0; + atts.addAttribute(namespace, "name", "name", "CDATA", "cached"); + ch.startElement(namespace, "value", "value", atts); + // For each element in Store + Enumeration e = store.keys(); + atts.clear(); + while( e.hasMoreElements() ) { + size++; + Object key = e.nextElement(); + Object val = store.get( key ); + String line = null; + if( val == null ) { + empty++; + } else { + line = key.toString() + " (class: " + + val.getClass().getName() + + ")" ; + ch.startElement(namespace, "line", "line", atts); + ch.characters(line.toCharArray(), 0, line.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 (" + empty + " are empty)"); + endGroup(ch); + }; + endGroup(ch); + // END Cache // BEGIN OS info endGroup(ch); No revision No revision 1.2.2.2 +38 -14 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.2.2.1 retrieving revision 1.2.2.2 diff -u -r1.2.2.1 -r1.2.2.2 --- status2html.xsl 2001/11/14 08:36:42 1.2.2.1 +++ status2html.xsl 2001/12/11 21:09:40 1.2.2.2 @@ -71,21 +71,45 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + - + + + + + + + + + +
    + +
+ + +
+ + + +
  • + + + +
  • +
    ---------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org For additional commands, e-mail: cocoon-cvs-help@xml.apache.org