You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by fr...@apache.org on 2002/09/20 20:15:31 UTC

cvs commit: xml-cocoon2/src/java/org/apache/cocoon/generation StatusGenerator.java

froehlich    2002/09/20 11:15:31

  Modified:    src/java/org/apache/cocoon/generation StatusGenerator.java
  Log:
  added action to clear the persistent store
  
  Revision  Changes    Path
  1.7       +41 -1     xml-cocoon2/src/java/org/apache/cocoon/generation/StatusGenerator.java
  
  Index: StatusGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/StatusGenerator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StatusGenerator.java	6 May 2002 12:28:51 -0000	1.6
  +++ StatusGenerator.java	20 Sep 2002 18:15:31 -0000	1.7
  @@ -94,6 +94,7 @@
    * @author <a href="mailto:paul@luminas.co.uk">Paul Russell</a> (Luminas Limited)
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
    * @author <a href="mailto:skoechlin@ivision.fr">S&eacute;bastien K&oelig;chlin</a> (iVision)
  + * @author <a href="mailto:g-froehlich@gmx.de">Gerhard Froehlich</a>
    * @version CVS $Id$
    */
   public class StatusGenerator extends ComposerGenerator {
  @@ -101,6 +102,8 @@
       /** The StoreJanitor used to get cache statistics
        */
       protected StoreJanitor storejanitor;
  +    protected Store store_persistent;
  +
   
       /** The XML namespace for the output document.
        */
  @@ -121,6 +124,7 @@
           super.compose(manager);
           try {
               this.storejanitor = (StoreJanitor)manager.lookup(StoreJanitor.ROLE);
  +            this.store_persistent = (Store)this.manager.lookup(Store.PERSISTENT_STORE);
           } catch(ComponentException ce) {
               getLogger().info("StoreJanitor is not available. Sorry, no cache statistics");
           }
  @@ -263,7 +267,43 @@
               addValue(ch, "size", String.valueOf(size) + " items in cache (" + empty + " are empty)");
               endGroup(ch);
           };
  +        endGroup(ch);        
  +
  +        startGroup(ch, store_persistent.getClass().getName()+" (hash = 0x"+Integer.toHexString(store_persistent.hashCode())+")" );
  +        int size = 0;
  +        int empty = 0;
  +        atts.addAttribute(namespace, "name", "name", "CDATA", "cached");
  +        ch.startElement(namespace, "value", "value", atts);
  +        Enumeration enum = this.store_persistent.keys();
  +        while( enum.hasMoreElements() ) {
  +            size++;
  +
  +            Object key  = enum.nextElement();
  +            Object val  = store_persistent.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);
  +
           // END Cache
   
           // BEGIN OS info
  
  
  

----------------------------------------------------------------------
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