cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/apples/java/org/apache/cocoon/components/flow/apples ApplesProcessor.java
Date Fri, 04 Jun 2004 15:13:07 GMT
bruno       2004/06/04 08:13:07

  Modified:    src/blocks/apples/java/org/apache/cocoon/components/flow/apples
                        ApplesProcessor.java
  Log:
  Supply cocoon avalon context as parent context
  Some isDebugEnabled's
  Added support for stateless apples
  
  Revision  Changes    Path
  1.13      +31 -8     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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ApplesProcessor.java	5 Mar 2004 13:01:38 -0000	1.12
  +++ ApplesProcessor.java	4 Jun 2004 15:13:07 -0000	1.13
  @@ -50,14 +50,19 @@
   
           AppleController app = instantiateController(className);
   
  -        WebContinuation wk = this.continuationsMgr.createWebContinuation(app, null, 0,
this);
  +        WebContinuation wk = null;
  +        if (!(app instanceof StatelessAppleController)) {
  +            wk = this.continuationsMgr.createWebContinuation(app, null, 0, this);
  +            if (getLogger().isDebugEnabled())
  +                getLogger().debug("Instantiated a stateful apple, continuationid = " +
wk.getId());
  +        }
   
  -        DefaultContext appleContext = new DefaultContext();
  -        appleContext.put("continuation-id", wk.getId());
  +        DefaultContext appleContext = new DefaultContext(avalonContext);
  +        if (wk != null) {
  +            appleContext.put("continuation-id", wk.getId());
  +        }
   
  -        getLogger().debug("Pulling fresh apple through the lifecycle... | continuationid="
+ wk.getId());
  -        
  -        LifecycleHelper.setupComponent( app, getLogger(), appleContext, 
  +        LifecycleHelper.setupComponent( app, getLogger(), appleContext,
                                           this.serviceManager, new WrapperComponentManager(this.serviceManager),
 
                                           null, null, true);
           
  @@ -115,13 +120,31 @@
           Request cocoonRequest = ContextHelper.getRequest(this.avalonContext);
           AppleRequest req = new DefaultAppleRequest(params, cocoonRequest);
           DefaultAppleResponse res = new DefaultAppleResponse();
  -        app.process(req, res);
  +
  +        try {
  +            app.process(req, res);
  +        } finally {
  +            if (wk == null) {
  +                // dispose stateless apple immediatelly
  +                if (app instanceof Disposable) {
  +                    try {
  +                        ((Disposable)app).dispose();
  +                    } catch (Exception e) {
  +                        getLogger().error("Error disposing Apple instance.", e);
  +                    }
  +                }
  +            }
  +        }
   
           if (res.isRedirect()) {
               redirector.redirect(false, res.getURI());
           } else {
               String uri = res.getURI();
  -            getLogger().debug("Apple forwards to " + uri + " with bizdata= " + res.getData()
+ " and continuationid= " + wk.getId());
  +            if (getLogger().isDebugEnabled()) {
  +                getLogger().debug("Apple forwards to " + uri + " with bizdata= " + res.getData()
+ (wk != null ? " and continuationid= " + wk.getId() : " without continuationid"));
  +            }
  +
  +            // Note: it is ok for wk to be null
               this.forwardTo(uri, res.getData(), wk, redirector);
           }
   
  
  
  

Mime
View raw message