cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ovi...@apache.org
Subject cvs commit: xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow ContinuationsManagerImpl.java
Date Wed, 10 Apr 2002 00:35:06 GMT
ovidiu      02/04/09 17:35:06

  Modified:    src/scratchpad/schecoon/src/org/apache/cocoon/components/flow
                        ContinuationsManagerImpl.java
  Log:
  Pass and additional time-to-live argument in
  createWebContinuation(). Added an 'expirations' sorted set to maintain
  continuations in the order of their expiration.
  
  Revision  Changes    Path
  1.3       +20 -7     xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java
  
  Index: ContinuationsManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ContinuationsManagerImpl.java	2 Apr 2002 04:59:49 -0000	1.2
  +++ ContinuationsManagerImpl.java	10 Apr 2002 00:35:06 -0000	1.3
  @@ -2,17 +2,20 @@
   
   import java.security.SecureRandom;
   import java.util.Collections;
  +import java.util.Comparator;
   import java.util.HashMap;
   import java.util.HashSet;
  +import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
   import java.util.Set;
  +import java.util.SortedSet;
  +import java.util.TreeSet;
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.apache.avalon.framework.thread.ThreadSafe;
  -import java.util.Iterator;
   
   /**
    * The default implementation of {@link ContinuationsManager}.
  @@ -33,10 +36,8 @@
     /**
      * How long does a continuation exist in memory since the last
      * access? The time is in seconds, and the default is 3600 (1 hour).
  -   *
  -   * FIXME: Not used for the moment.
      */
  -  protected int timeToLive;
  +  protected int defaultTimeToLive;
   
     /**
      * Maintains the forrest of <code>WebContinuation</code> trees.
  @@ -49,6 +50,13 @@
      */
     protected Map idToWebCont = Collections.synchronizedMap(new HashMap());
   
  +  /**
  +   * Sorted set of <code>WebContinuation</code> instances, based on
  +   * their expiration time. This is used by the background thread to
  +   * invalidate continuations.
  +   */
  +  protected SortedSet expirations = new TreeSet();
  +
     public ContinuationsManagerImpl()
       throws Exception
     {
  @@ -59,17 +67,21 @@
   
     public void configure(Configuration config)
     {
  -    this.timeToLive = config.getAttributeAsInteger("time-to-live", 3600);
  +    defaultTimeToLive = config.getAttributeAsInteger("time-to-live", 3600);
     }
   
     public WebContinuation createWebContinuation(Object kont,
  -                                               WebContinuation parentKont)
  +                                               WebContinuation parentKont,
  +                                               int timeToLive)
     {
  -    WebContinuation wk = new WebContinuation(kont, parentKont, this);
  +    int ttl = (timeToLive == 0 ? defaultTimeToLive : timeToLive);
  +    WebContinuation wk = new WebContinuation(kont, parentKont, this, ttl);
   
       if (parentKont == null)
         forrest.add(wk);
   
  +    expirations.add(wk);
  +
       // No need to add the WebContinuation in idToWebCont as it was
       // already done during its construction.
   
  @@ -92,6 +104,7 @@
     protected void _invalidate(WebContinuation wk)
     {
       idToWebCont.remove(wk.getId());
  +    expirations.remove(wk);
       
       // Invalidate all the children continuations as well
       List children = wk.getChildren();
  
  
  

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