mpo         2003/08/26 02:06:44

  Modified:    src/blocks/apples/java/org/apache/cocoon/components/flow/apples
                        ApplesProcessor.java
  Log:
  Making sure Apples that are Disposable will get their dispose event called 
upon invalidation of their wrapping WebContinuation.
  
  
  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.4       +17 -2     
cocoon-2.1/src/blocks/apples/java/org/apache/cocoon/components/flow/apples/ApplesProcessor.java
  
  Index: ApplesProcessor.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.1/src/blocks/apples/java/org/apache/cocoon/components/flow/apples/ApplesProcessor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ApplesProcessor.java      6 Aug 2003 15:54:13 -0000       1.3
  +++ ApplesProcessor.java      26 Aug 2003 09:06:43 -0000      1.4
  @@ -50,9 +50,11 @@
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
  +import org.apache.avalon.framework.activity.Disposable;
   import org.apache.avalon.framework.context.DefaultContext;
   import org.apache.cocoon.components.LifecycleHelper;
   import org.apache.cocoon.components.flow.AbstractInterpreter;
  +import org.apache.cocoon.components.flow.ContinuationsDisposer;
   import org.apache.cocoon.components.flow.InvalidContinuationException;
   import org.apache.cocoon.components.flow.WebContinuation;
   import org.apache.cocoon.environment.Environment;
  @@ -63,7 +65,7 @@
    * ApplesProcessor is the core Cocoon component that provides the 'Apples' 
    * flow implementation. 
    */
  -public class ApplesProcessor extends AbstractInterpreter implements 
Serviceable {
  +public class ApplesProcessor extends AbstractInterpreter implements 
Serviceable, ContinuationsDisposer {
   
       //TODO make this a configuration setting
       public static final int TIMETOLIVE = 1800; // 30 minutes
  @@ -80,11 +82,13 @@
   
           AppleController app = instantiateController(className);
   
  -        WebContinuation wk = 
this.continuationsMgr.createWebContinuation(app, null, TIMETOLIVE);
  +        WebContinuation wk = 
this.continuationsMgr.createWebContinuation(app, null, TIMETOLIVE, this);
   
           getLogger().debug("Pulling fresh apple through the lifecycle...");
           DefaultContext appleContext = new DefaultContext();
           appleContext.put("continuation-id", wk.getId());
  +        
  +        //TODO: also add the componentManager for Apples that took the other 
approach
           LifecycleHelper.setupComponent(app, getLogger(), appleContext, 
this.serviceManager, null, null, null);
   
           processApple(params, env, app, wk);
  @@ -156,8 +160,19 @@
       }
   
   
  +    public void disposeContinuation(WebContinuation webContinuation) {
  +        AppleController app =
  +            (AppleController) webContinuation.getContinuation();
  +        if (app instanceof Disposable) {
  +            ((Disposable)app).dispose();            
  +        }
  +
  +    }
  +
  +
       public void service(ServiceManager serviceManager) throws 
ServiceException {
           this.serviceManager = serviceManager;
       }
  +
   
   }
  
  
  

Reply via email to