cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r619047 - in /cocoon/whiteboard/micro/core: cocoon-core/src/main/resources/META-INF/cocoon/avalon/ cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/ cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/...
Date Wed, 06 Feb 2008 16:12:05 GMT
Author: reinhard
Date: Wed Feb  6 08:11:45 2008
New Revision: 619047

URL: http://svn.apache.org/viewvc?rev=619047&view=rev
Log:
remove SitemapSource and cocoon:/ redirects

Removed:
    cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSource.java
    cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/SitemapSourceFactory.java
    cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/environment/internal/ForwardEnvironmentWrapper.java
    cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
    cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/environment/wrapper/MutableEnvironmentFacade.java
Modified:
    cocoon/whiteboard/micro/core/cocoon-core/src/main/resources/META-INF/cocoon/avalon/cocoon-core-source-factories.xconf
    cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/ForwardRedirector.java
    cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java

Modified: cocoon/whiteboard/micro/core/cocoon-core/src/main/resources/META-INF/cocoon/avalon/cocoon-core-source-factories.xconf
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/core/cocoon-core/src/main/resources/META-INF/cocoon/avalon/cocoon-core-source-factories.xconf?rev=619047&r1=619046&r2=619047&view=diff
==============================================================================
--- cocoon/whiteboard/micro/core/cocoon-core/src/main/resources/META-INF/cocoon/avalon/cocoon-core-source-factories.xconf
(original)
+++ cocoon/whiteboard/micro/core/cocoon-core/src/main/resources/META-INF/cocoon/avalon/cocoon-core-source-factories.xconf
Wed Feb  6 08:11:45 2008
@@ -33,8 +33,6 @@
                         class="org.apache.excalibur.source.impl.ResourceSourceFactory"/>
     <component-instance name="context"
                         class="org.apache.cocoon.components.source.impl.ContextSourceFactory"/>
-    <component-instance name="cocoon"
-                        class="org.apache.cocoon.components.source.impl.SitemapSourceFactory"/>
     <component-instance name="blockcontext"
                         class="org.apache.cocoon.components.source.impl.BlockContextSourceFactory"/>
     <!--

Modified: cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/ForwardRedirector.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/ForwardRedirector.java?rev=619047&r1=619046&r2=619047&view=diff
==============================================================================
--- cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/ForwardRedirector.java
(original)
+++ cocoon/whiteboard/micro/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/ForwardRedirector.java
Wed Feb  6 08:11:45 2008
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,21 +23,20 @@
 import org.apache.cocoon.util.AbstractLogEnabled;
 
 /**
- * A base class for <code>Redirector</code>s that handle forward redirects, i.e.
internal
- * redirects using the "cocoon:" pseudo-protocol.
  * <p>
- * Concrete subclasses have to define the <code>cocoonRedirect()</code> method.
+ * A base class for <code>Redirector</code>s that handle forward redirects.
+ * </p>
  *
  * @version $Id$
  */
-public abstract class ForwardRedirector extends AbstractLogEnabled
+public class ForwardRedirector extends AbstractLogEnabled
                                         implements Redirector, PermanentRedirector {
 
     /**
      * Was there a call to <code>redirect()</code> ?
      */
     private boolean hasRedirected = false;
-    
+
     /** The <code>Environment to use for redirection (either internal or external)
*/
     protected Environment env;
 
@@ -49,21 +48,14 @@
     }
 
     /**
-     * Redirects to a given URL. If this URL starts with "cocoon:", then an internal
-     * redirect is performed. Otherwise, an external redirect is send to the
-     * environment.
+     * Redirects to a given URL.
      */
     public void redirect(boolean sessionMode, String url) throws IOException, ProcessingException
{
         if (getLogger().isInfoEnabled()) {
             getLogger().info("Redirecting to '" + url + "'");
         }
 
-        if (url.startsWith("cocoon:")) {
-            cocoonRedirect(url);
-        } else {
-            this.doRedirect(sessionMode, url, false, false);
-        }
-
+        this.doRedirect(sessionMode, url, false, false);
         this.hasRedirected = true;
     }
 
@@ -72,43 +64,32 @@
             getLogger().info("Redirecting to '" + url + "'");
         }
 
-        if (url.startsWith("cocoon:")) {
-            cocoonRedirect(url);
-        } else {
-            this.doRedirect(sessionMode, url, true, false);
-        }
-
+        this.doRedirect(sessionMode, url, true, false);
         this.hasRedirected = true;
     }
 
     /**
-     * Unconditionally redirects to a given URL, even it this redirector is part of a
-     * subpipeline.
+     * Unconditionally redirects to a given URL
      */
     public void globalRedirect(boolean sessionMode, String url) throws IOException, ProcessingException
{
         if (getLogger().isInfoEnabled()) {
             getLogger().info("Redirecting to '" + url + "'");
         }
 
-        // FIXME : how to handle global redirect to cocoon: ?
-        if (url.startsWith("cocoon:")) {
-            cocoonRedirect(url);
-        } else {
-            this.doRedirect(sessionMode, url, false, true);
-        }
+        this.doRedirect(sessionMode, url, false, true);
         this.hasRedirected = true;
     }
 
-    protected abstract void cocoonRedirect(String uri) throws IOException, ProcessingException;
-
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.cocoon.environment.Redirector#hasRedirected()
      */
     public boolean hasRedirected() {
         return this.hasRedirected;
     }
-    
-    /* (non-Javadoc)
+
+    /**
+     * {@inheritDoc}
      * @see org.apache.cocoon.environment.Redirector#sendStatus(int)
      */
     public void sendStatus(int sc) {
@@ -120,13 +101,13 @@
     /**
      * Redirect the client to new URL with session mode
      */
-    protected void doRedirect(boolean sessionmode, 
+    protected void doRedirect(boolean sessionmode,
                               String newURL,
                               boolean permanent,
                               boolean global)
     throws IOException {
         final Request request = ObjectModelHelper.getRequest(this.env.getObjectModel());
-        
+
         // check if session mode shall be activated
         if (sessionmode) {
             // The session

Modified: cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java?rev=619047&r1=619046&r2=619047&view=diff
==============================================================================
--- cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
(original)
+++ cocoon/whiteboard/micro/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/treeprocessor/ConcreteTreeProcessor.java
Wed Feb  6 08:11:45 2008
@@ -16,7 +16,6 @@
  */
 package org.apache.cocoon.components.treeprocessor;
 
-import java.io.IOException;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -25,21 +24,13 @@
 
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.service.ServiceManager;
-import org.springframework.beans.factory.config.ConfigurableBeanFactory;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.web.context.WebApplicationContext;
-
-import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.Processor;
-import org.apache.cocoon.components.source.impl.SitemapSourceInfo;
 import org.apache.cocoon.core.container.spring.avalon.AvalonUtils;
 import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.environment.ForwardRedirector;
 import org.apache.cocoon.environment.Redirector;
 import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.environment.internal.EnvironmentHelper;
-import org.apache.cocoon.environment.internal.ForwardEnvironmentWrapper;
-import org.apache.cocoon.environment.wrapper.MutableEnvironmentFacade;
 import org.apache.cocoon.sitemap.EnterSitemapEvent;
 import org.apache.cocoon.sitemap.EnterSitemapEventListener;
 import org.apache.cocoon.sitemap.ExecutionContext;
@@ -50,6 +41,9 @@
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.cocoon.util.location.Location;
 import org.apache.cocoon.util.location.LocationImpl;
+import org.springframework.beans.factory.config.ConfigurableBeanFactory;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.web.context.WebApplicationContext;
 
 /**
  * The concrete implementation of {@link Processor}, containing the evaluation tree and associated
@@ -231,8 +225,7 @@
             final Redirector oldRedirector = context.getRedirector();
             try {
                 // Build a redirector
-                TreeProcessorRedirector redirector = new TreeProcessorRedirector(environment,
context);
-                context.setRedirector(redirector);
+                context.setRedirector(new ForwardRedirector(environment));
                 context.service(this.manager);
                 context.setLastProcessor(this);
 
@@ -242,7 +235,6 @@
                 // Restore old redirector
                 context.setRedirector(oldRedirector);
             }
-
         } finally {
             if (handle != null) {
                 this.sitemapExecutor.leaveSitemap(this, environment.getObjectModel());
@@ -272,57 +264,6 @@
         }
     }
 
-    protected boolean handleCocoonRedirect(String uri, Environment env, InvokeContext context)
-    throws Exception {
-        Environment environment = env;
-        // Build an environment wrapper
-        // If the current env is a facade, change the delegate and continue processing the
facade, since
-        // we may have other redirects that will in turn also change the facade delegate
-
-        MutableEnvironmentFacade facade = environment instanceof MutableEnvironmentFacade
?
-            ((MutableEnvironmentFacade)environment) : null;
-
-        if (facade != null) {
-            // Consider the facade delegate (the real environment)
-            environment = facade.getDelegate();
-        }
-
-        // test if this is a call from flow
-        boolean isRedirect = (environment.getObjectModel().remove("cocoon:forward") == null);
-        final SitemapSourceInfo info = SitemapSourceInfo.parseURI(environment, uri);
-        Environment newEnv = new ForwardEnvironmentWrapper(environment, info);
-        if (isRedirect) {
-            ((ForwardEnvironmentWrapper) newEnv).setInternalRedirect(true);
-        }
-
-        if (facade != null) {
-            // Change the facade delegate
-            facade.setDelegate((ForwardEnvironmentWrapper)newEnv);
-            newEnv = facade;
-        }
-
-        // Get the processor that should process this request
-        ConcreteTreeProcessor processor;
-        if (newEnv.getURIPrefix().equals("")) {
-            processor = ((TreeProcessor)getRootProcessor()).concreteProcessor;
-        } else {
-            processor = this;
-        }
-
-        // Process the redirect
-        // No more reset since with TreeProcessorRedirector, we need to pop values from the
redirect location
-        // context.reset();
-        // The following is a fix for bug #26854 and #26571
-        final boolean result = processor.process(newEnv, context);
-        if (facade != null) {
-            newEnv = facade.getDelegate();
-        }
-        if (((ForwardEnvironmentWrapper) newEnv).getRedirectURL() != null) {
-            environment.redirect(((ForwardEnvironmentWrapper) newEnv).getRedirectURL(), false,
false);
-        }
-        return result;
-    }
-
     /**
      * @see org.apache.avalon.framework.activity.Disposable#dispose()
      */
@@ -350,29 +291,6 @@
                 ((ConfigurableBeanFactory)webAppContext).destroySingletons();
             }
             this.webAppContext = null;
-        }
-    }
-
-    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 {
-                ConcreteTreeProcessor.this.handleCocoonRedirect(uri, this.env, this.context);
-            } catch (IOException e) {
-                throw e;
-            } catch (ProcessingException e) {
-                throw e;
-            } catch (RuntimeException e) {
-                throw e;
-            } catch (Exception e) {
-                throw new ProcessingException(e);
-            }
         }
     }
 



Mime
View raw message