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

cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/flow ContinuationsManagerImpl.java WebContinuation.java flow.xconf

crafterm    2002/12/06 10:20:15

  Modified:    src/java/org/apache/cocoon/components/flow
                        ContinuationsManagerImpl.java WebContinuation.java
                        flow.xconf
  Log:
  Applied patch for better logging of continuation hierarchies.
  
  PR: BZ#15078
  Submitted By: Michael Melhem <Mi...@managesoft.com>
  
  Revision  Changes    Path
  1.6       +43 -1     xml-cocoon2/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java
  
  Index: ContinuationsManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ContinuationsManagerImpl.java	5 Dec 2002 09:37:20 -0000	1.5
  +++ ContinuationsManagerImpl.java	6 Dec 2002 18:20:15 -0000	1.6
  @@ -112,13 +112,27 @@
                                                  int timeToLive)
     {
       int ttl = (timeToLive == 0 ? defaultTimeToLive : timeToLive);
  +
       WebContinuation wk = new WebContinuation(kont, parentKont, this, ttl);
  +    wk.enableLogging(getLogger());
   
       if (parentKont == null)
         forrest.add(wk);
   
  +    // REVISIT: Place only the "leaf" nodes in the expirations Sorted Set.
  +    if (parentKont != null) {
  +        if (wk.getParentContinuation().getChildren().size() < 2) {
  +            expirations.remove(wk.getParentContinuation());
  +        }
  +    }
  +
       expirations.add(wk);
   
  +    if (this.getLogger().isDebugEnabled()) {
  +      displayAllContinuations();
  +      displayExpireSet();
  +    }
  +    
       // No need to add the WebContinuation in idToWebCont as it was
       // already done during its construction.
   
  @@ -140,6 +154,9 @@
   
     protected void _invalidate(WebContinuation wk)
     {
  +    if (this.getLogger().isDebugEnabled()) {
  +      getLogger().debug("WK: Expiring Continuation " + wk.getId());
  +    }
       idToWebCont.remove(wk.getId());
       expirations.remove(wk);
       
  @@ -194,10 +211,35 @@
       return continuationId;
     }
   
  +  /**
  +   * Dump to Log file the current contents of 
  +   * the expirations <code>SortedSet</code> 
  +   */
  +  public void displayExpireSet() {
  +    Iterator iter = expirations.iterator();
  +    StringBuffer wkSet = new StringBuffer("\nWK: Expire Set, size: " + expirations.size());
  +    while (iter.hasNext()) {
  +      final WebContinuation wk = (WebContinuation)iter.next();
  +      final long lat = wk.getLastAccessTime();
  +      wkSet.append("\nWK: ")
  +           .append(wk.getId())
  +           .append(" Last Touched [")
  +           .append(lat)
  +           .append("]");
  +    }
  +
  +    getLogger().debug(wkSet.toString());
  +  }
  +
  +  /**
  +   * Dump to Log file all <code>WebContinuation</code>s 
  +   * in the system
  +   */
     public void displayAllContinuations()
     {
       Iterator iter = forrest.iterator();
  -    while (iter.hasNext())
  +    while (iter.hasNext()) {
         ((WebContinuation)iter.next()).display();
  +    }
     }
   }
  
  
  
  1.5       +36 -11    xml-cocoon2/src/java/org/apache/cocoon/components/flow/WebContinuation.java
  
  Index: WebContinuation.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/WebContinuation.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WebContinuation.java	5 Dec 2002 09:37:20 -0000	1.4
  +++ WebContinuation.java	6 Dec 2002 18:20:15 -0000	1.5
  @@ -49,6 +49,8 @@
   import java.util.Date;
   import java.util.List;
   
  +import org.apache.avalon.framework.logger.AbstractLogEnabled;
  +
   /**
    * Representation of continuations in a Web environment.
    *
  @@ -64,7 +66,7 @@
    * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
    * @since March 19, 2002
    */
  -public class WebContinuation
  +public class WebContinuation extends AbstractLogEnabled
     implements Comparable
   {
     /**
  @@ -136,7 +138,9 @@
       this.continuation = continuation;
       this.parentContinuation = parentContinuation;
       id = manager.generateContinuationId(this);
  +    this.updateLastAccessTime();
       this.timeToLive = timeToLive;
  +
       if (parentContinuation != null)
         this.parentContinuation.children.add(this);
     }
  @@ -210,6 +214,17 @@
     }
   
     /**
  +   * Returns the last time this
  +   * <code>WebContinuation</code> was accessed.
  +   *
  +   * @return a <code>long</code> value
  +   */
  +  public long getLastAccessTime()
  +  {
  +    return lastAccessTime;
  +  }
  +
  +  /**
      * Sets the user object associated with this instance.
      *
      * @param obj an <code>Object</code> value
  @@ -278,7 +293,7 @@
      */
     public void display()
     {
  -    display(0);
  +    getLogger().debug("\nWK: Tree" + display(0));
     }
   
     /**
  @@ -290,19 +305,29 @@
      *
      * @param depth an <code>int</code> value
      */
  -  protected void display(int depth)
  +  protected String display(int depth)
     {
  -    StringBuffer buf = new StringBuffer();
  -    for (int i = 0; i < depth; i++)
  -      buf.append("  ");
  -    String spaces = buf.toString();
  +    StringBuffer tree = new StringBuffer("\n");
  +    for (int i = 0; i < depth; i++) {
  +      tree.append("  ");
  +    }
   
  -    System.out.print(spaces); System.out.println("WebContinuation " + id);
  +    tree.append("WK: WebContinuation ")
  +        .append(id)
  +        .append(" Last Touched [")
  +        .append(lastAccessTime)
  +        .append("]");
  +
  +    //REVISIT: is this needed for some reason?
  +    //System.out.print(spaces); System.out.println("WebContinuation " + id);
   
       int size = children.size();
       depth++;
  -    for (int i = 0; i < size; i++)
  -      ((WebContinuation)children.get(i)).display(depth);
  +    for (int i = 0; i < size; i++) {
  +      tree.append(((WebContinuation)children.get(i)).display(depth));
  +    }
  +
  +    return tree.toString();
     }
   
     /**
  @@ -310,6 +335,6 @@
      */
     protected void updateLastAccessTime()
     {
  -    lastAccessTime = (new Date()).getTime();
  +    lastAccessTime = new Date().getTime();
     }
   }
  
  
  
  1.3       +1 -1      xml-cocoon2/src/java/org/apache/cocoon/components/flow/flow.xconf
  
  Index: flow.xconf
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/flow.xconf,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- flow.xconf	1 Oct 2002 07:33:07 -0000	1.2
  +++ flow.xconf	6 Dec 2002 18:20:15 -0000	1.3
  @@ -64,6 +64,6 @@
   
     </flow-interpreters>
   
  -  <continuations time-to-live="3600"/>
  +  <continuations logger="flow" time-to-live="3600"/>
   
   </xconf>
  
  
  

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