You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2005/04/22 17:42:08 UTC

svn commit: r164249 - in /cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow: ContinuationsManager.java ContinuationsManagerImpl.java WebContinuationDataBean.java

Author: reinhard
Date: Fri Apr 22 08:42:07 2005
New Revision: 164249

URL: http://svn.apache.org/viewcvs?rev=164249&view=rev
Log:
sync ContinuationsManager with trunk (StatusGenerator not synced for now as it is very different from sync

Added:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/WebContinuationDataBean.java
Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManager.java
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManager.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManager.java?rev=164249&r1=164248&r2=164249&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManager.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManager.java Fri Apr 22 08:42:07 2005
@@ -15,6 +15,8 @@
  */
 package org.apache.cocoon.components.flow;
 
+import java.util.List;
+
 /**
  * The interface of the Continuations manager.
  *
@@ -89,4 +91,9 @@
      * @see WebContinuation#display()
      */
     public void displayAllContinuations();
+    
+    /**
+     * Get a list of all continuations as <code>WebContinuationDataBean</code> objects. 
+     */
+    public List getWebContinuationsDataBeanList();    
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java?rev=164249&r1=164248&r2=164249&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java Fri Apr 22 08:42:07 2005
@@ -38,6 +38,7 @@
 import org.apache.excalibur.instrument.ValueInstrument;
 
 import java.security.SecureRandom;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -597,5 +598,16 @@
 
     public void contextualize(Context context) throws ContextException {
         this.context = context;        
+    }
+
+    /**
+     * Get a list of all web continuations (data only)
+     */
+    public List getWebContinuationsDataBeanList() {
+        List beanList = new ArrayList();
+        for(Iterator it = this.forest.iterator(); it.hasNext();) {
+            beanList.add(new WebContinuationDataBean((WebContinuation) it.next()));
+        }
+        return beanList;
     }
 }

Added: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/WebContinuationDataBean.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/WebContinuationDataBean.java?rev=164249&view=auto
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/WebContinuationDataBean.java (added)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/flow/WebContinuationDataBean.java Fri Apr 22 08:42:07 2005
@@ -0,0 +1,93 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.flow;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Access to continuation data for monitoring applications
+ */
+public class WebContinuationDataBean {
+
+    private static final String TYPE_JAVAFLOW = "javaflow";
+    private static final String TYPE_FLOWSCRIPT = "flowscript";
+    private static final String HAS_EXPIRED_NO = "no";
+    private static final String HAS_EXPIRED_YES = "yes";
+
+    private WebContinuation wc;
+    private SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
+    private List _children = new ArrayList();
+
+    public WebContinuationDataBean(WebContinuation wc) {
+        this.wc = wc;
+        for (Iterator it = wc.getChildren().iterator(); it.hasNext();) {
+            WebContinuationDataBean child = new WebContinuationDataBean(
+                    (WebContinuation) it.next());
+            this._children.add(child);
+        }
+    }
+
+    public String getId() {
+        return wc.getId();
+    }
+
+    public String getLastAccessTime() {
+        return formatter.format(new Date(wc.getLastAccessTime()));
+    }
+
+    public String getInterpreterId() {
+        return wc.getInterpreterId();
+    }
+
+    public String getTimeToLiveInMinutes() {
+        return Long.toString(wc.getTimeToLive() / 1000 / 60);
+    }
+
+    public String getTimeToLive() {
+        return Long.toString(wc.getTimeToLive());
+    }
+
+    public String getExpireTime() {
+        return formatter.format(new Date(wc.getLastAccessTime()
+                + wc.getTimeToLive()));
+    }
+
+    public String hasExpired() {
+        if ((wc.getLastAccessTime() + wc.getTimeToLive()) < System
+                .currentTimeMillis()) {
+            return HAS_EXPIRED_YES;
+        }
+        return HAS_EXPIRED_NO;
+
+    }
+
+    public String getType() {
+        if (wc.getUserObject().getClass().getName().indexOf(
+                "FOM_WebContinuation") > 0) {
+            return TYPE_FLOWSCRIPT;
+        }
+        return TYPE_JAVAFLOW;
+    }
+
+    public List get_children() {
+        return this._children;
+    }
+
+}