cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r643296 - in /cocoon/branches/BRANCH_2_1_X/src: java/org/apache/cocoon/generation/StatusGenerator.java webapp/stylesheets/system/status2html.xslt
Date Tue, 01 Apr 2008 06:24:53 GMT
Author: joerg
Date: Mon Mar 31 23:24:50 2008
New Revision: 643296

URL: http://svn.apache.org/viewvc?rev=643296&view=rev
Log:
backport from trunk: show continuations on status page

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/StatusGenerator.java
    cocoon/branches/BRANCH_2_1_X/src/webapp/stylesheets/system/status2html.xslt

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/StatusGenerator.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/StatusGenerator.java?rev=643296&r1=643295&r2=643296&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/StatusGenerator.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/generation/StatusGenerator.java
Mon Mar 31 23:24:50 2008
@@ -29,6 +29,9 @@
 import org.apache.cocoon.Constants;
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.ResourceNotFoundException;
+import org.apache.cocoon.components.flow.ContinuationsManager;
+import org.apache.cocoon.components.flow.WebContinuation;
+import org.apache.cocoon.components.flow.WebContinuationDataBean;
 import org.apache.cocoon.components.source.SourceUtil;
 import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.xml.AttributesImpl;
@@ -134,6 +137,16 @@
     protected Store storePersistent;
 
     /**
+     * Show continuations information
+     */
+    private boolean showContinuations;
+
+    /**
+     * The ContinuationManager
+     */
+    private ContinuationsManager continuationsManager;
+
+    /**
      * List & show the contents of WEB/lib
      */
     private boolean showLibrary;
@@ -149,6 +162,7 @@
     }
 
     public void configure(Configuration configuration) throws ConfigurationException {
+        this.showContinuations = configuration.getChild("show-continuations").getValueAsBoolean(true);
         this.showLibrary = configuration.getChild("show-libraries").getValueAsBoolean(true);
     }
 
@@ -171,6 +185,12 @@
         } else {
             getLogger().info("Persistent Store is not available. Sorry no cache statistics
about it.");
         }
+
+        if(this.manager.hasService(ContinuationsManager.ROLE)) {
+            continuationsManager = (ContinuationsManager) this.manager.lookup(ContinuationsManager.ROLE);
+        } else {
+            getLogger().info("ContinuationsManager is not available. Sorry no overview of
created continuations");
+        }
     }
 
     public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par)
@@ -252,6 +272,9 @@
         atts.addCDATAAttribute(NAMESPACE, "cocoon-version", Constants.VERSION);
         super.contentHandler.startElement(NAMESPACE, "statusinfo", "statusinfo", atts);
 
+        if (this.showContinuations) {
+            genContinuationsTree();
+        }
         genVMStatus();
         genProperties();
         if (this.showLibrary) {
@@ -260,6 +283,31 @@
 
         // End root element.
         super.contentHandler.endElement(NAMESPACE, "statusinfo", "statusinfo");
+    }
+
+    private void genContinuationsTree() throws SAXException {
+        startGroup("Continuations");
+        Set continuations = this.continuationsManager.getForest();
+        for (Iterator i = continuations.iterator(); i.hasNext();) {
+            displayContinuation(new WebContinuationDataBean((WebContinuation) i.next()));
+        }
+        endGroup();
+    }
+
+    private void displayContinuation(WebContinuationDataBean wc) throws SAXException {
+        AttributesImpl ai = new AttributesImpl();
+        ai.addAttribute(NAMESPACE, "id", "id", "CDATA", wc.getId());
+        ai.addAttribute(NAMESPACE, "interpreter", "interpreter", "CDATA", wc.getInterpreterId());
+        ai.addAttribute(NAMESPACE, "expire-time", "expire-time", "CDATA", wc.getExpireTime());
+        ai.addAttribute(NAMESPACE, "time-to-live", "time-to-live", "CDATA", wc.getTimeToLive()
+ "ms");
+        ai.addAttribute(NAMESPACE, "last-access-time", "last-access-time", "CDATA", wc.getLastAccessTime());
+
+        super.contentHandler.startElement(NAMESPACE, "cont", "cont", ai);
+        List children = wc.get_children();
+        for (int i = 0; i < children.size(); i++) {
+            displayContinuation((WebContinuationDataBean) children.get(i));
+        }
+        super.contentHandler.endElement(NAMESPACE, "cont", "cont");
     }
 
     private void genVMStatus() throws SAXException {

Modified: cocoon/branches/BRANCH_2_1_X/src/webapp/stylesheets/system/status2html.xslt
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/webapp/stylesheets/system/status2html.xslt?rev=643296&r1=643295&r2=643296&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/webapp/stylesheets/system/status2html.xslt (original)
+++ cocoon/branches/BRANCH_2_1_X/src/webapp/stylesheets/system/status2html.xslt Mon Mar 31
23:24:50 2008
@@ -78,6 +78,25 @@
     <h2><xsl:value-of select="@status:name"/></h2>
     <ul><xsl:apply-templates select="status:value"/></ul>
     <xsl:apply-templates select="status:group"/>
+    <xsl:if test="status:cont">
+        <ul>
+            <xsl:apply-templates select="status:cont"/>     
+        </ul>
+    </xsl:if>
+  </xsl:template>
+
+  <xsl:template match="status:cont">
+    <li>
+        <xsl:for-each select="@*">
+            <span class="description"><xsl:value-of select="name()"/>:<xsl:text>
</xsl:text> </span><xsl:value-of select="."/>
+            <xsl:if test="position() != last()">, </xsl:if>
+        </xsl:for-each>
+    </li>
+    <xsl:if test="status:cont">
+        <ul>
+            <xsl:apply-templates select="status:cont"/>     
+        </ul>   
+    </xsl:if>
   </xsl:template>
 
   <xsl:template match="status:value">



Mime
View raw message