cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From giac...@apache.org
Subject cvs commit: xml-cocoon2/webapp/stylesheets/system status2html.xsl
Date Tue, 11 Dec 2001 21:09:40 GMT
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 <skoechlin@ivision.fr>
  
  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
  +     * 
  +     * <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.
        */
  
  
  
  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 <a href="mailto:paul@luminas.co.uk">Paul Russell</a> (Luminas Limited)
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version CVS $Revision: 1.4.2.3 $ $Date: 2001/10/11 08:56:12 $
  + * @author <a href="mailto:skoechlin@ivision.fr">S&eacute;bastien K&oelig;chlin</a>
(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 <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 +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 @@
   
     </xsl:template>
   
  -  <xsl:template match="status:value">
  -    <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="." />
  -       </FONT>
  -      </td>
  -    </tr>
  +	<xsl:template match="status:value[count(status:line) &lt;= 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>
  +
  +	<xsl:template match="status:value[count(status:line) &gt; 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')]">
  
  
  

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


Mime
View raw message