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:[EMAIL PROTECTED]";>Paul Russell</a> (Luminas Limited)
    * @author <a href="mailto:[EMAIL PROTECTED]";>Stefano Mazzocchi</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>S&eacute;bastien K&oelig;chlin</a> 
(iVision)
  + * @author <a href="mailto:[EMAIL PROTECTED]";>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:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to