cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sylv...@apache.org
Subject cvs commit: cocoon-2.2/src/java/org/apache/cocoon/environment/internal EnvironmentHelper.java
Date Fri, 20 Feb 2004 18:57:15 GMT
sylvain     2004/02/20 10:57:15

  Modified:    src/java/org/apache/cocoon/components/cprocessor
                        InvokeContext.java TreeProcessor.java
               src/java/org/apache/cocoon/components/cprocessor/sitemap
                        ActNode.java AggregateNode.java
                        CallFunctionNode.java CallResourceNode.java
                        RedirectToURINode.java
               src/java/org/apache/cocoon/environment
                        ForwardRedirector.java
               src/java/org/apache/cocoon/environment/internal
                        EnvironmentHelper.java
  Log:
  Updates after flowscript upgrade
  
  Revision  Changes    Path
  1.8       +23 -1     cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/InvokeContext.java
  
  Index: InvokeContext.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/InvokeContext.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- InvokeContext.java	6 Feb 2004 11:42:46 -0000	1.7
  +++ InvokeContext.java	20 Feb 2004 18:57:15 -0000	1.8
  @@ -64,6 +64,7 @@
   import org.apache.cocoon.Processor;
   import org.apache.cocoon.components.pipeline.ProcessingPipeline;
   import org.apache.cocoon.components.cprocessor.variables.VariableResolver;
  +import org.apache.cocoon.environment.Redirector;
   
   /**
    * The invocation context of <code>ProcessingNode</code>s.
  @@ -112,6 +113,9 @@
       /** The last processor */
       protected Processor lastProcessor;
       
  +    /** The redirector */
  +    protected Redirector redirector;
  +    
       /**
        * Create an <code>InvokeContext</code> without existing pipelines. This
also means
        * the current request is external.
  @@ -296,6 +300,24 @@
           Object name = mapToName.get(map);
           mapToName.remove(map);
           nameToMap.remove(name);
  +    }
  +    
  +    /**
  +     * Set the redirector to be used by nodes that need it.
  +     * 
  +     * @param redirector the redirector
  +     */
  +    public void setRedirector(Redirector redirector) {
  +        this.redirector = redirector;
  +    }
  +    
  +    /**
  +     * Get the redirector to be used by nodes that need it.
  +     * 
  +     * @return the redirector
  +     */
  +    public Redirector getRedirector() {
  +        return this.redirector;
       }
       
       /**
  
  
  
  1.19      +35 -16    cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/TreeProcessor.java
  
  Index: TreeProcessor.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/TreeProcessor.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- TreeProcessor.java	6 Feb 2004 11:42:46 -0000	1.18
  +++ TreeProcessor.java	20 Feb 2004 18:57:15 -0000	1.19
  @@ -50,6 +50,7 @@
   */
   package org.apache.cocoon.components.cprocessor;
   
  +import java.io.IOException;
   import java.net.MalformedURLException;
   import java.util.Collections;
   import java.util.HashMap;
  @@ -77,12 +78,14 @@
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
   import org.apache.cocoon.Constants;
  +import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.Processor;
   import org.apache.cocoon.components.ChainedConfiguration;
   import org.apache.cocoon.components.sax.XMLTeePipe;
   import org.apache.cocoon.components.source.SourceUtil;
   import org.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper;
   import org.apache.cocoon.environment.Environment;
  +import org.apache.cocoon.environment.ForwardRedirector;
   import org.apache.cocoon.environment.internal.EnvironmentHelper;
   import org.apache.cocoon.environment.wrapper.EnvironmentWrapper;
   import org.apache.cocoon.environment.wrapper.MutableEnvironmentFacade;
  @@ -288,22 +291,14 @@
           
           // and now process
           EnvironmentHelper.enterProcessor(this, m_manager, environment);
  +        
  +        // Build a redirector
  +        TreeProcessorRedirector redirector = new TreeProcessorRedirector(environment, context);
  +        setupLogger(redirector);
  +        context.setRedirector(redirector);
           try {
  -            if (rootNode.invoke(environment, context)) {
  -                // Do we have a cocoon: redirect ?
  -                String cocoonRedirect = (String) environment.getAttribute(COCOON_REDIRECT_ATTR);
  -                if (cocoonRedirect != null) {
  -                    // Remove the redirect indication
  -                    environment.removeAttribute(COCOON_REDIRECT_ATTR);
  -                    // and handle the redirect
  -                    return handleCocoonRedirect(cocoonRedirect, environment, context);
  -                } else {
  -                    // "normal" success
  -                    return true;
  -                }
  -            } else {
  -                return false;
  -            }
  +            boolean success = rootNode.invoke(environment, context);
  +            return success;
           } finally {
               EnvironmentHelper.leaveProcessor();
           }
  @@ -447,7 +442,8 @@
           }
           
           // Process the redirect
  -        context.reset();
  +//      No more reset since with TreeProcessorRedirector, we need to pop values from the
redirect location
  +//             context.reset();
           return processor.process(newEnv, context);
       }
       
  @@ -557,6 +553,29 @@
           return new TreeProcessor(this, delayedSource, checkReload, prefix);
       }
       
  +    private class TreeProcessorRedirector extends ForwardRedirector {
  +        
  +        private InvokeContext context;
  +        public TreeProcessorRedirector(Environment env, InvokeContext context) {
  +            super(env);
  +            this.context = context;
  +        }
  +        
  +        protected void cocoonRedirect(String uri) throws IOException, ProcessingException
{
  +            try {
  +                TreeProcessor.this.handleCocoonRedirect(uri, this.env, this.context);
  +            } catch(IOException ioe) {
  +                throw ioe;
  +            } catch(ProcessingException pe) {
  +                throw pe;
  +            } catch(RuntimeException re) {
  +                throw re;
  +            } catch(Exception ex) {
  +                throw new ProcessingException(ex);
  +            }
  +        }
  +    }
  +
       /**
        * Local extension of EnvironmentWrapper to propagate otherwise blocked
        * methods to the actual environment.
  
  
  
  1.5       +3 -3      cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/ActNode.java
  
  Index: ActNode.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/ActNode.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ActNode.java	28 Jan 2004 10:17:12 -0000	1.4
  +++ ActNode.java	20 Feb 2004 18:57:15 -0000	1.5
  @@ -190,7 +190,7 @@
   
               Map result = m_actionSetNode.call(env, context, resolvedParams);
   
  -            if (EnvironmentHelper.getRedirector(env).hasRedirected()) {
  +            if (context.getRedirector().hasRedirected()) {
                   return true;
   
               } else if (result == null) {
  @@ -209,7 +209,7 @@
   
           // Prepare data needed by the action
           Map            objectModel    = env.getObjectModel();
  -        Redirector     redirector     = EnvironmentHelper.getRedirector(env);
  +        Redirector     redirector     = context.getRedirector();
           String         resolvedSource = m_source.resolve(context, objectModel);
           Parameters     resolvedParams = VariableResolver.buildParameters(super.m_parameters,
context, objectModel);
   
  
  
  
  1.4       +6 -1      cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/AggregateNode.java
  
  Index: AggregateNode.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/AggregateNode.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AggregateNode.java	28 Jan 2004 17:25:30 -0000	1.3
  +++ AggregateNode.java	20 Feb 2004 18:57:15 -0000	1.4
  @@ -91,6 +91,11 @@
    *
    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
    * @version CVS $Id$
  + * 
  + * @avalon.component
  + * @avalon.service type=ProcessingNode
  + * @x-avalon.lifestyle type=singleton
  + * @x-avalon.info name=aggregate-node
    */
   public class AggregateNode extends AbstractProcessingNode {
   
  
  
  
  1.6       +4 -4      cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/CallFunctionNode.java
  
  Index: CallFunctionNode.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/CallFunctionNode.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CallFunctionNode.java	27 Jan 2004 13:41:40 -0000	1.5
  +++ CallFunctionNode.java	20 Feb 2004 18:57:15 -0000	1.6
  @@ -152,7 +152,7 @@
       }
   
       public boolean invoke(Environment env, InvokeContext context) throws Exception {
  -        Redirector redirector = EnvironmentHelper.getRedirector(env);
  +        Redirector redirector = context.getRedirector();
           
           List params = null;
   
  @@ -166,7 +166,7 @@
           // If the continuation id is not null, it takes precedence over
           // the function call, so we invoke it here.
           if (continuation != null && continuation.length() > 0) {
  -            m_interpreter.handleContinuation(continuation, params, env);
  +            m_interpreter.handleContinuation(continuation, params, redirector);
               if (!redirector.hasRedirected()) {
                   String msg = "<map:call continuation> did not send a response, at
" + getLocation();
                   throw new ProcessingException(msg);
  @@ -180,7 +180,7 @@
           String name = m_functionName.resolve(context, env.getObjectModel());
   
           if (name != null && name.length() > 0) {
  -            m_interpreter.callFunction(name, params, env);
  +            m_interpreter.callFunction(name, params, redirector);
               if (!redirector.hasRedirected()) {
                   String msg = "<map:call function='" + name + "'> did not send a response,
at " + getLocation();
                   throw new ProcessingException(msg);
  
  
  
  1.2       +2 -2      cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/CallResourceNode.java
  
  Index: CallResourceNode.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/CallResourceNode.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CallResourceNode.java	28 Dec 2003 21:03:17 -0000	1.1
  +++ CallResourceNode.java	20 Feb 2004 18:57:15 -0000	1.2
  @@ -70,7 +70,7 @@
    * @avalon.component
    * @avalon.service type=ProcessingNode
    * @x-avalon.lifestyle type=singleton
  - * @x-avalon.info name=call-function
  + * @x-avalon.info name=call-resource
    */
   public class CallResourceNode extends AbstractProcessingNode implements Initializable {
   
  
  
  
  1.5       +2 -2      cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/RedirectToURINode.java
  
  Index: RedirectToURINode.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/cprocessor/sitemap/RedirectToURINode.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RedirectToURINode.java	27 Jan 2004 13:41:38 -0000	1.4
  +++ RedirectToURINode.java	20 Feb 2004 18:57:15 -0000	1.5
  @@ -105,7 +105,7 @@
               getLogger().info("Redirecting to '" + resolvedURI + "' at " + getLocation());
           }
   
  -        final Redirector redirector = EnvironmentHelper.getRedirector(env);
  +        final Redirector redirector = context.getRedirector();
   
           if (m_global) {
               redirector.globalRedirect(m_createSession, resolvedURI);
  
  
  
  1.16      +5 -11     cocoon-2.2/src/java/org/apache/cocoon/environment/ForwardRedirector.java
  
  Index: ForwardRedirector.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/ForwardRedirector.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ForwardRedirector.java	10 Jan 2004 14:38:19 -0000	1.15
  +++ ForwardRedirector.java	20 Feb 2004 18:57:15 -0000	1.16
  @@ -54,8 +54,7 @@
   
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.components.cprocessor.TreeProcessor;
  -import org.apache.cocoon.environment.internal.*;
  +import org.apache.cocoon.environment.internal.EnvironmentHelper;
   
   /**
    * A <code>Redirector</code> that handles forward redirects, i.e. internal
  @@ -64,9 +63,7 @@
    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
    * @version CVS $Id$
    */
  -public class ForwardRedirector
  -extends AbstractLogEnabled 
  -implements Redirector, PermanentRedirector {
  +public abstract class ForwardRedirector extends AbstractLogEnabled implements Redirector,
PermanentRedirector {
   
       /**
        * Was there a call to <code>redirect()</code> ?
  @@ -74,7 +71,7 @@
       private boolean hasRedirected = false;
       
       /** The <code>Environment to use for redirection (either internal or external)
*/
  -    private Environment env;
  +    protected Environment env;
   
       public ForwardRedirector(Environment env) {
           this.env = env;
  @@ -131,10 +128,7 @@
           this.hasRedirected = true;
       }
   
  -    private void cocoonRedirect(String uri) {
  -        // Simply notify the Processor.
  -        this.env.setAttribute(TreeProcessor.COCOON_REDIRECT_ATTR, uri);
  -    }
  +    protected abstract void cocoonRedirect(String uri) throws IOException, ProcessingException;;
   
       /**
        * Perform check on whether redirection has occured or not
  
  
  
  1.8       +7 -8      cocoon-2.2/src/java/org/apache/cocoon/environment/internal/EnvironmentHelper.java
  
  Index: EnvironmentHelper.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/java/org/apache/cocoon/environment/internal/EnvironmentHelper.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- EnvironmentHelper.java	20 Feb 2004 09:40:15 -0000	1.7
  +++ EnvironmentHelper.java	20 Feb 2004 18:57:15 -0000	1.8
  @@ -88,12 +88,6 @@
   extends AbstractLogEnabled
   implements SourceResolver, Serviceable, Disposable {
   
  -    /** The key used to store the current redirector 
  -     * in the environment context 
  -     * TODO: THIS WILL BE REMOVED SOON
  -     * */
  -    private static final String REDIRECTOR_KEY = "global:" + Redirector.class.getName();
  -
       /** The key used to store the current environment context
        * in the object model */
       static protected final String PROCESS_KEY = EnvironmentHelper.class.getName();
  @@ -382,7 +376,6 @@
               }
           }
           // redirect
  -        final Response response = ObjectModelHelper.getResponse(env.getObjectModel());
           env.redirect(newURL, global, permanent);
       }
   
  @@ -406,6 +399,8 @@
           }
           stack.pushInfo(new EnvironmentInfo(processor, stack.getOffset(), manager, env));
           stack.setOffset(stack.size()-1);
  +<<<<<<< EnvironmentHelper.java
  +=======
           
           // TODO: THIS WILL BE REMOVED SOON
           EnvironmentContext ctx = (EnvironmentContext)env.getObjectModel().get(PROCESS_KEY);
  @@ -413,6 +408,7 @@
           ForwardRedirector redirector = new ForwardRedirector(env);
           redirector.enableLogging(processor.getEnvironmentHelper().getLogger());
           ctx.addAttribute(REDIRECTOR_KEY, redirector);
  +>>>>>>> 1.7
   
       }
   
  @@ -473,6 +469,8 @@
       }
       
       /**
  +<<<<<<< EnvironmentHelper.java
  +=======
        * Return the Redirector
        * TODO: THIS WILL BE REMOVED SOON
        */
  @@ -485,6 +483,7 @@
       }
       
       /**
  +>>>>>>> 1.7
        * Return the environment context
        * TODO: THIS WILL BE REMOVED SOON
        */
  
  
  

Mime
View raw message