cziegeler    2003/03/10 07:57:24

  Modified:    src/java/org/apache/cocoon/environment
                        ForwardRedirector.java
  Log:
  Fixing releasing of processor
  
  Revision  Changes    Path
  1.2       +24 -9     
cocoon-2.0/src/java/org/apache/cocoon/environment/ForwardRedirector.java
  
  Index: ForwardRedirector.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.0/src/java/org/apache/cocoon/environment/ForwardRedirector.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ForwardRedirector.java    9 Mar 2003 00:02:53 -0000       1.1
  +++ ForwardRedirector.java    10 Mar 2003 15:57:24 -0000      1.2
  @@ -56,6 +56,7 @@
   import org.apache.avalon.framework.component.ComponentManager;
   
   import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
  +import org.apache.cocoon.components.CocoonComponentManager;
   import org.apache.cocoon.components.pipeline.StreamPipeline;
   import org.apache.cocoon.components.pipeline.EventPipeline;
   
  @@ -146,8 +147,11 @@
           this.hasRedirected = true;
       }
       
  -    private void cocoonRedirect(boolean sessionMode, String uri) throws 
IOException, ProcessingException {
  -    try {
  +    private void cocoonRedirect(boolean sessionMode, String uri) 
  +    throws IOException, ProcessingException {
  +        Processor actualProcessor = null;
  +        try {
  +            Processor usedProcessor;
               boolean rawMode = false;
               String prefix;
       
  @@ -162,7 +166,7 @@
                   }
               }
       
  -            Processor actualProcessor;
  +            
               
               // Does the uri point to this sitemap or to the root sitemap?
               if (uri.startsWith("//")) {
  @@ -170,6 +174,7 @@
                   prefix = ""; // start at the root
                   try {
                       actualProcessor = 
(Processor)this.manager.lookup(Processor.ROLE);
  +                    usedProcessor = actualProcessor;
                   } catch (ComponentException e) {
                       throw new ProcessingException("Cannot get Processor instance", 
e);
                   }
  @@ -177,7 +182,7 @@
               } else if (uri.startsWith("/")) {
                   prefix = null; // means use current prefix
                   uri = uri.substring(1);
  -                actualProcessor = this.processor;
  +                usedProcessor = this.processor;
       
               } else {
                   throw new ProcessingException("Malformed cocoon URI.");
  @@ -200,11 +205,19 @@
       
               boolean processingResult;
               
  -            if (this.eventPipe == null && this.streamPipe == null) {
  -                processingResult = actualProcessor.process(newEnv);
  -            } else {
  -                processingResult = actualProcessor.process(newEnv, this.streamPipe, 
this.eventPipe);
  +            // FIXME - What to do here?
  +            Object processKey = CocoonComponentManager.startProcessing(newEnv);
  +            try {
  +                    
  +                if (this.eventPipe == null && this.streamPipe == null) {
  +                    processingResult = usedProcessor.process(newEnv);
  +                } else {
  +                    processingResult = usedProcessor.process(newEnv, 
this.streamPipe, this.eventPipe);
  +                }
  +            } finally {
  +                CocoonComponentManager.endProcessing(newEnv, processKey);
               }
  +    
               
               if (!processingResult) {
                   throw new ProcessingException("Couldn't process URI " + requestURI);
  @@ -218,6 +231,8 @@
               String msg = "Error while redirecting to " + uri;
               getLogger().error(msg, e);
               throw new ProcessingException(msg, e);
  +        } finally {
  +            this.manager.release( actualProcessor );
           }
       }
   
  
  
  

Reply via email to