You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by mp...@apache.org on 2003/08/26 11:05:15 UTC

cvs commit: cocoon-2.1/src/java/org/apache/cocoon/components/flow WebContinuation.java ContinuationsManagerImpl.java ContinuationsManager.java

mpo         2003/08/26 02:05:15

  Modified:    src/java/org/apache/cocoon/components/flow
                        WebContinuation.java ContinuationsManagerImpl.java
                        ContinuationsManager.java
  Log:
  Adaption to use of new ContinuationsDisposer.
  
  PR:
  Obtained from:
  Submitted by:	
  Reviewed by:	
  CVS: ----------------------------------------------------------------------
  CVS: PR:
  CVS:   If this change addresses a PR in the problem report tracking
  CVS:   database, then enter the PR number(s) here.
  CVS: Obtained from:
  CVS:   If this change has been taken from another system, such as NCSA,
  CVS:   then name the system in this line, otherwise delete it.
  CVS: Submitted by:
  CVS:   If this code has been contributed to Apache by someone else; i.e.,
  CVS:   they sent us a patch or a new module, then include their name/email
  CVS:   address here. If this is your work then delete this line.
  CVS: Reviewed by:
  CVS:   If we are doing pre-commit code reviews and someone else has
  CVS:   reviewed your changes, include their name(s) here.
  CVS:   If you have not had it reviewed then delete this line.
  
  Revision  Changes    Path
  1.5       +24 -2     cocoon-2.1/src/java/org/apache/cocoon/components/flow/WebContinuation.java
  
  Index: WebContinuation.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/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	20 Mar 2003 02:46:32 -0000	1.4
  +++ WebContinuation.java	26 Aug 2003 09:05:15 -0000	1.5
  @@ -119,6 +119,13 @@
        * is bigger than <code>lastAccessTime + timeToLive</code>.
        */
       protected int timeToLive;
  +    
  +    /**
  +     * Holds the <code>ContinuationsDisposer</code> to call when this continuation
  +     * gets invalidated.
  +     */
  +    protected ContinuationsDisposer disposer;
  +    
   
       /**
        * Create a <code>WebContinuation</code> object. Saves the object in
  @@ -129,16 +136,20 @@
        * @param continuation an <code>Object</code> value
        * @param parentContinuation a <code>WebContinuation</code> value
        * @param timeToLive time this continuation should live
  +     * @param disposer a <code>ContinuationsDisposer</code> to call when this
  +     * continuation gets invalidated.
        */
       WebContinuation(String id,
                       Object continuation,
                       WebContinuation parentContinuation,
  -                    int timeToLive) {
  +                    int timeToLive, 
  +                    ContinuationsDisposer disposer) {
           this.id = id;
           this.continuation = continuation;
           this.parentContinuation = parentContinuation;
           this.updateLastAccessTime();
           this.timeToLive = timeToLive;
  +        this.disposer = disposer;
   
           if (parentContinuation != null) {
               this.parentContinuation.children.add(this);
  @@ -243,6 +254,17 @@
        */
       public Object getUserObject() {
           return userObject;
  +    }
  +
  +    /**
  +     * Obtains the <code>ContinuationsDisposer</code> to call when this continuation
  +     * is invalidated.
  +     * 
  +     * @return a <code>ContinuationsDisposer</code> instance or null if there are
  +     * no specific clean-up actions required. 
  +     */
  +    ContinuationsDisposer getDisposer() {
  +        return this.disposer;
       }
   
       /**
  
  
  
  1.7       +18 -5     cocoon-2.1/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java
  
  Index: ContinuationsManagerImpl.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/ContinuationsManagerImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ContinuationsManagerImpl.java	19 Jun 2003 07:27:47 -0000	1.6
  +++ ContinuationsManagerImpl.java	26 Aug 2003 09:05:15 -0000	1.7
  @@ -143,10 +143,11 @@
   
       public WebContinuation createWebContinuation(Object kont,
                                                    WebContinuation parent,
  -                                                 int timeToLive) {
  +                                                 int timeToLive, 
  +                                                 ContinuationsDisposer disposer) {
           int ttl = (timeToLive == 0 ? defaultTimeToLive : timeToLive);
   
  -        WebContinuation wk = generateContinuation(kont, parent, ttl);
  +        WebContinuation wk = generateContinuation(kont, parent, ttl, disposer);
           wk.enableLogging(getLogger());
   
           if (parent == null) {
  @@ -198,6 +199,12 @@
           for (int i = 0; i < size; i++) {
               _invalidate((WebContinuation) children.get(i));
           }
  +        
  +        // Call specific possible implementation-specific clean-up on this continuation.
  +        ContinuationsDisposer disposer = wk.getDisposer();
  +        if (disposer != null) {
  +          disposer.disposeContinuation(wk);
  +        }
       }
   
       public WebContinuation lookupWebContinuation(String id) {
  @@ -217,9 +224,15 @@
        * @param kont an <code>Object</code> value representing continuation
        * @param parent value representing parent <code>WebContinuation</code>
        * @param ttl <code>WebContinuation</code> time to live
  +     * @param disposer <code>ContinuationsDisposer</code> instance to use for
  +     * cleanup of the continuation.
        * @return the generated <code>WebContinuation</code> with unique identifier
        */
  -    private WebContinuation generateContinuation(Object kont, WebContinuation parent, int ttl) {
  +    private WebContinuation generateContinuation( Object kont, 
  +                                                  WebContinuation parent,
  +                                                  int ttl, 
  +                                                  ContinuationsDisposer disposer) {
  +
           char[] result = new char[bytes.length * 2];
           WebContinuation wk = null;
   
  @@ -235,7 +248,7 @@
               String id = new String(result);
               synchronized (idToWebCont) {
                   if (!idToWebCont.containsKey(id)) {
  -                    wk = new WebContinuation(id, kont, parent, ttl);
  +                    wk = new WebContinuation(id, kont, parent, ttl, disposer);
                       idToWebCont.put(id, wk);
                       break;
                   }
  
  
  
  1.5       +5 -2      cocoon-2.1/src/java/org/apache/cocoon/components/flow/ContinuationsManager.java
  
  Index: ContinuationsManager.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/flow/ContinuationsManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ContinuationsManager.java	20 Mar 2003 02:46:32 -0000	1.4
  +++ ContinuationsManager.java	26 Aug 2003 09:05:15 -0000	1.5
  @@ -77,12 +77,15 @@
        * @param timeToLive an <code>int</code> value indicating how long
        * in seconds this continuation will live in the server if not
        * accessed
  +     * @param disposer a <code>ContinuationsDisposer</code> instance to called when 
  +     * the continuation gets cleaned up.
        * @return a <code>WebContinuation</code> value
        * @see WebContinuation
        */
       public WebContinuation createWebContinuation(Object kont,
                                                    WebContinuation parentKont,
  -                                                 int timeToLive);
  +                                                 int timeToLive,
  +                                                 ContinuationsDisposer disposer);
   
       /**
        * Invalidates a <code>WebContinuation</code>. This effectively