cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jheym...@apache.org
Subject svn commit: r330548 [31/132] - in /cocoon/whiteboard/maven2/cocoon-flat-layout: ./ cocoon-ajax-block/ cocoon-ajax-block/api/ cocoon-ajax-block/api/src/ cocoon-ajax-block/api/src/main/ cocoon-ajax-block/api/src/main/java/ cocoon-ajax-block/api/src/main/...
Date Thu, 03 Nov 2005 14:00:48 GMT
Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallFunctionNode.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallFunctionNode.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallFunctionNode.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallFunctionNode.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,127 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.components.flow.Interpreter;
+import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode;
+import org.apache.cocoon.components.treeprocessor.InvokeContext;
+import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.Redirector;
+
+/**
+ * Node handler for calling functions and resuming continuations in
+ * the control flow layer.
+ *
+ * @author <a href="mailto:ovidiu@apache.org">Ovidiu Predescu</a>
+ * @since March 13, 2002
+ * @version CVS $Id: CallFunctionNode.java 233343 2005-08-18 18:06:44Z sylvain $
+ */
+public class CallFunctionNode extends AbstractProcessingNode implements ParameterizableProcessingNode {
+
+    protected Map parameters;
+    protected VariableResolver functionName;
+    protected VariableResolver continuationId;
+    protected String[] argumentNames;
+    protected Interpreter interpreter;
+
+    public CallFunctionNode(VariableResolver functionName, VariableResolver continuationId, String[] argumentNames) {
+        super(null);
+        this.functionName = functionName;
+        this.continuationId = continuationId;
+        this.argumentNames = argumentNames;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode#setParameters(java.util.Map)
+     */
+    public void setParameters(Map parameterMap) {
+        this.parameters = parameterMap;
+    }
+
+    public void setInterpreter(Interpreter interp) throws Exception {
+        this.interpreter = interp;
+    }
+
+    public boolean invoke(Environment env, InvokeContext context) throws Exception {
+
+        Map objectModel = env.getObjectModel();
+
+        // Resolve parameters
+        Parameters params = VariableResolver.buildParameters(this.parameters, context, objectModel);
+
+        // Build the list of positional arguments
+        //TODO (SW): Deprecate this in the future.
+        // It has be found to be bad practice to pass sitemap parameters
+        // as function arguments, as these are name-value pairs in the sitemap
+        // and positional arguments in the flowscript. If the user doesn't respect
+        // the argument order, this leads to difficult to solve bugs.
+        List args;
+        if (argumentNames.length != 0) {
+            args = new ArrayList(argumentNames.length);
+            for (int i = 0; i < argumentNames.length; i++) {
+                String name = argumentNames[i];
+                args.add(new Interpreter.Argument(name, params.getParameter(name)));
+            }
+        } else {
+            args = Collections.EMPTY_LIST;
+        }
+
+        // Need redirector in any case
+        Redirector redirector = context.getRedirector();
+
+        // If the continuation id is not null, it takes precedence over
+        // the function call, so we invoke it here.
+        String continuation = continuationId.resolve(context, env.getObjectModel());
+        if (continuation != null && continuation.length() > 0) {
+            try {
+                interpreter.handleContinuation(continuation, args, redirector);
+            } catch(Exception e) {
+                throw ProcessingException.throwLocated("Sitemap: error calling continuation", e, getLocation());
+            }
+            if (!redirector.hasRedirected()) {
+                throw new ProcessingException("Sitemap: <map:call continuation> did not send a response", getLocation());
+            }
+            return true;
+        }
+
+        // We don't have a continuation id passed in <map:call>, so invoke
+        // the specified function
+        String name = functionName.resolve(context, objectModel);
+        if (name != null && name.length() > 0) {
+            try {
+                interpreter.callFunction(name, args, redirector);
+            } catch(Exception e) {
+                throw ProcessingException.throwLocated("Sitemap: error calling function '" + name + "'", e, getLocation());
+            }
+            if (!redirector.hasRedirected()) {
+                throw new ProcessingException("Sitemap: <map:call function> did not send a response", getLocation());
+            }
+            return true;
+        }
+
+        // Found neither continuation nor function to call
+        throw new ProcessingException("Sitemap: no function nor continuation given in <map:call function>", getLocation());
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallFunctionNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNode.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNode.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNode.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNode.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,89 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import java.util.Map;
+
+import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode;
+import org.apache.cocoon.components.treeprocessor.CategoryNode;
+import org.apache.cocoon.components.treeprocessor.InvokeContext;
+import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
+import org.apache.cocoon.environment.Environment;
+
+/**
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: CallNode.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+
+public class CallNode extends AbstractProcessingNode
+    implements ParameterizableProcessingNode {
+
+    /** The parameters of this node */
+    private Map parameters;
+
+    /** The 'resource' attribute */
+    private VariableResolver resourceName;
+
+    /** The category node */
+    private CategoryNode resources;
+
+    public CallNode() {
+        super(null);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode#setParameters(java.util.Map)
+     */
+    public void setParameters(Map parameterMap) {
+        this.parameters = parameterMap;
+    }
+
+    public void setResource(CategoryNode resources, VariableResolver resourceName) throws Exception {
+        this.resourceName = resourceName;
+        this.resources = resources;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.components.treeprocessor.ProcessingNode#invoke(org.apache.cocoon.environment.Environment, org.apache.cocoon.components.treeprocessor.InvokeContext)
+     */
+    public final boolean invoke(Environment env, InvokeContext context)
+      throws Exception {
+
+        Map objectModel = env.getObjectModel();
+        // Resolve parameters, but push them only once the resource name has been
+        // resolved, otherwise it adds an unwanted nesting level
+        Map params = VariableResolver.buildMap(this.parameters, context, objectModel);
+
+        // Resolved resource name
+        String name = this.resourceName.resolve(context, objectModel);
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Calling resource " + name);
+        }
+        
+        // and only now push the parameters
+        params = this.executor.pushVariables(this, objectModel, null, params);
+        context.pushMap(null,params);
+        
+        try {
+            return this.resources.invokeByName(name, env, context);
+        } finally {
+            this.executor.popVariables(this, objectModel);
+            context.popMap();
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNodeBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNodeBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNodeBuilder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,128 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.cocoon.components.flow.Interpreter;
+import org.apache.cocoon.components.treeprocessor.AbstractProcessingNodeBuilder;
+import org.apache.cocoon.components.treeprocessor.CategoryNode;
+import org.apache.cocoon.components.treeprocessor.CategoryNodeBuilder;
+import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder;
+import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
+
+/**
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez </a>
+ * @author <a href="mailto:ovidiu@apache.org">Ovidiu Predescu </a>
+ * @version CVS $Id: CallNodeBuilder.java 55071 2004-10-19 15:39:30Z vgritsenko $
+ */
+public class CallNodeBuilder extends AbstractProcessingNodeBuilder
+                             implements LinkedProcessingNodeBuilder {
+
+    protected ProcessingNode node;
+
+    protected String resourceName;
+
+    protected String functionName;
+
+    protected String continuationId;
+
+    public ProcessingNode buildNode(Configuration config)
+    throws Exception {
+        resourceName = config.getAttribute("resource", null);
+        functionName = config.getAttribute("function", null);
+        continuationId = config.getAttribute("continuation", null);
+
+        if (resourceName == null) {
+            // Building a CallFunction node
+            if (functionName == null && continuationId == null) {
+                throw new ConfigurationException(
+                    "<map:call> must have either a 'resource', 'function' or 'continuation' attribute, at "
+                    + config.getLocation()
+                );
+            }
+
+            // Build the ordered list of parameter names
+            // FIXME(SW): remove this in the future (see comment in FlowNode)
+            List argumentNames = new ArrayList();
+            Configuration[] params = config.getChildren("parameter");
+            for (int i = 0; i < params.length; i++) {
+                argumentNames.add(params[i].getAttribute("name"));
+            }
+
+            node = new CallFunctionNode(VariableResolverFactory.getResolver(
+                functionName, this.manager),
+                VariableResolverFactory.getResolver(continuationId, this.manager),
+                (String[]) argumentNames.toArray(new String[argumentNames.size()])
+            );
+
+        } else {
+            // Building a Call(Resource)Node
+            if (functionName != null || continuationId != null) {
+                throw new ConfigurationException(
+                    "<map:call> cannot have both a 'resource' and a 'function' or 'continuation' attribute, at "
+                    + config.getLocation());
+            }
+            node = new CallNode();
+        }
+
+        this.treeBuilder.setupNode(this.node, config);
+        if (node instanceof Configurable) {
+            ((Configurable) this.node).configure(config);
+        }
+
+        return this.node;
+    }
+
+    public void linkNode() throws Exception {
+        if (resourceName != null) {
+            // We have a <map:call resource="..."/>
+            CategoryNode resources = CategoryNodeBuilder.getCategoryNode(treeBuilder, "resources");
+
+            if (resources == null)
+                throw new ConfigurationException(
+                    "This sitemap contains no resources. Cannot call at " + node.getLocation());
+
+            ((CallNode) this.node).setResource(
+                resources,
+                VariableResolverFactory.getResolver(this.resourceName, this.manager)
+            );
+        } else {
+            // We have a <map:call> with either "function" or
+            // "continuation", or both specified
+
+            // Check to see if a flow has been defined in this sitemap
+            FlowNode flow = (FlowNode) treeBuilder.getRegisteredNode("flow");
+            if (flow == null) {
+                throw new ConfigurationException(
+                    "This sitemap contains no control flows defined, cannot call at "
+                    + node.getLocation()
+                    + ". Define a control flow using <map:flow>, with embedded <map:script> elements.");
+            }
+
+            // Get the Interpreter instance and set it up in the
+            // CallFunctionNode function
+            Interpreter interpreter = flow.getInterpreter();
+            ((CallFunctionNode) node).setInterpreter(interpreter);
+        }
+    }
+}
\ No newline at end of file

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ComponentsNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ComponentsNodeBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ComponentsNodeBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ComponentsNodeBuilder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,51 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.cocoon.components.treeprocessor.AbstractProcessingNodeBuilder;
+import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+import org.apache.cocoon.components.treeprocessor.ProcessingNodeBuilder;
+
+/**
+ * Handles &lt;map:components&gt;. It doesn't actually create a <code>ProcessingNode</code>.
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: ComponentsNodeBuilder.java 160478 2005-04-07 22:18:29Z danielf $
+ */
+public class ComponentsNodeBuilder extends AbstractProcessingNodeBuilder {
+
+    private static String[] VPCTypes =
+    {"generators", "transformers", "serializers", "readers"};
+
+    /** This builder has no parameters -- return <code>false</code> */
+    protected boolean hasParameters() {
+        return false;
+    }
+
+    public ProcessingNode buildNode(Configuration config) throws Exception {
+        // Handle the VPCs
+        for (int i = 0; i < VPCTypes.length; i++) {
+            Configuration child = config.getChild(VPCTypes[i], false);
+            if (child != null) {
+                ProcessingNodeBuilder childBuilder =
+                    this.treeBuilder.createNodeBuilder(child);
+                childBuilder.buildNode(child);
+            }
+        }
+        return null;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ComponentsNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ComponentsSelector.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ComponentsSelector.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ComponentsSelector.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ComponentsSelector.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,165 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.cocoon.core.container.DefaultServiceSelector;
+import org.apache.cocoon.generation.GeneratorFactory;
+import org.apache.cocoon.serialization.SerializerFactory;
+import org.apache.cocoon.transformation.TransformerFactory;
+
+/**
+ * Component selector for sitemap components.
+ *
+ * @version CVS $Id: ComponentsSelector.java 154898 2005-02-22 21:54:48Z cziegeler $
+ */
+public class ComponentsSelector extends DefaultServiceSelector {
+
+    private static final int UNKNOWN     = -1;
+    private static final int GENERATOR   = 0;
+    private static final int TRANSFORMER = 1;
+    private static final int SERIALIZER  = 2;
+
+    /** Configuration element names, used to find the role */
+    private static final String[] CONFIG_NAMES = {
+        "generators",
+        "transformers",
+        "serializers",
+        "readers",
+        "matchers",
+        "selectors",
+        "actions",
+        "pipes"
+    };
+
+    /** Names of children elements, according to role */
+    private static final String[] COMPONENT_NAMES = {
+        "generator",
+        "transformer",
+        "serializer",
+        "reader",
+        "matcher",
+        "selector",
+        "action",
+        "pipe"
+    };
+
+    /** The role as an integer */
+    private int roleId;
+
+    /**
+     * Return the component instance name according to the selector role
+     * (e.g. "action" for "org.apache.cocoon.acting.Action").
+     */
+    protected String getComponentInstanceName() {
+        return COMPONENT_NAMES[this.roleId];
+    }
+
+    /**
+     * Get the attribute for class names. This is "src" for known roles, and
+     * "class" (the default) for other roles.
+     */
+    protected String getClassAttributeName() {
+        return "src";
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+     */
+    public void configure(Configuration config) throws ConfigurationException {
+        // Who are we ?
+        final String configName = config.getName();
+        this.roleId = UNKNOWN; // unknown
+        for (int i = 0; i < CONFIG_NAMES.length; i++) {
+            if (CONFIG_NAMES[i].equals(configName)) {
+                this.roleId = i;
+                break;
+            }
+        }
+        
+        if (this.roleId == UNKNOWN) {
+            throw new ConfigurationException("ComponentsSelector is reserved for sitemap components. Illegal use at " +
+                    config.getLocation());
+        }
+
+        super.configure(config);
+    }
+
+    /**
+     * Override parent to implement support for {@link GeneratorFactory},
+     * {@link TransformerFactory}, and {@link SerializerFactory}.
+     */
+    public Object select(Object hint) throws ServiceException {
+        final Object component = super.select(hint);
+
+        switch (this.roleId) {
+            case GENERATOR:
+                if (component instanceof GeneratorFactory) {
+                    return ((GeneratorFactory)component).getInstance();
+                }
+                break;
+            case TRANSFORMER:
+                if (component instanceof TransformerFactory) {
+                    return ((TransformerFactory)component).getInstance();
+                }
+                break;
+            case SERIALIZER:
+                if (component instanceof SerializerFactory) {
+                    return ((SerializerFactory)component).getInstance();
+                }
+                break;
+        }
+
+        return component;
+    }
+
+    /**
+     * Override parent to implement support for {@link GeneratorFactory},
+     * {@link TransformerFactory}, and {@link SerializerFactory}.
+     */
+    public void release(Object component) {
+
+        // If component is an Instance returned by Factory, get the Factory.
+        switch (this.roleId) {
+            case GENERATOR:
+                if (component instanceof GeneratorFactory.Instance) {
+                    // Dispose component, if needed
+                    ContainerUtil.dispose(component);
+                    component = ((GeneratorFactory.Instance)component).getFactory();
+                }
+                break;
+            case TRANSFORMER:
+                if (component instanceof TransformerFactory.Instance) {
+                    // Dispose component, if needed
+                    ContainerUtil.dispose(component);
+                    component = ((TransformerFactory.Instance)component).getFactory();
+                }
+                break;
+            case SERIALIZER:
+                if (component instanceof SerializerFactory.Instance) {
+                    // Dispose component, if needed
+                    ContainerUtil.dispose(component);
+                    component = ((SerializerFactory.Instance)component).getFactory();
+                }
+                break;
+        }
+
+        super.release(component);
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ComponentsSelector.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ErrorHandlerHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ErrorHandlerHelper.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ErrorHandlerHelper.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ErrorHandlerHelper.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,240 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+
+import org.apache.cocoon.Constants;
+import org.apache.cocoon.Processor;
+import org.apache.cocoon.ResourceNotFoundException;
+import org.apache.cocoon.components.notification.Notifying;
+import org.apache.cocoon.components.notification.NotifyingBuilder;
+import org.apache.cocoon.components.treeprocessor.InvokeContext;
+import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.ObjectModelHelper;
+
+import java.io.IOException;
+import java.util.Map;
+
+/**
+ * Helps to call error handlers from PipelineNode and PipelinesNode.
+ *
+ * @author <a href="mailto:juergen.seitz@basf-it-services.com">J&uuml;rgen Seitz</a>
+ * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
+ * @version $Id: ErrorHandlerHelper.java 280345 2005-09-12 14:25:56Z cziegeler $
+ */
+public class ErrorHandlerHelper extends AbstractLogEnabled
+                                implements Serviceable {
+
+    private ServiceManager manager;
+
+    /**
+     * Logger for handled errors
+     */
+    protected Logger handledErrorsLogger;
+
+    /**
+     * Error handling node for the ResourceNotFoundException
+     * (deprecated)
+     */
+    private HandleErrorsNode error404;
+
+    /**
+     * Error handling node for all other exceptions
+     */
+    private HandleErrorsNode error500;
+
+    public void enableLogging(Logger logger) {
+        super.enableLogging(logger);
+        this.handledErrorsLogger = logger.getChildLogger("handled-errors");
+    }
+
+    /**
+     * The component manager is used to create notifying builders.
+     */
+    public void service(ServiceManager manager) {
+        this.manager = manager;
+    }
+
+    void set404Handler(ProcessingNode node) {
+        this.error404 = (HandleErrorsNode) node;
+    }
+
+    void set500Handler(ProcessingNode node) {
+        this.error500 = (HandleErrorsNode) node;
+    }
+
+    /**
+     * @return true if has no error handler nodes set
+     */
+    public boolean isEmpty() {
+        return this.error404 == null && this.error500 == null;
+    }
+
+    public boolean isInternal() {
+        return this.error500 != null && this.error500.isInternal();
+    }
+
+    public boolean isExternal() {
+        return this.error500 != null && this.error500.isExternal();
+    }
+
+    /**
+     * Handle error.
+     */
+    public boolean invokeErrorHandler(Exception ex,
+                                      Environment env,
+                                      InvokeContext context)
+    throws Exception {
+        final Processor.InternalPipelineDescription desc = prepareErrorHandler(ex, env, context);
+        if ( desc != null ) {
+            desc.release();
+            return true;
+        }
+        return  false;
+    }
+
+    /**
+     * Prepare error handler for the internal pipeline error handling.
+     *
+     * <p>If building pipeline only, error handling pipeline will be
+     * built and returned. If building and executing pipeline,
+     * error handling pipeline will be built and executed.</p>
+     */
+    public Processor.InternalPipelineDescription prepareErrorHandler(Exception ex,
+                                                                     Environment env,
+                                                                     InvokeContext context)
+    throws Exception {
+        boolean internal = !env.isExternal() && !env.isInternalRedirect();
+
+        if (internal && !isInternal()) {
+            // Propagate exception on internal request: No internal handler.
+            throw ex;
+        } else if (!internal && !isExternal()) {
+            // Propagate exception on external request: No external handler.
+            throw ex;
+        } else if (!internal && error404 != null && ex instanceof ResourceNotFoundException) {
+            // Invoke 404-specific handler: Only on external requests. Deprecated.
+            return prepareErrorHandler(error404, ex, env, context);
+        } else if (error500 != null) {
+            // Invoke global handler
+            return prepareErrorHandler(error500, ex, env, context);
+        }
+
+        // Exception was not handled in this error handler, propagate.
+        throw ex;
+    }
+
+    /**
+     * Handle error using specified error handler processing node.
+     */
+    public boolean invokeErrorHandler(ProcessingNode node,
+                                      Exception ex,
+                                      Environment env,
+                                      InvokeContext context)
+    throws Exception {
+        final Processor.InternalPipelineDescription desc = prepareErrorHandler(node, ex, env, context);
+        if ( desc != null ) {
+            desc.release();
+            return true;
+        }
+        return  false;
+    }
+
+    /**
+     * Prepare (or execute) error handler using specified error handler
+     * processing node.
+     *
+     * <p>If building pipeline only, error handling pipeline will be
+     * built and returned. If building and executing pipeline,
+     * error handling pipeline will be built and executed.</p>
+     */
+    private Processor.InternalPipelineDescription prepareErrorHandler(ProcessingNode node,
+                                                                      Exception ex,
+                                                                      Environment env,
+                                                                      InvokeContext context)
+    throws Exception {
+        if (ex instanceof ResourceNotFoundException) {
+            this.handledErrorsLogger.error(ex.getMessage());
+        } else {
+            this.handledErrorsLogger.error(ex.getMessage(), ex);
+        }
+
+        try {
+            prepare(context, env, ex);
+
+            // Create error context
+            InvokeContext errorContext = new InvokeContext(context.isBuildingPipelineOnly());
+            errorContext.enableLogging(getLogger());
+            errorContext.setRedirector(context.getRedirector());
+            errorContext.service(this.manager);
+            errorContext.inform(context.getPipelineType(), context.getPipelineParameters(), env.getObjectModel());
+            try {
+                // Process error handling node
+                if (node.invoke(env, errorContext)) {
+                    // Exception was handled.
+                    return errorContext.getInternalPipelineDescription(env);
+                }
+            } finally {
+                errorContext.dispose();
+            }
+        } catch (Exception e) {
+            getLogger().error("An exception occured while handling errors at " + node.getLocation(), e);
+            // Rethrow it: It will either be handled by the parent sitemap or by the environment (e.g. Cocoon servlet)
+            throw e;
+        }
+
+        // Exception was not handled in this error handler, propagate.
+        throw ex;
+    }
+
+    /**
+     * Build notifying object
+     */
+    private void prepare(InvokeContext context, Environment env, Exception ex)
+    throws IOException, ServiceException {
+        Map objectModel = env.getObjectModel();
+        if (objectModel.get(Constants.NOTIFYING_OBJECT) == null) {
+            // error has not been processed by another handler before
+
+            // Try to reset the response to avoid mixing already produced output
+            // and error page.
+            if (!context.isBuildingPipelineOnly()) {
+                env.tryResetResponse();
+            }
+
+            // Create a Notifying
+            NotifyingBuilder notifyingBuilder = (NotifyingBuilder) this.manager.lookup(NotifyingBuilder.ROLE);
+            Notifying currentNotifying = null;
+            try {
+                currentNotifying = notifyingBuilder.build(this, ex);
+            } finally {
+                this.manager.release(notifyingBuilder);
+            }
+
+            // Add it to the object model
+            objectModel.put(Constants.NOTIFYING_OBJECT, currentNotifying);
+
+            // Also add the exception
+            objectModel.put(ObjectModelHelper.THROWABLE_OBJECT, ex);
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/ErrorHandlerHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNode.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNode.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNode.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNode.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,107 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.avalon.framework.service.Serviceable;
+
+import org.apache.cocoon.components.flow.Interpreter;
+import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode;
+import org.apache.cocoon.components.treeprocessor.InvokeContext;
+import org.apache.cocoon.environment.Environment;
+
+/**
+ * Handler for &lt;map:flow&gt; element in the sitemap.
+ *
+ * @author <a href="mailto:ovidiu@apache.org">Ovidiu Predescu</a>
+ * @since September 13, 2002
+ * @version CVS $Id: FlowNode.java 233343 2005-08-18 18:06:44Z sylvain $
+ */
+public class FlowNode extends AbstractProcessingNode
+                      implements Serviceable, Disposable {
+
+    private ServiceManager manager;
+    private String language;
+    private Interpreter interpreter;
+    private ServiceSelector interpreterSelector;
+
+    public FlowNode(String language) {
+        this.language = language;
+    }
+
+    /**
+     * Lookup an flow {@link org.apache.cocoon.components.flow.Interpreter}
+     * instance to hold the scripts defined within the <code>&lt;map:flow&gt;</code>
+     * in the sitemap.
+     *
+     * @param manager a <code>ServiceManager</code> value
+     * @exception ServiceException if no flow interpreter could be obtained
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+
+        try {
+            this.interpreterSelector = (ServiceSelector) manager.lookup(Interpreter.ROLE + "Selector");
+            // Obtain the Interpreter instance for this language
+            this.interpreter = (Interpreter) this.interpreterSelector.select(language);
+            // Set interpreter ID as URI of the flow node (full sitemap file path)
+            this.interpreter.setInterpreterID(this.location.getURI());
+        } catch (ServiceException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new ServiceException(language,
+                                       "FlowNode: Couldn't obtain a flow interpreter for '" + language +
+                                       "' at " + getLocation(), e);
+        }
+    }
+
+    /**
+     * This method should never be called by the TreeProcessor, since a
+     * <code>&lt;map:flow&gt;</code> element should not be in an
+     * "executable" sitemap node.
+     *
+     * @param env an <code>Environment</code> value
+     * @param context an <code>InvokeContext</code> value
+     * @return a <code>boolean</code> value
+     * @exception Exception if an error occurs
+     */
+    public boolean invoke(Environment env, InvokeContext context) throws Exception {
+        return true;
+    }
+
+    public Interpreter getInterpreter() {
+        return interpreter;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public void dispose() {
+        if (this.manager != null) {
+            if (this.interpreterSelector != null) {
+                this.interpreterSelector.release(this.interpreter);
+                this.interpreter = null;
+
+                this.manager.release(this.interpreterSelector);
+                this.interpreterSelector = null;
+            }
+            this.manager = null;
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNodeBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNodeBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNodeBuilder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,48 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNodeBuilder;
+import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+
+/**
+ * Builder of a {@link FlowNode} instance, corresponding to a
+ * <code>&lt;map:flow&gt;</code> element in the sitemap.
+ *
+ * @author <a href="mailto:ovidiu@apache.org">Ovidiu Predescu</a>
+ * @since September 13, 2002
+ * @version CVS $Id: FlowNodeBuilder.java 290410 2005-09-20 10:13:19Z sylvain $
+ */
+public class FlowNodeBuilder extends AbstractParentProcessingNodeBuilder {
+
+    public ProcessingNode buildNode(Configuration config)
+    throws Exception {
+        String language = config.getAttribute("language", "javascript");
+        FlowNode node = new FlowNode(language);
+
+        if ( !this.treeBuilder.registerNode("flow", node) ) {
+            throw new ConfigurationException("Only one <map:flow> is allowed in a sitemap. Another one is declared at " +
+                    config.getLocation());
+        }
+        this.treeBuilder.setupNode(node, config);
+
+        buildChildNodesList(config);
+
+        return node;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/FlowNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNode.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNode.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNode.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNode.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,102 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import java.util.Map;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.components.treeprocessor.InvokeContext;
+import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode;
+import org.apache.cocoon.components.treeprocessor.PipelineEventComponentProcessingNode;
+import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.sitemap.SitemapExecutor;
+
+/**
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: GenerateNode.java 179045 2005-05-30 11:08:13Z cziegeler $
+ */
+public class GenerateNode extends PipelineEventComponentProcessingNode implements ParameterizableProcessingNode {
+
+    private String generatorName;
+
+    private VariableResolver source;
+
+    private Map parameters;
+
+
+    public GenerateNode(String name, VariableResolver source) {
+        this.generatorName = name;
+        this.source = source;
+    }
+
+    public void setParameters(Map parameterMap) {
+        this.parameters = parameterMap;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.components.treeprocessor.ProcessingNode#invoke(org.apache.cocoon.environment.Environment, org.apache.cocoon.components.treeprocessor.InvokeContext)
+     */
+    public final boolean invoke(Environment env, InvokeContext context)
+    throws Exception {
+
+        final Map objectModel = env.getObjectModel();
+        
+        SitemapExecutor.PipelineComponentDescription desc = new SitemapExecutor.PipelineComponentDescription();
+        desc.type = this.generatorName;
+        desc.source = source.resolve(context, objectModel);
+        desc.parameters = VariableResolver.buildParameters(this.parameters, context, objectModel);
+        desc.hintParameters = this.pipelineHints == null
+                ? Parameters.EMPTY_PARAMETERS
+                : VariableResolver.buildParameters(this.pipelineHints, context, objectModel);
+        
+        desc = this.executor.addGenerator(this, objectModel, desc);
+        
+        context.getProcessingPipeline().setGenerator(
+            desc.type,
+            desc.source,
+            desc.parameters,
+            desc.hintParameters
+        );
+
+
+        // Check view
+        if (this.views != null) {
+	 
+            //inform the pipeline that we have a branch point
+            context.getProcessingPipeline().informBranchPoint();
+
+            String cocoonView = env.getView();
+            if (cocoonView != null) {
+
+                // Get view node
+                ProcessingNode viewNode = (ProcessingNode)this.views.get(cocoonView);
+
+                if (viewNode != null) {
+                    if (getLogger().isInfoEnabled()) {
+                        getLogger().info("Jumping to view " + cocoonView + " from generator at " + this.getLocation());
+                    }
+                    return viewNode.invoke(env, context);
+                }
+            }
+        }
+
+        // Return false to continue sitemap invocation
+        return false;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNodeBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNodeBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNodeBuilder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,62 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.cocoon.components.treeprocessor.AbstractProcessingNodeBuilder;
+import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder;
+import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
+import org.apache.cocoon.generation.Generator;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: GenerateNodeBuilder.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+
+public class GenerateNodeBuilder extends AbstractProcessingNodeBuilder
+  implements LinkedProcessingNodeBuilder {
+
+    private GenerateNode node;
+
+    private Collection views;
+    private Map  pipelineHints;
+
+    public ProcessingNode buildNode(Configuration config) throws Exception {
+
+        String type = this.treeBuilder.getTypeForStatement(config, Generator.ROLE);
+
+        this.views = ((SitemapLanguage)this.treeBuilder).getViewsForStatement(Generator.ROLE, type, config);
+        this.pipelineHints = ((SitemapLanguage)this.treeBuilder).getHintsForStatement(Generator.ROLE, type, config);
+
+        this.node = new GenerateNode(
+            type,
+            VariableResolverFactory.getResolver(config.getAttribute("src", null), this.manager)
+        );
+        this.node.setPipelineHints(this.pipelineHints);
+        return this.treeBuilder.setupNode(this.node, config);
+    }
+
+    public void linkNode() throws Exception {
+        this.node.setViews(
+            ((SitemapLanguage)this.treeBuilder).getViewNodes(this.views)
+        );
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,124 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.Constants;
+import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode;
+import org.apache.cocoon.components.treeprocessor.InvokeContext;
+import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+import org.apache.cocoon.environment.Environment;
+import org.apache.commons.lang.SystemUtils;
+
+/**
+ * Handles &lt;map:handle-errors&gt;
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version $Id: HandleErrorsNode.java 179045 2005-05-30 11:08:13Z cziegeler $
+ */
+public final class HandleErrorsNode extends AbstractParentProcessingNode {
+
+    private ProcessingNode[] children;
+    private int statusCode;
+    private boolean internal;
+    private boolean external;
+
+    /**
+     * @param statusCode Value of the type attribute: 404 (deprecated), 500 (deprecated), or -1 (no attribute present).
+     * @param scope Value of the error handler scope attribute: external, internal, always.
+     */
+    public HandleErrorsNode(int statusCode, String scope)
+    throws ConfigurationException {
+        this.statusCode = statusCode;
+        if ("internal".equals(scope)) {
+            this.internal = true;
+        } else if ("external".equals(scope)) {
+            this.external = true;
+        } else if ("always".equals(scope)) {
+            this.internal = true;
+            this.external = true;
+        } else {
+            throw new ConfigurationException("Unrecognized value of when attribute on <handle-errors> at " +
+                                             getLocation());
+        }
+    }
+
+    public int getStatusCode() {
+        return this.statusCode;
+    }
+
+    public boolean isInternal() {
+        return this.internal;
+    }
+
+    public boolean isExternal() {
+        return this.external;
+    }
+
+    public void setChildren(ProcessingNode[] nodes) {
+        this.children = nodes;
+    }
+
+    public final boolean invoke(Environment env, InvokeContext context)
+    throws Exception {
+
+        if (getLogger().isInfoEnabled()) {
+            getLogger().info("Processing handle-errors at " + getLocation());
+        }
+
+		if (statusCode == -1) {
+            // No 'type' attribute : new Cocoon 2.1 behaviour, no implicit generator
+            try {
+                return invokeNodes(this.children, env, context);
+
+            } catch (ProcessingException e) {
+                // Handle the various cases related to the transition from implicit generators in handle-errors to
+                // explicit ones, in order to provide meaningful messages that will ease the migration
+                if (e.getMessage().indexOf("Must set a generator before adding") != -1) {
+
+                    env.getObjectModel().remove(Constants.NOTIFYING_OBJECT);
+                    throw new ProcessingException(
+                        "Incomplete pipeline: 'handle-error' without a 'type' must include a generator, at " +
+                        getLocation() + SystemUtils.LINE_SEPARATOR +
+                        "Either add a generator (preferred) or a type='500' attribute (deprecated) on 'handle-errors'");
+                }
+
+                // Rethrow the exception
+                throw e;
+            }
+		}
+	    // A 'type' attribute is present : add the implicit generator
+        context.getProcessingPipeline().setGenerator("<notifier>", "", Parameters.EMPTY_PARAMETERS, Parameters.EMPTY_PARAMETERS);
+
+        try {
+            return invokeNodes(this.children, env, context);
+        } catch (ProcessingException e) {
+            if (e.getMessage().indexOf("Generator already set") != -1){
+
+                env.getObjectModel().remove(Constants.NOTIFYING_OBJECT);
+                throw new ProcessingException(
+                        "Error: 'handle-error' with a 'type' attribute has an implicit generator, at " +
+                        getLocation() + SystemUtils.LINE_SEPARATOR +
+                        "Please remove the 'type' attribute on 'handle-error'");
+            }
+            // Rethrow the exception
+            throw e;
+        }
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNodeBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNodeBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNodeBuilder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,56 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.thread.ThreadSafe;
+
+import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNodeBuilder;
+import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+
+/**
+ * Builds a &lt;map:handle-errors&gt;
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version $Id: HandleErrorsNodeBuilder.java 157555 2005-03-15 15:49:32Z vgritsenko $
+ */
+public class HandleErrorsNodeBuilder extends AbstractParentProcessingNodeBuilder
+                                     implements ThreadSafe {
+
+    /** This builder has no parameters -- return <code>false</code> */
+    protected boolean hasParameters() {
+        return false;
+    }
+
+    public ProcessingNode buildNode(Configuration config) throws Exception {
+
+        HandleErrorsNode node = new HandleErrorsNode(config.getAttributeAsInteger("type", -1),
+                                                     config.getAttribute("when", "external"));
+        this.treeBuilder.setupNode(node, config);
+
+        // Set a flag that will prevent redirects
+        ((SitemapLanguage) this.treeBuilder).setBuildingErrorHandler(true);
+        try {
+            // Get all children
+            node.setChildren(buildChildNodes(config));
+        } finally {
+            // And clear the flag
+            ((SitemapLanguage) this.treeBuilder).setBuildingErrorHandler(false);
+        }
+
+        return node;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/HandleErrorsNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNode.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNode.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNode.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNode.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,91 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import java.util.Map;
+
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.components.treeprocessor.InvokeContext;
+import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode;
+import org.apache.cocoon.components.treeprocessor.SimpleSelectorProcessingNode;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.matching.Matcher;
+
+/**
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: MatchNode.java 179045 2005-05-30 11:08:13Z cziegeler $
+ */
+
+public class MatchNode extends SimpleSelectorProcessingNode
+        implements ParameterizableProcessingNode {
+
+    /** The 'pattern' attribute */
+    private VariableResolver pattern;
+
+    /** The 'name' for the variable anchor */
+    private String name;
+
+    private Map parameters;
+
+    public MatchNode(String type, VariableResolver pattern, String name) {
+        super(Matcher.ROLE + "Selector", type);
+        this.pattern = pattern;
+        this.name = name;
+    }
+
+    public void setParameters(Map parameterMap) {
+        this.parameters = parameterMap;
+    }
+
+    public final boolean invoke(Environment env, InvokeContext context)
+      throws Exception {
+	
+        // Perform any common invoke functionality 
+        super.invoke(env, context);
+
+        Map objectModel = env.getObjectModel();
+
+        String resolvedPattern = pattern.resolve(context, objectModel);
+        Parameters resolvedParams = VariableResolver.buildParameters(this.parameters, context, objectModel);
+
+        Map result = null;
+
+        Matcher matcher = (Matcher)getComponent();
+        try {
+            result = this.executor.invokeMatcher(this, 
+                    objectModel, 
+                    matcher, 
+                    resolvedPattern, 
+                    resolvedParams);
+        } finally {
+            releaseComponent(matcher);
+        }
+
+        if (result != null) {
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("Matcher '" + this.componentName + "' matched pattern '" + this.pattern +
+                    "' at " + this.getLocation());
+            }
+
+            // Invoke children with the matcher results
+            return this.invokeNodes(children, env, context, name, result);
+        }
+        // Matcher failed
+        return false;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNodeBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNodeBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNodeBuilder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,82 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNodeBuilder;
+import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+import org.apache.cocoon.components.treeprocessor.SimpleSelectorProcessingNode;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
+import org.apache.cocoon.matching.Matcher;
+import org.apache.cocoon.matching.PreparableMatcher;
+
+/**
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version CVS $Id: MatchNodeBuilder.java 30941 2004-07-29 19:56:58Z vgritsenko $
+ */
+
+public class MatchNodeBuilder extends AbstractParentProcessingNodeBuilder
+  implements ThreadSafe {
+
+    public ProcessingNode buildNode(Configuration config) throws Exception {
+
+        String pattern = config.getAttribute("pattern", null);
+        String name = config.getAttribute("name", null);
+
+        String type = this.treeBuilder.getTypeForStatement(config, Matcher.ROLE);
+
+        // Get the type and class for this matcher
+        ServiceSelector selector = (ServiceSelector)this.manager.lookup(Matcher.ROLE + "Selector");
+
+        Class clazz = null;
+        try {
+            // Find matcher class
+            Matcher matcher = (Matcher)selector.select(type);
+            clazz = matcher.getClass();
+            selector.release(matcher);
+        } finally {
+            this.manager.release(selector);
+        }
+
+        // PreparableMatcher are only prepared if pattern doesn't need request-time resolution.
+        boolean preparable =
+            PreparableMatcher.class.isAssignableFrom(clazz) &&
+            !VariableResolverFactory.needsResolve(pattern);
+
+        // Instanciate appropriate node
+        SimpleSelectorProcessingNode node;
+        VariableResolver patternResolver = VariableResolverFactory.getResolver(pattern, this.manager);
+
+        if (preparable) {
+            node = new PreparableMatchNode(type, VariableResolverFactory.unescape(pattern),name);
+        } else {
+            node = new MatchNode(type, patternResolver,name);
+        }
+
+        this.treeBuilder.setupNode(node, config);
+
+        // Get all children
+        ProcessingNode[] children = buildChildNodes(config);
+
+        node.setChildren(children);
+
+        return node;
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,160 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.Processor;
+import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode;
+import org.apache.cocoon.components.treeprocessor.InvokeContext;
+import org.apache.cocoon.components.treeprocessor.TreeProcessor;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
+import org.apache.cocoon.environment.Environment;
+import org.apache.commons.lang.BooleanUtils;
+
+/**
+ *
+ * @author <a href="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version $Id: MountNode.java 312930 2005-10-11 18:13:35Z cziegeler $
+ */
+public class MountNode extends AbstractProcessingNode
+                       implements Disposable {
+
+    /** The key to get the pass_through value from the Environment*/
+    public final static String COCOON_PASS_THROUGH = "COCOON_PASS_THROUGH";
+
+
+    /** The 'uri-prefix' attribute */
+    private final VariableResolver prefix;
+
+    /** The 'src' attribute */
+    private final VariableResolver source;
+
+    /** Processors for sources */
+    private Map processors = new HashMap();
+
+    /** The processor for this node */
+    private final TreeProcessor parentProcessor;
+
+    /** The value of the 'check-reload' attribute */
+    private final boolean checkReload;
+
+    /** The value of the 'pass-through' attribute */
+    private final Boolean passThrough;
+
+    public MountNode(VariableResolver prefix,
+                     VariableResolver source,
+                     TreeProcessor parentProcessor,
+                     boolean checkReload,
+                     boolean passThrough) {
+        this.prefix = prefix;
+        this.source = source;
+        this.parentProcessor = parentProcessor;
+        this.checkReload = checkReload;
+        this.passThrough = BooleanUtils.toBooleanObject(passThrough);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.components.treeprocessor.ProcessingNode#invoke(org.apache.cocoon.environment.Environment, org.apache.cocoon.components.treeprocessor.InvokeContext)
+     */
+    public final boolean invoke(Environment env, InvokeContext context)
+    throws Exception {
+        final Map objectModel = env.getObjectModel();
+
+        String resolvedSource = this.source.resolve(context, objectModel);
+        String resolvedPrefix = this.prefix.resolve(context, objectModel);
+
+        if (resolvedSource.length() == 0) {
+            throw new ProcessingException("Source of mount statement is empty");
+        }
+        // Handle directory mounts
+        if (resolvedSource.charAt(resolvedSource.length() - 1) == '/') {
+            resolvedSource = resolvedSource + "sitemap.xmap";
+        }
+
+        TreeProcessor processor = getProcessor(resolvedSource, resolvedPrefix);
+
+        // Save context
+        String oldPrefix = env.getURIPrefix();
+        String oldURI    = env.getURI();
+        Object oldPassThrough = env.getAttribute(COCOON_PASS_THROUGH);
+        env.setAttribute(COCOON_PASS_THROUGH, this.passThrough);
+
+        try {
+            processor.getEnvironmentHelper().changeContext(env);
+
+            if (context.isBuildingPipelineOnly()) {
+                // Propagate pipelines
+                Processor.InternalPipelineDescription pp = processor.buildPipeline(env);
+                if (pp != null) {
+                    context.setInternalPipelineDescription(pp);
+                    return true;
+                }
+                return false;
+            }
+            // Processor will create its own pipelines
+            return processor.process(env);
+        } catch(Exception e) {
+            // Wrap with our location
+            throw ProcessingException.throwLocated("Sitemap: error when calling sub-sitemap", e, getLocation());
+
+        } finally {
+            // Restore context
+            env.setURI(oldPrefix, oldURI);
+            if (oldPassThrough != null) {
+                env.setAttribute(COCOON_PASS_THROUGH, oldPassThrough);
+            } else {
+                env.removeAttribute(COCOON_PASS_THROUGH);
+            }
+
+            // Turning recomposing as a test, according to:
+            // http://marc.theaimsgroup.com/?t=106802211400005&r=1&w=2
+            // Recompose pipelines which may have been recomposed by subsitemap
+            // context.recompose(this.manager);
+        }
+    }
+
+    private synchronized TreeProcessor getProcessor(String source, String prefix)
+    throws Exception {
+
+        TreeProcessor processor = (TreeProcessor) processors.get(source);
+        if (processor == null) {
+
+            processor = this.parentProcessor.createChildProcessor(source, this.checkReload, prefix);
+
+            // Associate to the original source
+            processors.put(source, processor);
+        }
+
+        return processor;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public void dispose() {
+        Iterator i = this.processors.values().iterator();
+        while (i.hasNext()) {
+            ((TreeProcessor) i.next()).dispose();
+        }
+        this.processors.clear();
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNodeBuilder.java
URL: http://svn.apache.org/viewcvs/cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNodeBuilder.java?rev=330548&view=auto
==============================================================================
--- cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNodeBuilder.java (added)
+++ cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNodeBuilder.java Thu Nov  3 05:41:06 2005
@@ -0,0 +1,53 @@
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.treeprocessor.sitemap;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.cocoon.components.treeprocessor.AbstractProcessingNodeBuilder;
+import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
+import org.apache.cocoon.core.Core;
+
+/**
+ *
+ * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
+ * @version $Id: MountNodeBuilder.java 312930 2005-10-11 18:13:35Z cziegeler $
+ */
+
+public class MountNodeBuilder
+    extends AbstractProcessingNodeBuilder
+    implements ThreadSafe {
+
+    /** This builder has no parameters -- return <code>false</code> */
+    protected boolean hasParameters() {
+        return false;
+    }
+
+    public ProcessingNode buildNode(Configuration config) throws Exception {
+        final Core core = (Core)manager.lookup(Core.ROLE);
+        MountNode node = new MountNode(
+            VariableResolverFactory.getResolver(config.getAttribute("uri-prefix"), manager),
+            VariableResolverFactory.getResolver(config.getAttribute("src"), manager),
+            this.treeBuilder.getProcessor().getWrappingProcessor(),
+            config.getAttributeAsBoolean("check-reload", core.getSettings().isReloadingEnabled("sitemap")),
+            config.getAttributeAsBoolean("pass-through", false)
+        );
+  
+        return (this.treeBuilder.setupNode(node, config));
+    }
+}

Propchange: cocoon/whiteboard/maven2/cocoon-flat-layout/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNodeBuilder.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message