Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 22405 invoked by uid 500); 25 Nov 2002 21:52:08 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 22352 invoked by uid 500); 25 Nov 2002 21:52:06 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 25 Nov 2002 21:52:01 -0000 Message-ID: <20021125215201.13234.qmail@icarus.apache.org> From: sylvain@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables NOPVariableResolver.java PreparedVariableResolver.java VariableResolver.java VariableResolverFactory.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N sylvain 2002/11/25 13:52:01 Modified: . Tag: cocoon_2_0_3_branch changes.xml src/java/org/apache/cocoon/components/treeprocessor Tag: cocoon_2_0_3_branch AbstractParentProcessingNode.java AbstractParentProcessingNodeBuilder.java AbstractProcessingNodeBuilder.java CategoryNode.java ContainerNode.java DefaultTreeBuilder.java NamedContainerNode.java NullNode.java ParameterizableProcessingNode.java SimpleParentProcessingNode.java package.html src/java/org/apache/cocoon/components/treeprocessor/sitemap Tag: cocoon_2_0_3_branch ActNodeBuilder.java ActSetNode.java ActTypeNode.java ActionSetNode.java ActionSetNodeBuilder.java AggregateNode.java AggregateNodeBuilder.java CallNode.java CallNodeBuilder.java ComponentsSelector.java GenerateNode.java GenerateNodeBuilder.java MatchNode.java MatchNodeBuilder.java MountNode.java MountNodeBuilder.java PipelineNode.java PipelineNodeBuilder.java PipelinesNode.java PipelinesNodeBuilder.java PreparableMatchNode.java ReadNode.java ReadNodeBuilder.java RedirectToNodeBuilder.java RedirectToURINode.java SelectNode.java SelectNodeBuilder.java SerializeNode.java SerializeNodeBuilder.java SitemapLanguage.java TransformNode.java TransformNodeBuilder.java package.html Added: src/java/org/apache/cocoon/components/treeprocessor Tag: cocoon_2_0_3_branch PipelineEventComponentProcessingNode.java src/java/org/apache/cocoon/components/treeprocessor/variables Tag: cocoon_2_0_3_branch NOPVariableResolver.java PreparedVariableResolver.java VariableResolver.java VariableResolverFactory.java Removed: src/java/org/apache/cocoon/components/treeprocessor Tag: cocoon_2_0_3_branch MapStackResolver.java Log: Port input module sitemap variable subsititution available in 2.1 to the 2.0 branch. Revision Changes Path No revision No revision 1.138.2.70 +7 -1 xml-cocoon2/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/changes.xml,v retrieving revision 1.138.2.69 retrieving revision 1.138.2.70 diff -u -r1.138.2.69 -r1.138.2.70 --- changes.xml 20 Nov 2002 11:21:50 -0000 1.138.2.69 +++ changes.xml 25 Nov 2002 21:51:58 -0000 1.138.2.70 @@ -39,6 +39,12 @@ + + Extend the syntax of sitemap variable substitution : variables can have a prefix which + indicates an InputModule where to get the value from. For example, the expression + "{request-param:foo}" will evaluate to the value of the "foo" request parameter (provided + of course that the "request-param" InputModule is correctly defined in cocoon.xconf). + RequestLifecycleComponents were not handled properly when the cocoon: protocol is used No revision No revision 1.2.2.2 +5 -5 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNode.java Index: AbstractParentProcessingNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNode.java,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -r1.2.2.1 -r1.2.2.2 --- AbstractParentProcessingNode.java 15 Jul 2002 14:42:48 -0000 1.2.2.1 +++ AbstractParentProcessingNode.java 25 Nov 2002 21:51:59 -0000 1.2.2.2 @@ -51,8 +51,6 @@ package org.apache.cocoon.components.treeprocessor; import org.apache.cocoon.environment.Environment; -import org.apache.cocoon.components.pipeline.EventPipeline; -import org.apache.cocoon.components.pipeline.StreamPipeline; import java.util.List; import java.util.Map; @@ -71,14 +69,16 @@ * @param currentMap the Map of parameters produced by this node, * which is added to listOfMap. */ + protected final boolean invokeNodes( ProcessingNode[] nodes, Environment env, InvokeContext context, + String currentName, Map currentMap) throws Exception { - context.pushMap(currentMap); + context.pushMap(/*currentName,*/currentMap); try { for (int i = 0; i < nodes.length; i++) { @@ -92,7 +92,7 @@ // No success context.popMap(); } - + return false; } 1.1.2.1 +5 -6 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNodeBuilder.java Index: AbstractParentProcessingNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/AbstractParentProcessingNodeBuilder.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- AbstractParentProcessingNodeBuilder.java 5 Mar 2002 08:26:22 -0000 1.1 +++ AbstractParentProcessingNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -54,8 +54,6 @@ import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.avalon.framework.logger.AbstractLoggable; - import org.apache.cocoon.util.StringUtils; import java.util.*; @@ -106,8 +104,10 @@ // Is this element to be ignored ? if (ignoredChildren != null && ignoredChildren.contains(name)) { - getLogger().debug("Element '" + name + "' is ignored for building children of element '" + - child.getName() + "'"); + if (this.getLogger().isDebugEnabled()) { + getLogger().debug("Element '" + name + "' is ignored for building children of element '" + + child.getName() + "'"); + } return false; } @@ -160,7 +160,6 @@ throw ce; } catch(Exception e) { String msg = "Error while creating node '" + child.getName() + "' at " + child.getLocation(); - getLogger().error(msg, e); throw new ConfigurationException(msg, e); } } 1.2.2.2 +23 -5 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNodeBuilder.java Index: AbstractProcessingNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/AbstractProcessingNodeBuilder.java,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -u -r1.2.2.1 -r1.2.2.2 --- AbstractProcessingNodeBuilder.java 2 May 2002 20:19:59 -0000 1.2.2.1 +++ AbstractProcessingNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.2.2.2 @@ -50,12 +50,18 @@ */ package org.apache.cocoon.components.treeprocessor; -import org.apache.avalon.framework.logger.AbstractLoggable; +import org.apache.avalon.framework.logger.AbstractLogEnabled; +import org.apache.avalon.framework.component.Recomposable; +import org.apache.avalon.framework.component.ComponentManager; +import org.apache.avalon.framework.component.ComponentException; 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.treeprocessor.variables.VariableResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; + import org.apache.cocoon.sitemap.PatternException; import java.util.Map; @@ -68,10 +74,20 @@ */ -public abstract class AbstractProcessingNodeBuilder extends AbstractLoggable - implements ProcessingNodeBuilder { +public abstract class AbstractProcessingNodeBuilder extends AbstractLogEnabled + implements ProcessingNodeBuilder, Recomposable { protected TreeBuilder treeBuilder; + + protected ComponentManager manager; + + public void compose(ComponentManager manager) throws ComponentException { + this.manager = manager; + } + + public void recompose(ComponentManager manager) throws ComponentException { + this.manager = manager; + } public void setBuilder(TreeBuilder treeBuilder) { this.treeBuilder = treeBuilder; @@ -106,7 +122,9 @@ String name = child.getAttribute("name"); String value = child.getAttribute("value"); try { - params.put(MapStackResolver.getResolver(name), MapStackResolver.getResolver(value)); + params.put( + VariableResolverFactory.getResolver(name, this.manager), + VariableResolverFactory.getResolver(value, this.manager)); } catch(PatternException pe) { String msg = "Invalid pattern '" + value + " at " + child.getLocation(); getLogger().error(msg, pe); 1.1.2.1 +1 -3 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/CategoryNode.java Index: CategoryNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/CategoryNode.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- CategoryNode.java 5 Mar 2002 08:26:22 -0000 1.1 +++ CategoryNode.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -50,8 +50,6 @@ */ package org.apache.cocoon.components.treeprocessor; -import org.apache.cocoon.components.pipeline.EventPipeline; -import org.apache.cocoon.components.pipeline.StreamPipeline; import org.apache.cocoon.environment.Environment; import org.apache.cocoon.ProcessingException; 1.1.2.1 +1 -3 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/ContainerNode.java Index: ContainerNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/ContainerNode.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- ContainerNode.java 5 Mar 2002 08:26:22 -0000 1.1 +++ ContainerNode.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -50,8 +50,6 @@ */ package org.apache.cocoon.components.treeprocessor; -import org.apache.cocoon.components.pipeline.EventPipeline; -import org.apache.cocoon.components.pipeline.StreamPipeline; import org.apache.cocoon.environment.Environment; import java.util.*; 1.3.2.5 +5 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java Index: DefaultTreeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java,v retrieving revision 1.3.2.4 retrieving revision 1.3.2.5 diff -u -r1.3.2.4 -r1.3.2.5 --- DefaultTreeBuilder.java 15 Jul 2002 14:42:48 -0000 1.3.2.4 +++ DefaultTreeBuilder.java 25 Nov 2002 21:51:59 -0000 1.3.2.5 @@ -81,6 +81,7 @@ import org.apache.cocoon.components.ExtendedComponentSelector; import org.apache.cocoon.components.LifecycleHelper; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; import org.apache.cocoon.environment.Source; import org.apache.cocoon.environment.SourceResolver; @@ -502,7 +503,9 @@ String name = child.getAttribute("name"); String value = child.getAttribute("value"); try { - params.put(MapStackResolver.getResolver(name), MapStackResolver.getResolver(value)); + params.put( + VariableResolverFactory.getResolver(name, this.manager), + VariableResolverFactory.getResolver(value, this.manager)); } catch(PatternException pe) { String msg = "Invalid pattern '" + value + "' at " + child.getLocation(); getLogger().error(msg, pe); 1.1.2.1 +1 -5 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/NamedContainerNode.java Index: NamedContainerNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/NamedContainerNode.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- NamedContainerNode.java 5 Mar 2002 08:26:22 -0000 1.1 +++ NamedContainerNode.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -50,10 +50,6 @@ */ package org.apache.cocoon.components.treeprocessor; -import org.apache.cocoon.components.pipeline.EventPipeline; -import org.apache.cocoon.components.pipeline.StreamPipeline; -import org.apache.cocoon.environment.Environment; - /** * A named container node that just invokes its children. * 1.1.2.1 +2 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/NullNode.java Index: NullNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/NullNode.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- NullNode.java 5 Mar 2002 08:26:22 -0000 1.1 +++ NullNode.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -63,7 +63,7 @@ public final boolean invoke(Environment env, InvokeContext context) throws Exception { - getLogger().debug("Invoke on NullNode at " + getLocation()); + getLogger().warn("Invoke on NullNode at " + getLocation()); return false; } 1.1.2.1 +2 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/ParameterizableProcessingNode.java Index: ParameterizableProcessingNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/ParameterizableProcessingNode.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- ParameterizableProcessingNode.java 5 Mar 2002 08:26:22 -0000 1.1 +++ ParameterizableProcessingNode.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -62,7 +62,7 @@ public interface ParameterizableProcessingNode extends ProcessingNode { /** - * Set the parameters of this node as a Map of MapStackResolvers + * Set the parameters of this node as a Map of VariableResolvers * that will be resolved at process-time. */ void setParameters(Map parameterMap); 1.1.2.1 +43 -12 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/SimpleParentProcessingNode.java Index: SimpleParentProcessingNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/SimpleParentProcessingNode.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- SimpleParentProcessingNode.java 5 Mar 2002 08:26:22 -0000 1.1 +++ SimpleParentProcessingNode.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -1,36 +1,36 @@ /* - + ============================================================================ The Apache Software License, Version 1.1 ============================================================================ - + Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. - + Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: - + 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - + 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - + 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - + 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. - + 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. - + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE @@ -41,18 +41,20 @@ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - + This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi . For more information on the Apache Software Foundation, please see . - + */ package org.apache.cocoon.components.treeprocessor; import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode; import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.environment.Environment; + /** * * @author Sylvain Wallez @@ -66,5 +68,34 @@ public void setChildren(ProcessingNode[] children) { this.children = children; + } + + /** + * Boolean method with returns true if this Node has children + * and false otherwise + * + * @return boolean + */ + public boolean hasChildren() { + if ((this.children == null) || (this.children.length > 0)) + return true; + return false; + } + + + /** + * Define common invoke behavior here + */ + public boolean invoke(Environment env, InvokeContext context) throws Exception { + + +// // inform the pipeline (if available) that we have come across +// // a possible branch point +// if (context.pipelineIsSet() && this.hasChildren() ) { +// context.getProcessingPipeline().informBranchPoint(); +// } + + // processing not yet complete, so return false + return false; } } 1.1.2.1 +7 -3 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/package.html Index: package.html =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/package.html,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- package.html 5 Mar 2002 08:26:22 -0000 1.1 +++ package.html 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -1,6 +1,10 @@ -package description + + Tree Processor + - Evaluation tree based implementation of the Processor interface. +

Evaluation tree based implementation of the Processor interface

+

+

- \ No newline at end of file + No revision No revision 1.2.2.1 +1 -7 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/PipelineEventComponentProcessingNode.java Index: PipelineEventComponentProcessingNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/PipelineEventComponentProcessingNode.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- PipelineEventComponentProcessingNode.java 9 Sep 2002 12:00:41 -0000 1.2 +++ PipelineEventComponentProcessingNode.java 25 Nov 2002 21:51:59 -0000 1.2.2.1 @@ -63,15 +63,9 @@ public abstract class PipelineEventComponentProcessingNode extends AbstractProcessingNode { protected Map views; - protected Map pipelineHints; public void setViews(Map views) { this.views = views; - } - - // Set any pipeline-hint parameters - public void setPipelineHints(Map parameterMap) { - this.pipelineHints = parameterMap; } public boolean hasViews() { No revision No revision 1.1.2.1 +9 -3 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActNodeBuilder.java Index: ActNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActNodeBuilder.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- ActNodeBuilder.java 5 Mar 2002 08:26:23 -0000 1.1 +++ ActNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -58,9 +58,10 @@ import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNodeBuilder; import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode; import org.apache.cocoon.components.treeprocessor.CategoryNodeBuilder; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder; import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; import java.util.*; @@ -82,10 +83,15 @@ this.actSetName = config.getAttribute("set", null); if (actSetName == null) { + String name = config.getAttribute("name", null); String source = config.getAttribute("src", null); String type = this.treeBuilder.getTypeForStatement(config, Action.ROLE + "Selector"); - ActTypeNode actTypeNode = new ActTypeNode(type, source); + ActTypeNode actTypeNode = new ActTypeNode( + type, + VariableResolverFactory.getResolver(source, this.manager), + name + ); this.treeBuilder.setupNode(actTypeNode, config); actTypeNode.setChildren(buildChildNodes(config)); 1.2.2.1 +11 -7 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActSetNode.java Index: ActSetNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActSetNode.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- ActSetNode.java 27 Mar 2002 15:13:40 -0000 1.2 +++ ActSetNode.java 25 Nov 2002 21:51:59 -0000 1.2.2.1 @@ -60,13 +60,11 @@ import org.apache.cocoon.environment.Environment; import org.apache.cocoon.environment.Redirector; import org.apache.cocoon.environment.SourceResolver; -import org.apache.cocoon.components.pipeline.EventPipeline; -import org.apache.cocoon.components.pipeline.StreamPipeline; import org.apache.cocoon.sitemap.PatternException; import org.apache.cocoon.components.treeprocessor.InvokeContext; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode; import org.apache.cocoon.components.treeprocessor.ProcessingNode; import org.apache.cocoon.components.treeprocessor.SimpleParentProcessingNode; @@ -101,8 +99,14 @@ public final boolean invoke(Environment env, InvokeContext context) throws Exception { - List mapStack = context.getMapStack(); - Parameters resolvedParams = MapStackResolver.buildParameters(this.parameters, mapStack); + // Perform any common invoke functionality + super.invoke(env, context); + + Parameters resolvedParams = VariableResolver.buildParameters( + this.parameters, + context, + env.getObjectModel() + ); Map result = this.actionSet.call(env, context, resolvedParams); @@ -116,7 +120,7 @@ return true; } else { - return this.invokeNodes(this.children, env, context, result); + return this.invokeNodes(this.children, env, context, null, result); } } } 1.2.2.1 +20 -11 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActTypeNode.java Index: ActTypeNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActTypeNode.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- ActTypeNode.java 27 Mar 2002 15:13:40 -0000 1.2 +++ ActTypeNode.java 25 Nov 2002 21:51:59 -0000 1.2.2.1 @@ -63,7 +63,7 @@ import org.apache.cocoon.sitemap.PatternException; import org.apache.cocoon.components.treeprocessor.InvokeContext; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode; import org.apache.cocoon.components.treeprocessor.SimpleSelectorProcessingNode; @@ -85,14 +85,20 @@ private Map parameters; /** The 'src' attribute */ - protected MapStackResolver source; + protected VariableResolver source; + + /** The 'name' for the variable anchor */ + protected String name; /** Pre-selected action, if it's ThreadSafe */ protected Action threadSafeAction; - public ActTypeNode(String name, String source) throws PatternException { - super(name); - this.source = MapStackResolver.getResolver(source); + protected ComponentManager manager; + + public ActTypeNode(String type, VariableResolver source, String name) throws PatternException { + super(type); + this.source = source; + this.name = name; } public void setParameters(Map parameterMap) { @@ -100,7 +106,7 @@ } public void compose(ComponentManager manager) throws ComponentException { - + this.manager = manager; setSelector((ComponentSelector)manager.lookup(Action.ROLE + "Selector")); // Get the action, if it's thread safe @@ -109,14 +115,16 @@ public final boolean invoke(Environment env, InvokeContext context) throws Exception { + + // Perform any common invoke functionality + super.invoke(env, context); // Prepare data needed by the action Map objectModel = env.getObjectModel(); Redirector redirector = PipelinesNode.getRedirector(env); SourceResolver resolver = getSourceResolver(objectModel); - List mapStack = context.getMapStack(); - String resolvedSource = source.resolve(mapStack); - Parameters resolvedParams = MapStackResolver.buildParameters(this.parameters, mapStack); + String resolvedSource = source.resolve(context, objectModel); + Parameters resolvedParams = VariableResolver.buildParameters(this.parameters, context, objectModel); Map actionResult; @@ -147,7 +155,7 @@ } else { // Action succeeded : process children if there are some, with the action result if (this.children != null) { - return this.invokeNodes(this.children, env, context, actionResult); + return this.invokeNodes(this.children, env, context, name, actionResult); } else { // Return false to continue sitemap invocation @@ -160,5 +168,6 @@ if (this.threadSafeAction != null) { this.selector.release(this.threadSafeAction); } + this.manager.release(this.selector); } } 1.2.2.1 +20 -12 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActionSetNode.java Index: ActionSetNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActionSetNode.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- ActionSetNode.java 27 Mar 2002 15:10:35 -0000 1.2 +++ ActionSetNode.java 25 Nov 2002 21:51:59 -0000 1.2.2.1 @@ -65,7 +65,7 @@ import org.apache.cocoon.sitemap.PatternException; import org.apache.cocoon.components.treeprocessor.InvokeContext; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; import org.apache.cocoon.components.treeprocessor.NamedProcessingNode; import org.apache.cocoon.components.treeprocessor.SimpleSelectorProcessingNode; @@ -88,16 +88,19 @@ /** The actions that are ThreadSafe, to avoid lookups */ private Action[] threadSafeActions; - + /** The src for each action */ - private MapStackResolver[] sources; - + private VariableResolver[] sources; + /** The parameters for each action */ private Map[] parameters; + /** The component manager */ + protected ComponentManager manager; + public ActionSetNode( String name, String[] types, String[] actionNames, - MapStackResolver[] sources, Map[] parameters) { + VariableResolver[] sources, Map[] parameters) { super(name); this.types = types; this.actionNames = actionNames; @@ -106,7 +109,7 @@ } public void compose(ComponentManager manager) throws ComponentException { - + this.manager = manager; setSelector((ComponentSelector)manager.lookup(Action.ROLE + "Selector")); // Get all actions that are thread safe @@ -119,6 +122,9 @@ public final boolean invoke(Environment env, InvokeContext context) throws Exception { + + // Perform any common invoke functionalty + // super.invoke(env, context); String msg = "An action-set cannot be invoked, at " + this.getLocation(); getLogger().error(msg); throw new UnsupportedOperationException(msg); @@ -134,7 +140,6 @@ Map objectModel = env.getObjectModel(); Redirector redirector = PipelinesNode.getRedirector(env); SourceResolver resolver = getSourceResolver(objectModel); - List mapStack = context.getMapStack(); String cocoonAction = env.getAction(); @@ -149,10 +154,10 @@ Action action; String actionName = actionNames[i]; - String source = sources[i].resolve(mapStack); + String source = sources[i].resolve(context, objectModel); if (actionName == null || actionName.equals(cocoonAction)) { - - Parameters actionParams = MapStackResolver.buildParameters(parameters[i], mapStack); + + Parameters actionParams = VariableResolver.buildParameters(parameters[i], context, objectModel); if (actionParams == Parameters.EMPTY_PARAMETERS) { actionParams = params; } else { @@ -191,10 +196,13 @@ } public void dispose() { - // Dispose all ThreadSafe actions + + // Dispose ThreadSafe actions for (int i = 0; i < this.threadSafeActions.length; i++) { this.selector.release(this.threadSafeActions[i]); } + + this.manager.release(this.selector); } /** 1.2.2.1 +7 -5 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActionSetNodeBuilder.java Index: ActionSetNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ActionSetNodeBuilder.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- ActionSetNodeBuilder.java 27 Mar 2002 15:10:35 -0000 1.2 +++ ActionSetNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.2.2.1 @@ -57,7 +57,8 @@ import org.apache.cocoon.acting.Action; import org.apache.cocoon.components.treeprocessor.AbstractProcessingNodeBuilder; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; import org.apache.cocoon.components.treeprocessor.ProcessingNode; import java.util.*; @@ -93,7 +94,8 @@ actionTypes.add(type); actionNames.add(childConfig.getAttribute("action", null)); - actionSources.add(MapStackResolver.getResolver(childConfig.getAttribute("src", null))); + actionSources.add(VariableResolverFactory.getResolver( + childConfig.getAttribute("src", null), this.manager)); actionParameters.add(this.getParameters(childConfig)); } else { @@ -107,8 +109,8 @@ String[] types = (String[])actionTypes.toArray(new String[actionTypes.size()]); String[] actions = (String[])actionNames.toArray(new String[actionNames.size()]); Map[] parameters = (Map[])actionParameters.toArray(new Map[actionParameters.size()]); - MapStackResolver[] sources = - (MapStackResolver[])actionSources.toArray(new MapStackResolver[actionSources.size()]); + VariableResolver[] sources = + (VariableResolver[])actionSources.toArray(new VariableResolver[actionSources.size()]); ActionSetNode node = new ActionSetNode(actionSetName, types, actions, sources, parameters); this.treeBuilder.setupNode(node, config); 1.3.2.2 +41 -36 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNode.java Index: AggregateNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNode.java,v retrieving revision 1.3.2.1 retrieving revision 1.3.2.2 diff -u -r1.3.2.1 -r1.3.2.2 --- AggregateNode.java 8 Aug 2002 03:21:28 -0000 1.3.2.1 +++ AggregateNode.java 25 Nov 2002 21:51:59 -0000 1.3.2.2 @@ -52,17 +52,16 @@ import org.apache.avalon.framework.parameters.Parameters; -import org.apache.cocoon.components.pipeline.EventPipeline; -import org.apache.cocoon.components.pipeline.StreamPipeline; import org.apache.cocoon.environment.Environment; import org.apache.cocoon.sitemap.PatternException; import org.apache.cocoon.sitemap.ContentAggregator; +import org.apache.cocoon.components.pipeline.EventPipeline; import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode; import org.apache.cocoon.components.treeprocessor.InvokeContext; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; import java.util.*; @@ -88,23 +87,23 @@ public class AggregateNode extends AbstractProcessingNode { - private MapStackResolver element; - private MapStackResolver nsURI; - private MapStackResolver nsPrefix; + private VariableResolver element; + private VariableResolver nsURI; + private VariableResolver nsPrefix; /** All parts */ private Part[] allParts; - + /** Pre-filtered Part[] for views that have a matching label in any of the parts */ private Map viewParts; /** View nodes to jump to */ private Map viewNodes; - public AggregateNode(String element, String nsURI, String nsPrefix) throws PatternException { - this.element = MapStackResolver.getResolver(element); - this.nsURI = MapStackResolver.getResolver(nsURI); - this.nsPrefix = MapStackResolver.getResolver(nsPrefix); + public AggregateNode(VariableResolver element, VariableResolver nsURI, VariableResolver nsPrefix) throws PatternException { + this.element = element; + this.nsURI = nsURI; + this.nsPrefix = nsPrefix; } public void setParts(Part[] allParts, Map viewParts) { @@ -121,7 +120,7 @@ boolean infoEnabled = getLogger().isInfoEnabled(); - List mapStack = context.getMapStack(); + Map objectModel = env.getObjectModel(); // Setup aggregator EventPipeline eventPipeline = context.getEventPipeline(); @@ -130,14 +129,14 @@ ContentAggregator aggregator = (ContentAggregator)eventPipeline.getGenerator(); aggregator.setRootElement( - this.element.resolve(mapStack), - this.nsURI.resolve(mapStack), - this.nsPrefix.resolve(mapStack) + this.element.resolve(context, objectModel), + this.nsURI.resolve(context, objectModel), + this.nsPrefix.resolve(context, objectModel) ); // Get actual parts, potentially filtered by the view Part[] actualParts; - + String cocoonView = env.getView(); if (cocoonView == null) { // Keep all parts @@ -146,7 +145,7 @@ } else { // Are there some parts that match this view ? actualParts = (Part[])this.viewParts.get(cocoonView); - + // If not, keep all parts if (actualParts == null) { actualParts = this.allParts; @@ -158,15 +157,15 @@ Part part = actualParts[i]; if (part != null) { aggregator.addPart( - part.source.resolve(mapStack), - part.element.resolve(mapStack), - part.nsURI.resolve(mapStack), - part.stripRoot.resolve(mapStack), - part.nsPrefix.resolve(mapStack) + part.source.resolve(context, objectModel), + part.element.resolve(context, objectModel), + part.nsURI.resolve(context, objectModel), + part.stripRoot.resolve(context, objectModel), + part.nsPrefix.resolve(context, objectModel) ); } } - + // Bug #7196 : Some parts matched the view : jump to that view if (actualParts != this.allParts) { ProcessingNode viewNode = (ProcessingNode)this.viewNodes.get(cocoonView); @@ -175,7 +174,7 @@ getLogger().info("Jumping to view '" + cocoonView + "' from aggregate part at " + this.getLocation()); } return viewNode.invoke(env, context); - } + } } // Check aggregate-level view @@ -194,19 +193,25 @@ } public static class Part { - public Part(String source, String element, String nsURI, String nsPrefix, String stripRoot) + public Part( + VariableResolver source, + VariableResolver element, + VariableResolver nsURI, + VariableResolver nsPrefix, + VariableResolver stripRoot) throws PatternException { - this.source = MapStackResolver.getResolver(source); - this.element = MapStackResolver.getResolver(element); - this.nsURI = MapStackResolver.getResolver(nsURI); - this.nsPrefix = MapStackResolver.getResolver(nsPrefix); - this.stripRoot = MapStackResolver.getResolver(stripRoot); + this.source = source; + this.element = element; + this.nsURI = nsURI; + this.nsPrefix = nsPrefix; + this.stripRoot = stripRoot; } - private MapStackResolver source; - private MapStackResolver element; - private MapStackResolver nsURI; - private MapStackResolver nsPrefix; - private MapStackResolver stripRoot; + private VariableResolver source; + private VariableResolver element; + private VariableResolver nsURI; + private VariableResolver nsPrefix; + private VariableResolver stripRoot; + } } 1.3.2.1 +11 -11 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNodeBuilder.java Index: AggregateNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/AggregateNodeBuilder.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- AggregateNodeBuilder.java 22 Mar 2002 22:26:13 -0000 1.3 +++ AggregateNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.3.2.1 @@ -54,8 +54,9 @@ import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.cocoon.components.treeprocessor.AbstractProcessingNodeBuilder; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder; @@ -80,9 +81,9 @@ // Get root node data this.node = new AggregateNode( - config.getAttribute("element"), - config.getAttribute("ns", ""), - config.getAttribute("prefix", "") + VariableResolverFactory.getResolver(config.getAttribute("element"), this.manager), + VariableResolverFactory.getResolver(config.getAttribute("ns", ""), this.manager), + VariableResolverFactory.getResolver(config.getAttribute("prefix", ""), this.manager) ); this.treeBuilder.setupNode(this.node, config); @@ -109,18 +110,17 @@ if (!"part".equals(childConfig.getName())) { String msg = "Unknown element '" + childConfig.getName() + " in aggregate ' at " + childConfig.getLocation(); - getLogger().error(msg); throw new ConfigurationException(msg); } checkNamespace(childConfig); AggregateNode.Part currentPart = new AggregateNode.Part( - childConfig.getAttribute("src"), - childConfig.getAttribute("element", ""), - childConfig.getAttribute("ns", ""), - childConfig.getAttribute("prefix", ""), - childConfig.getAttribute("strip-root", "false") + VariableResolverFactory.getResolver(childConfig.getAttribute("src"), this.manager), + VariableResolverFactory.getResolver(childConfig.getAttribute("element", ""), this.manager), + VariableResolverFactory.getResolver(childConfig.getAttribute("ns", ""), this.manager), + VariableResolverFactory.getResolver(childConfig.getAttribute("prefix", ""), this.manager), + VariableResolverFactory.getResolver(childConfig.getAttribute("strip-root", "false"), this.manager) ); allParts.add(currentPart); 1.3.2.1 +23 -12 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNode.java Index: CallNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNode.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- CallNode.java 31 Mar 2002 21:07:48 -0000 1.3 +++ CallNode.java 25 Nov 2002 21:51:59 -0000 1.3.2.1 @@ -51,6 +51,9 @@ package org.apache.cocoon.components.treeprocessor.sitemap; import org.apache.avalon.framework.activity.Initializable; +import org.apache.avalon.framework.component.Composable; +import org.apache.avalon.framework.component.ComponentManager; +import org.apache.avalon.framework.component.ComponentException; import org.apache.cocoon.environment.Environment; @@ -59,9 +62,10 @@ 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.MapStackResolver; import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode; import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; import java.util.List; import java.util.Map; @@ -73,7 +77,9 @@ */ public class CallNode extends AbstractProcessingNode - implements Initializable, ParameterizableProcessingNode { + implements Initializable, ParameterizableProcessingNode, Composable { + + private ComponentManager manager; /** The parameters of this node */ private Map parameters; @@ -81,13 +87,17 @@ /** The 'resource' attribute */ private String resourceName; - private MapStackResolver resourceResolver; + private VariableResolver resourceResolver; /** The category node */ private CategoryNode resources; private ProcessingNode resourceNode; + public void compose(ComponentManager manager) throws ComponentException { + this.manager = manager; + } + public void setParameters(Map parameterMap) { this.parameters = parameterMap; } @@ -98,25 +108,26 @@ } public void initialize() throws Exception { - if (MapStackResolver.needsResolve(this.resourceName)) { + if (VariableResolverFactory.needsResolve(this.resourceName)) { // Will always be resolved at invoke time - this.resourceResolver = MapStackResolver.getResolver(this.resourceName); + this.resourceResolver = VariableResolverFactory.getResolver(this.resourceName, this.manager); } else { // Static name : get it now - this.resourceNode = this.resources.getNodeByName(MapStackResolver.unescape(this.resourceName)); + this.resourceNode = this.resources.getNodeByName(VariableResolverFactory.unescape(this.resourceName)); } } 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 = MapStackResolver.resolveMap(this.parameters, context.getMapStack()); + Map params = VariableResolver.buildMap(this.parameters, context, objectModel); if (this.resourceNode != null) { // Static resource name - context.pushMap(params); + context.pushMap(/*null,*/params); try { return this.resourceNode.invoke(env, context); @@ -126,13 +137,13 @@ } else { // Resolved resource name - String name = this.resourceResolver.resolve(context.getMapStack()); - if (getLogger().isInfoEnabled()) { + String name = this.resourceResolver.resolve(context, objectModel); + if (getLogger().isDebugEnabled()) { getLogger().info("Calling resource " + name); } // and only now push the parameters - context.pushMap(params); + context.pushMap(/*null,*/params); try { return this.resources.invokeByName(name, env, context); 1.2.2.1 +1 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNodeBuilder.java Index: CallNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNodeBuilder.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- CallNodeBuilder.java 13 Mar 2002 17:42:22 -0000 1.2 +++ CallNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.2.2.1 @@ -56,7 +56,6 @@ 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.MapStackResolver; import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder; import org.apache.cocoon.components.treeprocessor.ProcessingNode; 1.1.2.2 +36 -28 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ComponentsSelector.java Index: ComponentsSelector.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ComponentsSelector.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- ComponentsSelector.java 8 Aug 2002 03:21:28 -0000 1.1.2.1 +++ ComponentsSelector.java 25 Nov 2002 21:51:59 -0000 1.1.2.2 @@ -78,7 +78,8 @@ * @version CVS $Id$ */ -public class ComponentsSelector extends ExtendedComponentSelector implements OutputComponentSelector, SitemapComponentSelector { +public class ComponentsSelector extends ExtendedComponentSelector +implements OutputComponentSelector, SitemapComponentSelector { public static final int UNKNOWN = -1; public static final int GENERATOR = 0; @@ -170,7 +171,7 @@ if (this.roleId == SERIALIZER || this.roleId == READER) { this.hintMimeTypes = new HashMap(); } - + this.hintLabels = new HashMap(); super.configure(config); @@ -193,7 +194,7 @@ this.hintMimeTypes.put(hint, mimeType); } } - + String label = config.getAttribute("label", null); if (label != null) { // Empty '' attribute will result in empty array, @@ -213,36 +214,43 @@ */ public void initialize() /*throws Exception*/ { - // FIXME : need to catch exceptions since ECS doesn't propagate the throws clause of Initializable - try { - - Configuration emptyConfig = new DefaultConfiguration("", ""); + // FIXME : need to catch exceptions since ECS doesn't propagate the throws clause of Initializable + try { - // Ensure all system-defined hints exist. - // NOTE : checking this here means they can be user-defined in the sitemap - switch(this.roleId) { - case GENERATOR : - ensureExists("", - org.apache.cocoon.sitemap.NotifyingGenerator.class, emptyConfig); + DefaultConfiguration config = null; - ensureExists("", - org.apache.cocoon.sitemap.ContentAggregator.class, emptyConfig); - break; + // Ensure all system-defined hints exist. + // NOTE : checking this here means they can be user-defined in the sitemap + switch(this.roleId) { + case GENERATOR : + + config = new DefaultConfiguration(COMPONENT_NAMES[GENERATOR], "autogenerated"); + config.setAttribute("name", ""); + ensureExists("", + org.apache.cocoon.sitemap.NotifyingGenerator.class, config); + + config = new DefaultConfiguration(COMPONENT_NAMES[GENERATOR], "autogenerated"); + config.setAttribute("name", ""); + ensureExists("", + org.apache.cocoon.sitemap.ContentAggregator.class, config); + break; - case TRANSFORMER : - ensureExists("", - org.apache.cocoon.sitemap.LinkTranslator.class, emptyConfig); - break; - } + case TRANSFORMER : + config = new DefaultConfiguration(COMPONENT_NAMES[TRANSFORMER], "autogenerated"); + config.setAttribute("name", ""); + ensureExists("", + org.apache.cocoon.sitemap.LinkTranslator.class, config); + break; + } - super.initialize(); + super.initialize(); - // Don't keep known hints (they're no more needed) - this.knownHints = null; + // Don't keep known hints (they're no more needed) + this.knownHints = null; - } catch(Exception e) { - throw new CascadingRuntimeException("Cannot setup default components", e); - } + } catch(Exception e) { + throw new CascadingRuntimeException("Cannot setup default components", e); + } } 1.1.2.1 +15 -17 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNode.java Index: GenerateNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNode.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- GenerateNode.java 5 Mar 2002 08:26:23 -0000 1.1 +++ GenerateNode.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -50,16 +50,17 @@ */ package org.apache.cocoon.components.treeprocessor.sitemap; -import org.apache.cocoon.components.pipeline.EventPipeline; import org.apache.cocoon.environment.Environment; import org.apache.cocoon.sitemap.PatternException; -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.MapStackResolver; 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.avalon.framework.parameters.Parameters; import java.util.*; @@ -69,46 +70,43 @@ * @version CVS $Id$ */ -public class GenerateNode extends AbstractProcessingNode implements ParameterizableProcessingNode { +public class GenerateNode extends PipelineEventComponentProcessingNode implements ParameterizableProcessingNode { private String generatorName; - private MapStackResolver source; + private VariableResolver source; private Map parameters; - private Map views; /** The category node */ private CategoryNode viewsNode; - public GenerateNode(String name, String source) throws PatternException { + public GenerateNode(String name, VariableResolver source) throws PatternException { this.generatorName = name; - this.source = MapStackResolver.getResolver(source); + this.source = source; } public void setParameters(Map parameterMap) { this.parameters = parameterMap; } - public void setViews(Map views) { - this.views = views; - } public final boolean invoke(Environment env, InvokeContext context) throws Exception { - List mapStack = context.getMapStack(); + Map objectModel = env.getObjectModel(); context.getEventPipeline().setGenerator( this.generatorName, - source.resolve(mapStack), - MapStackResolver.buildParameters(this.parameters, mapStack) + source.resolve(context, objectModel), + VariableResolver.buildParameters(this.parameters, context, objectModel) ); + // Check view if (this.views != null) { - + String cocoonView = env.getView(); if (cocoonView != null) { @@ -124,7 +122,7 @@ } } - // Return false to contine sitemap invocation + // Return false to continue sitemap invocation return false; } } 1.1.2.1 +7 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNodeBuilder.java Index: GenerateNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/GenerateNodeBuilder.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- GenerateNodeBuilder.java 5 Mar 2002 08:26:23 -0000 1.1 +++ GenerateNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -57,6 +57,8 @@ 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.VariableResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; import java.util.*; @@ -79,7 +81,10 @@ this.views = ((SitemapLanguage)this.treeBuilder).getViewsForStatement(Generator.ROLE, type, config); - this.node = new GenerateNode(type, config.getAttribute("src", null)); + this.node = new GenerateNode( + type, + VariableResolverFactory.getResolver(config.getAttribute("src", null), this.manager) + ); return this.treeBuilder.setupNode(this.node, config); } 1.1.2.1 +31 -15 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNode.java Index: MatchNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNode.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- MatchNode.java 5 Mar 2002 08:26:23 -0000 1.1 +++ MatchNode.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -51,12 +51,11 @@ package org.apache.cocoon.components.treeprocessor.sitemap; import org.apache.cocoon.environment.Environment; -import org.apache.cocoon.components.pipeline.EventPipeline; -import org.apache.cocoon.components.pipeline.StreamPipeline; import org.apache.cocoon.sitemap.PatternException; import org.apache.cocoon.components.treeprocessor.SimpleSelectorProcessingNode; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; import org.apache.cocoon.matching.Matcher; +import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.component.ComponentSelector; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.parameters.Parameters; @@ -74,19 +73,26 @@ * @version CVS $Id$ */ -public class MatchNode extends SimpleSelectorProcessingNode implements ParameterizableProcessingNode, Composable { +public class MatchNode extends SimpleSelectorProcessingNode +implements ParameterizableProcessingNode, Composable, Disposable { /** The 'pattern' attribute */ - private MapStackResolver pattern; + private VariableResolver pattern; + + /** The 'name' for the variable anchor */ + private String name; /** The matcher, if it's ThreadSafe */ private Matcher threadSafeMatcher; private Map parameters; - public MatchNode(String name, String pattern) throws PatternException { - super(name); - this.pattern = MapStackResolver.getResolver(pattern); + private ComponentManager manager; + + public MatchNode(String type, VariableResolver pattern, String name) throws PatternException { + super(type); + this.pattern = pattern; + this.name = name; } public void setParameters(Map parameterMap) { @@ -94,8 +100,8 @@ } public void compose(ComponentManager manager) throws ComponentException { - - super.setSelector((ComponentSelector)manager.lookup(Matcher.ROLE + "Selector")); + this.manager = manager; + this.setSelector((ComponentSelector)manager.lookup(Matcher.ROLE + "Selector")); // Get matcher if it's ThreadSafe this.threadSafeMatcher = (Matcher)this.getThreadSafeComponent(); @@ -103,12 +109,15 @@ public final boolean invoke(Environment env, InvokeContext context) throws Exception { + + // Perform any common invoke functionality + super.invoke(env, context); List mapStack = context.getMapStack(); - - String resolvedPattern = pattern.resolve(mapStack); Map objectModel = env.getObjectModel(); - Parameters resolvedParams = MapStackResolver.buildParameters(this.parameters, mapStack); + + String resolvedPattern = pattern.resolve(context, objectModel); + Parameters resolvedParams = VariableResolver.buildParameters(this.parameters, context, objectModel); Map result = null; @@ -134,11 +143,18 @@ } // Invoke children with the matcher results - return this.invokeNodes(children, env, context, result); + return this.invokeNodes(children, env, context, name, result); } else { // Matcher failed return false; } + } + + /** + * Disposable Interface + */ + public void dispose() { + this.manager.release(this.selector); } } 1.2.2.1 +19 -23 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNodeBuilder.java Index: MatchNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MatchNodeBuilder.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- MatchNodeBuilder.java 17 Mar 2002 21:55:22 -0000 1.2 +++ MatchNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.2.2.1 @@ -50,19 +50,18 @@ */ package org.apache.cocoon.components.treeprocessor.sitemap; -import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.ComponentSelector; -import org.apache.avalon.framework.component.Recomposable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; +import org.apache.avalon.framework.thread.ThreadSafe; import org.apache.cocoon.matching.Matcher; import org.apache.cocoon.matching.PreparableMatcher; import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNodeBuilder; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; import org.apache.cocoon.components.treeprocessor.ProcessingNode; -import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder; import org.apache.cocoon.components.treeprocessor.SimpleSelectorProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; import java.util.*; @@ -73,46 +72,43 @@ */ public class MatchNodeBuilder extends AbstractParentProcessingNodeBuilder - implements Recomposable { + implements ThreadSafe { private static final String SELECTOR_ROLE = Matcher.ROLE + "Selector"; - private ComponentManager manager; - - public void compose(ComponentManager manager) { - this.manager = manager; - } - - public void recompose(ComponentManager manager) { - this.manager = manager; - } - 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, SELECTOR_ROLE); // Get the type and class for this matcher ComponentsSelector selector = (ComponentsSelector)this.manager.lookup(SELECTOR_ROLE); - // Find matcher class - Matcher matcher = (Matcher)selector.select(type); - Class clazz = matcher.getClass(); - selector.release(matcher); + 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) && - !MapStackResolver.needsResolve(pattern); + !VariableResolverFactory.needsResolve(pattern); // Instanciate appropriate node SimpleSelectorProcessingNode node; + VariableResolver patternResolver = VariableResolverFactory.getResolver(pattern, this.manager); if (preparable) { - node = new PreparableMatchNode(type, pattern); + node = new PreparableMatchNode(type, VariableResolverFactory.unescape(pattern),name); } else { - node = new MatchNode(type, pattern); + node = new MatchNode(type, patternResolver,name); } this.treeBuilder.setupNode(node, config); 1.2.2.1 +15 -22 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java Index: MountNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- MountNode.java 15 Mar 2002 10:51:11 -0000 1.2 +++ MountNode.java 25 Nov 2002 21:51:59 -0000 1.2.2.1 @@ -50,22 +50,16 @@ */ package org.apache.cocoon.components.treeprocessor.sitemap; +import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; - -import org.apache.cocoon.components.pipeline.EventPipeline; -import org.apache.cocoon.components.pipeline.StreamPipeline; - -import org.apache.cocoon.environment.Environment; -import org.apache.cocoon.sitemap.PatternException; - -import org.apache.cocoon.components.treeprocessor.MapStackResolver; +import org.apache.avalon.framework.component.Composable; import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode; import org.apache.cocoon.components.treeprocessor.TreeProcessor; import org.apache.cocoon.components.treeprocessor.InvokeContext; - +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; +import org.apache.cocoon.environment.Environment; +import org.apache.cocoon.sitemap.PatternException; import java.util.*; -import org.apache.avalon.framework.component.Composable; -import org.apache.avalon.framework.component.ComponentException; /** * @@ -76,10 +70,10 @@ public class MountNode extends AbstractProcessingNode implements Composable { /** The 'uri-prefix' attribute */ - private MapStackResolver prefix; + private VariableResolver prefix; /** The 'src' attribute */ - private MapStackResolver source; + private VariableResolver source; /** Processors for sources */ private Map processors = new HashMap(); @@ -93,10 +87,8 @@ /** The component manager to be used by the mounted processor */ private ComponentManager manager; - public MountNode(String prefix, String source, String language, TreeProcessor parentProcessor) - throws PatternException { - this.prefix = MapStackResolver.getResolver(prefix); - this.source = MapStackResolver.getResolver(source); + public MountNode(VariableResolver prefix, VariableResolver source, String language, TreeProcessor parentProcessor) { this.prefix = prefix; + this.source = source; this.language = language; this.parentProcessor = parentProcessor; } @@ -109,14 +101,15 @@ throws Exception { List mapStack = context.getMapStack(); + Map objectModel = env.getObjectModel(); - String resolvedSource = this.source.resolve(mapStack); + String resolvedSource = this.source.resolve(context, objectModel); TreeProcessor processor = (TreeProcessor)processors.get(resolvedSource); if (processor == null) { processor = getProcessor(env, resolvedSource); } - String resolvedPrefix = this.prefix.resolve(mapStack); + String resolvedPrefix = this.prefix.resolve(context, objectModel); String oldPrefix = env.getURIPrefix(); String oldURI = env.getURI(); @@ -141,11 +134,11 @@ } private synchronized TreeProcessor getProcessor(Environment env, String source) throws Exception { - + TreeProcessor processor = (TreeProcessor)processors.get(source); if (processor == null) { - + // Handle directory mounts String actualSource; if (source.charAt(source.length() - 1) == '/') { 1.1.2.1 +5 -3 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNodeBuilder.java Index: MountNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNodeBuilder.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- MountNodeBuilder.java 5 Mar 2002 08:26:23 -0000 1.1 +++ MountNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -55,6 +55,8 @@ import org.apache.cocoon.components.treeprocessor.AbstractProcessingNodeBuilder; import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; /** * @@ -72,8 +74,8 @@ public ProcessingNode buildNode(Configuration config) throws Exception { MountNode node = new MountNode( - config.getAttribute("uri-prefix"), - config.getAttribute("src"), + VariableResolverFactory.getResolver(config.getAttribute("uri-prefix"), manager), + VariableResolverFactory.getResolver(config.getAttribute("src"), manager), config.getAttribute("language", null), this.treeBuilder.getProcessor() ); 1.1.2.3 +47 -43 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java Index: PipelineNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNode.java,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- PipelineNode.java 8 Aug 2002 03:21:28 -0000 1.1.2.2 +++ PipelineNode.java 25 Nov 2002 21:51:59 -0000 1.1.2.3 @@ -50,36 +50,33 @@ */ package org.apache.cocoon.components.treeprocessor.sitemap; -import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.Composable; -import org.apache.avalon.framework.parameters.Parameters; - +import org.apache.avalon.framework.configuration.Configuration; import org.apache.cocoon.ConnectionResetException; import org.apache.cocoon.Constants; import org.apache.cocoon.ResourceNotFoundException; - -import org.apache.cocoon.environment.Environment; -import org.apache.cocoon.environment.ObjectModelHelper; import org.apache.cocoon.components.notification.Notifying; import org.apache.cocoon.components.notification.NotifyingBuilder; -import org.apache.cocoon.components.pipeline.EventPipeline; -import org.apache.cocoon.components.pipeline.StreamPipeline; import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; -import org.apache.cocoon.components.treeprocessor.ProcessingNode; import org.apache.cocoon.components.treeprocessor.InvokeContext; +import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode; +import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.environment.Environment; -import java.util.*; +import java.util.Map; /** - * + * Handles <map:pipeline> * * @author Sylvain Wallez + * @author Gianugo Rabellino + * @author Carsten Ziegeler * @version CVS $Id$ */ - -public class PipelineNode extends AbstractParentProcessingNode implements Composable { +public class PipelineNode + extends AbstractParentProcessingNode + implements Composable, ParameterizableProcessingNode { // TODO : handle a 'fail-hard' environment attribute // can be useful to stop off-line generation when there's an error @@ -97,6 +94,20 @@ /** Is it the last in the enclosing ? */ private boolean isLast = false; + /** The component name of the processing pipeline */ + protected String processingPipeline; + + /** Optional Sitemap parameters */ + protected Map parameters; + + /** + * A constructor to receive the optional expires parameter + * and optional parameters for the processing pipeline + */ + public PipelineNode(Configuration config) { + this.processingPipeline = config.getAttribute("type", null); + } + /** * The component manager is used to create error pipelines */ @@ -104,22 +115,23 @@ this.manager = manager; } - public void setChildren(ProcessingNode[] nodes) - { + public void setChildren(ProcessingNode[] nodes) { this.children = nodes; } + public void setParameters(Map parameterMap) { + this.parameters = parameterMap; + } + public void setLast(boolean isLast) { this.isLast = isLast; } - public void set404Handler(ProcessingNode node) - { + public void set404Handler(ProcessingNode node) { this.error404 = node; } - public void set500Handler(ProcessingNode node) - { + public void set500Handler(ProcessingNode node) { this.error500 = node; } @@ -128,7 +140,7 @@ } public final boolean invoke(Environment env, InvokeContext context) - throws Exception { + throws Exception { // Always fail on external resquests if internal only. if (this.internalOnly && !context.isInternalRequest()) { @@ -136,7 +148,6 @@ } try { - if (invokeNodes(children, env, context)) { return true; } else if (this.isLast) { @@ -146,44 +157,33 @@ } else { return false; } - } catch (ConnectionResetException cre) { // Will be reported by CocoonServlet, rethrowing throw cre; - } catch(ResourceNotFoundException rnfe) { - getLogger().warn("Resource not found in pipeline at " + getLocation(), rnfe); - + getLogger().info("Resource not found in pipeline at " + getLocation(), rnfe); if (error404 != null) { // There's a handler return invokeErrorHandler(error404, rnfe, env); - } else { // No handler : propagate throw rnfe; } - } catch(Exception e) { - // Rethrow exception for internal requests if (error500 != null && !context.isInternalRequest()) { - - getLogger().warn("Error while processing pipeline at " + getLocation(), e); - + getLogger().info("Error while processing pipeline at " + getLocation(), e); return invokeErrorHandler(error500, e, env); - } else { // No handler : propagate - - getLogger().error("Error while processing pipeline at " + getLocation(), e); + getLogger().info("Error while processing pipeline at " + getLocation(), e); throw e; } } } private boolean invokeErrorHandler(ProcessingNode node, Exception ex, Environment env) - throws Exception { - + throws Exception { InvokeContext errorContext = null; try { @@ -198,23 +198,27 @@ // Create a Notifying NotifyingBuilder notifyingBuilder= (NotifyingBuilder)this.manager.lookup(NotifyingBuilder.ROLE); - Notifying currentNotifying = notifyingBuilder.build(this, ex); - this.manager.release(notifyingBuilder); + Notifying currentNotifying = null; + try { + currentNotifying = notifyingBuilder.build(this, ex); + } finally { + this.manager.release(notifyingBuilder); + } // Add it to the object model env.getObjectModel().put(Constants.NOTIFYING_OBJECT, currentNotifying ); // is added in HandleErrorsNode return node.invoke(env, errorContext); - } catch (Exception subEx) { - getLogger().error("error notifier barfs", subEx); + getLogger().error("Error notifier is unable to notify the problem. Please check the logs. In the default webapp, look in the WEB-INF/logs dir.", subEx); return false; - } finally { if (errorContext != null) { errorContext.dispose(); } } } + } + 1.1.2.1 +37 -41 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java Index: PipelineNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelineNodeBuilder.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- PipelineNodeBuilder.java 5 Mar 2002 08:26:23 -0000 1.1 +++ PipelineNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -1,5 +1,4 @@ /* - ============================================================================ The Apache Software License, Version 1.1 ============================================================================ @@ -53,7 +52,6 @@ import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; 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.ProcessingNodeBuilder; @@ -62,72 +60,70 @@ /** * Builds a <map:pipeline> - * @author Sylvain Wallez + * @author Gianugo Rabellino * @version CVS $Id$ */ -public class PipelineNodeBuilder extends AbstractParentProcessingNodeBuilder implements ThreadSafe { +public class PipelineNodeBuilder + extends AbstractParentProcessingNodeBuilder + implements ThreadSafe { /** This builder has no parameters -- return false */ protected boolean hasParameters() { return true; } - public ProcessingNode buildNode(Configuration config) throws Exception { + public ProcessingNode buildNode(Configuration config) + throws Exception { + PipelineNode node = new PipelineNode( config ); - PipelineNode node = new PipelineNode(); this.treeBuilder.setupNode(node, config); - node.setInternalOnly(config.getAttributeAsBoolean("internal-only", false)); - ProcessingNode error404Handler = null; ProcessingNode error500Handler = null; - Configuration[] childConfigs = config.getChildren(); List children = new ArrayList(); + for (int i = 0; i < childConfigs.length; i++) { - childLoop : for (int i = 0; i < childConfigs.length; i++) { Configuration childConfig = childConfigs[i]; - if (!isChild(childConfig)) { - continue childLoop; - } - - ProcessingNodeBuilder builder = this.treeBuilder.createNodeBuilder(childConfig); + if (isChild(childConfig)) { - if (builder instanceof HandleErrorsNodeBuilder) { - // Error handler : check type - HandleErrorsNode handler = (HandleErrorsNode)builder.buildNode(childConfig); - int type = handler.getStatusCode(); - - if ( (type == 404 && error404Handler != null) || - (type == 500 && error500Handler != null) ) { - String msg = "Duplicate handle-errors at " + handler.getLocation(); - getLogger().error(msg); - throw new ConfigurationException(msg); - } - - if (type == 404) { - error404Handler = handler; - } else if (type == 500) { - error500Handler = handler; + ProcessingNodeBuilder builder = this.treeBuilder.createNodeBuilder(childConfig); + if (builder instanceof HandleErrorsNodeBuilder) { + // Error handler : check type + HandleErrorsNode handler = (HandleErrorsNode)builder.buildNode(childConfig); + int type = handler.getStatusCode(); + + if ( (type == 404 && error404Handler != null) || + (type == 500 && error500Handler != null) ) { + String msg = "Duplicate handle-errors at " + handler.getLocation(); + getLogger().error(msg); + throw new ConfigurationException(msg); + } + + if (type == 404) { + error404Handler = handler; + } else if (type == 500) { + error500Handler = handler; + } else { + String msg = "Unknown handle-errors type (" + type + ") at " + handler.getLocation(); + getLogger().error(msg); + throw new ConfigurationException(msg); + } } else { - String msg = "Unkown handle-errors type (" + type + ") at " + handler.getLocation(); - getLogger().error(msg); - throw new ConfigurationException(msg); + // Regular builder + children.add(builder.buildNode(childConfig)); } - - } else { - // Regular builder - children.add(builder.buildNode(childConfig)); } } - node.setChildren(toNodeArray(children)); node.set404Handler(error404Handler); node.set500Handler(error500Handler); - return node; } + + } + 1.3.2.1 +18 -17 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNode.java Index: PipelinesNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNode.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- PipelinesNode.java 27 Mar 2002 15:13:40 -0000 1.3 +++ PipelinesNode.java 25 Nov 2002 21:51:59 -0000 1.3.2.1 @@ -50,30 +50,24 @@ */ package org.apache.cocoon.components.treeprocessor.sitemap; +import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.Composable; -import org.apache.avalon.framework.activity.Disposable; - -import org.apache.cocoon.ResourceNotFoundException; - -import org.apache.cocoon.environment.Redirector; - +import org.apache.cocoon.Processor; +import org.apache.cocoon.components.treeprocessor.InvokeContext; +import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.components.treeprocessor.SimpleParentProcessingNode; import org.apache.cocoon.environment.Environment; import org.apache.cocoon.environment.ForwardRedirector; -import org.apache.cocoon.components.pipeline.EventPipeline; -import org.apache.cocoon.components.pipeline.StreamPipeline; -import org.apache.cocoon.components.treeprocessor.SimpleParentProcessingNode; -import org.apache.cocoon.components.treeprocessor.ProcessingNode; -import org.apache.cocoon.components.treeprocessor.InvokeContext; -import org.apache.cocoon.Processor; +import org.apache.cocoon.environment.Redirector; -import java.util.*; -import org.apache.avalon.framework.component.ComponentException; +import java.util.Map; /** * Handles <map:pipelines> * * @author Sylvain Wallez + * @author Carsten Ziegeler * @version CVS $Id$ */ @@ -83,10 +77,14 @@ private static final String REDIRECTOR_ATTR = "sitemap:redirector"; private ComponentManager manager; - + private Processor processor; - public PipelinesNode(Processor processor) { + /** + * Constructor + * @param processor The processor for this sitemap + */ + public PipelinesNode(Processor processor) { this.processor = processor; } @@ -117,6 +115,9 @@ */ public final boolean invoke(Environment env, InvokeContext context) throws Exception { + + // Perform any common invoke functionality + super.invoke(env, context); // Recompose context (and pipelines) to the local component manager context.recompose(this.manager); 1.2.2.1 +11 -3 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNodeBuilder.java Index: PipelinesNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PipelinesNodeBuilder.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- PipelinesNodeBuilder.java 27 Mar 2002 15:13:40 -0000 1.2 +++ PipelinesNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.2.2.1 @@ -53,20 +53,28 @@ import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.thread.ThreadSafe; - import org.apache.cocoon.components.treeprocessor.ContainerNodeBuilder; import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import java.util.HashMap; +import java.util.Map; /** * Builds a <map:pipelines> * * @author Sylvain Wallez + * @author Carsten Ziegeler * @version CVS $Id$ */ public class PipelinesNodeBuilder extends ContainerNodeBuilder implements ThreadSafe { - public ProcessingNode buildNode(Configuration config) throws Exception { + public ProcessingNode buildNode(Configuration config) + throws Exception { + // check for component configurations + Configuration child = config.getChild("component-configurations", false); + if (child != null) { + this.checkNamespace(child); + } PipelinesNode node = new PipelinesNode(this.treeBuilder.getProcessor()); this.treeBuilder.setupNode(node, config); 1.1.2.1 +28 -11 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PreparableMatchNode.java Index: PreparableMatchNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/PreparableMatchNode.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- PreparableMatchNode.java 5 Mar 2002 08:26:23 -0000 1.1 +++ PreparableMatchNode.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -51,13 +51,13 @@ package org.apache.cocoon.components.treeprocessor.sitemap; import org.apache.cocoon.environment.Environment; -import org.apache.cocoon.components.pipeline.EventPipeline; -import org.apache.cocoon.components.pipeline.StreamPipeline; import org.apache.cocoon.sitemap.PatternException; import org.apache.cocoon.components.treeprocessor.SimpleSelectorProcessingNode; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; +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; +import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.component.ComponentSelector; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.Composable; @@ -80,6 +80,9 @@ /** The 'pattern' attribute */ private String pattern; + /** The 'name' for the variable anchor */ + private String name; + private Object preparedPattern; private Map parameters; @@ -87,9 +90,12 @@ /** The matcher, if it's ThreadSafe */ private PreparableMatcher threadSafeMatcher; - public PreparableMatchNode(String name, String pattern) throws PatternException { - super(name); + protected ComponentManager manager; + + public PreparableMatchNode(String type, String pattern, String name) throws PatternException { + super(type); this.pattern = pattern; + this.name = name; } public void setParameters(Map parameterMap) { @@ -98,7 +104,7 @@ public void compose(ComponentManager manager) throws ComponentException { - + this.manager = manager; setSelector((ComponentSelector)manager.lookup(Matcher.ROLE + "Selector")); // Prepare the pattern, and keep matcher if ThreadSafe @@ -109,11 +115,10 @@ } try { - this.preparedPattern = matcher.preparePattern(MapStackResolver.unescape(this.pattern)); + this.preparedPattern = matcher.preparePattern(this.pattern); } catch(PatternException pe) { String msg = "Invalid pattern '" + this.pattern + "' for matcher at " + this.getLocation(); - getLogger().error(msg, pe); throw new ComponentException(msg, pe); } finally { @@ -125,9 +130,14 @@ public final boolean invoke(Environment env, InvokeContext context) throws Exception { + + // Perform any common invoke functionality + super.invoke(env, context); Map objectModel = env.getObjectModel(); - Parameters resolvedParams = MapStackResolver.buildParameters(this.parameters, context.getMapStack()); + Parameters resolvedParams = VariableResolver.buildParameters( + this.parameters, context, objectModel + ); Map result = null; @@ -153,11 +163,18 @@ } // Invoke children with the matcher results - return this.invokeNodes(children, env, context, result); + return this.invokeNodes(children, env, context, name, result); } else { // Matcher failed return false; } + } + + /** + * Disposable Interface + */ + public void dispose() { + this.manager.release(this.selector); } } 1.1.2.1 +11 -12 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNode.java Index: ReadNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNode.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- ReadNode.java 5 Mar 2002 08:26:23 -0000 1.1 +++ ReadNode.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -52,12 +52,11 @@ import org.apache.cocoon.components.pipeline.StreamPipeline; import org.apache.cocoon.environment.Environment; -import org.apache.cocoon.sitemap.PatternException; import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode; import org.apache.cocoon.components.treeprocessor.InvokeContext; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; import java.util.List; import java.util.Map; @@ -72,7 +71,7 @@ private String readerName; - private MapStackResolver source; + private VariableResolver source; private String mimeType; @@ -87,9 +86,9 @@ * @param mimeType the mime-type, or null not specified. * @param statusCode the HTTP response status code, or -1 if not specified. */ - public ReadNode(String name, String source, String mimeType, int statusCode) throws PatternException { + public ReadNode(String name, VariableResolver source, String mimeType, int statusCode) { this.readerName = name; - this.source = MapStackResolver.getResolver(source); + this.source = source; this.mimeType = mimeType; this.statusCode = statusCode; } @@ -101,7 +100,7 @@ public final boolean invoke(Environment env, InvokeContext context) throws Exception { - List mapStack = context.getMapStack(); + Map objectModel = env.getObjectModel(); StreamPipeline pipeline = context.getStreamPipeline(); @@ -109,16 +108,16 @@ // No mime-type set on node pipeline.setReader( this.readerName, - source.resolve(mapStack), - MapStackResolver.buildParameters(this.parameters, mapStack) - ); + source.resolve(context, objectModel), + VariableResolver.buildParameters(this.parameters, context, objectModel) + ); } else { // mime-type set on node pipeline.setReader( this.readerName, - source.resolve(mapStack), - MapStackResolver.buildParameters(this.parameters, mapStack), + source.resolve(context, objectModel), + VariableResolver.buildParameters(this.parameters, context, objectModel), this.mimeType ); } 1.1.2.1 +4 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNodeBuilder.java Index: ReadNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/ReadNodeBuilder.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- ReadNodeBuilder.java 5 Mar 2002 08:26:23 -0000 1.1 +++ ReadNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -58,6 +58,8 @@ import org.apache.cocoon.components.treeprocessor.AbstractProcessingNodeBuilder; import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; /** * @@ -73,7 +75,7 @@ ReadNode node = new ReadNode( type, - config.getAttribute("src", null), + VariableResolverFactory.getResolver(config.getAttribute("src", null), this.manager), config.getAttribute("mime-type", null), config.getAttributeAsInteger("status-code", -1) ); 1.1.2.1 +5 -4 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/RedirectToNodeBuilder.java Index: RedirectToNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/RedirectToNodeBuilder.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- RedirectToNodeBuilder.java 5 Mar 2002 08:26:23 -0000 1.1 +++ RedirectToNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -57,8 +57,9 @@ 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.MapStackResolver; import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; import java.util.*; @@ -94,14 +95,14 @@ String target = config.getAttribute("target", null); if (target != null) { Map params = new HashMap(1); - params.put("target", MapStackResolver.getResolver(target)); + params.put("target", VariableResolverFactory.getResolver(target, this.manager)); this.callNode.setParameters(params); } return this.callNode; } else { ProcessingNode URINode = new RedirectToURINode( - config.getAttribute("uri"), + VariableResolverFactory.getResolver(config.getAttribute("uri"), this.manager), config.getAttributeAsBoolean("session", false) ); return this.treeBuilder.setupNode(URINode, config); 1.2.2.1 +9 -10 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/RedirectToURINode.java Index: RedirectToURINode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/RedirectToURINode.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- RedirectToURINode.java 27 Mar 2002 15:13:40 -0000 1.2 +++ RedirectToURINode.java 25 Nov 2002 21:51:59 -0000 1.2.2.1 @@ -57,8 +57,8 @@ import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode; import org.apache.cocoon.components.treeprocessor.InvokeContext; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; import java.util.List; import java.util.Map; @@ -72,24 +72,23 @@ public class RedirectToURINode extends AbstractProcessingNode { /** The 'uri' attribute */ - private MapStackResolver uri; + private VariableResolver uri; - private boolean keepSession; + private boolean createSession; - public RedirectToURINode(String uri, boolean keepSession) throws PatternException { - this.uri = MapStackResolver.getResolver(uri); + public RedirectToURINode(VariableResolver uri, boolean createSession) throws PatternException { + this.uri = uri; + this.createSession = createSession; } public final boolean invoke(Environment env, InvokeContext context) throws Exception { - String resolvedURI = uri.resolve(context.getMapStack()); + String resolvedURI = uri.resolve(context, env.getObjectModel()); if (getLogger().isInfoEnabled()) { getLogger().info("Redirecting to '" + resolvedURI + "' at " + this.getLocation()); } - - PipelinesNode.getRedirector(env).redirect(this.keepSession, resolvedURI); - + PipelinesNode.getRedirector(env).redirect(this.createSession, resolvedURI); return true; } } 1.2.2.1 +14 -9 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SelectNode.java Index: SelectNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SelectNode.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -r1.2 -r1.2.2.1 --- SelectNode.java 27 Mar 2002 22:20:12 -0000 1.2 +++ SelectNode.java 25 Nov 2002 21:51:59 -0000 1.2.2.1 @@ -66,10 +66,10 @@ import org.apache.cocoon.sitemap.PatternException; import org.apache.cocoon.components.treeprocessor.InvokeContext; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode; import org.apache.cocoon.components.treeprocessor.ProcessingNode; import org.apache.cocoon.components.treeprocessor.SimpleSelectorProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; import java.util.List; import java.util.Map; @@ -91,10 +91,12 @@ private ProcessingNode[][] whenNodes; - private MapStackResolver[] whenTests; + private VariableResolver[] whenTests; private ProcessingNode[] otherwhiseNodes; + private ComponentManager manager; + public SelectNode(String name) throws PatternException { super(name); } @@ -103,14 +105,14 @@ this.parameters = parameterMap; } - public void setCases(ProcessingNode[][] whenNodes, MapStackResolver[] whenTests, ProcessingNode[] otherwhiseNodes) { + public void setCases(ProcessingNode[][] whenNodes, VariableResolver[] whenTests, ProcessingNode[] otherwhiseNodes) { this.whenNodes = whenNodes; this.whenTests = whenTests; this.otherwhiseNodes = otherwhiseNodes; } public void compose(ComponentManager manager) throws ComponentException { - + this.manager = manager; setSelector((ComponentSelector)manager.lookup(Selector.ROLE + "Selector")); // Get the selector, if it's ThreadSafe @@ -120,17 +122,19 @@ public final boolean invoke(Environment env, InvokeContext context) throws Exception { + // Perform any common invoke functionality + super.invoke(env, context); + // Prepare data needed by the action Map objectModel = env.getObjectModel(); - List mapStack = context.getMapStack(); - Parameters resolvedParams = MapStackResolver.buildParameters(this.parameters, mapStack); + Parameters resolvedParams = VariableResolver.buildParameters(this.parameters, context, objectModel); // If selector is ThreadSafe, avoid select() and try/catch block (faster !) if (this.threadSafeSelector != null) { for (int i = 0; i < this.whenTests.length; i++) { if (this.threadSafeSelector.select( - whenTests[i].resolve(mapStack), + whenTests[i].resolve(context, objectModel), objectModel, resolvedParams)) { return invokeNodes(this.whenNodes[i], env, context); @@ -149,7 +153,7 @@ for (int i = 0; i < this.whenTests.length; i++) { if (selector.select( - whenTests[i].resolve(mapStack), + whenTests[i].resolve(context, objectModel), objectModel, resolvedParams)) { return invokeNodes(this.whenNodes[i], env, context); @@ -171,5 +175,6 @@ if (this.threadSafeSelector != null) { this.selector.release(this.threadSafeSelector); } + this.manager.release(this.selector); } } 1.1.2.1 +34 -17 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SelectNodeBuilder.java Index: SelectNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SelectNodeBuilder.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- SelectNodeBuilder.java 5 Mar 2002 08:26:23 -0000 1.1 +++ SelectNodeBuilder.java 25 Nov 2002 21:51:59 -0000 1.1.2.1 @@ -57,9 +57,10 @@ import org.apache.cocoon.selection.Selector; import org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNodeBuilder; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder; import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; import java.util.*; @@ -69,21 +70,20 @@ * @version CVS $Id$ */ -public class SelectNodeBuilder extends AbstractParentProcessingNodeBuilder implements ThreadSafe { +public class SelectNodeBuilder extends AbstractParentProcessingNodeBuilder { + + private static final String SELECTOR_ROLE = Selector.ROLE + "Selector"; public ProcessingNode buildNode(Configuration config) throws Exception { - String type = this.treeBuilder.getTypeForStatement(config, Selector.ROLE + "Selector"); - - SelectNode node = new SelectNode(type); - this.treeBuilder.setupNode(node, config); + String type = this.treeBuilder.getTypeForStatement(config, SELECTOR_ROLE); // Lists of ProcessingNode[] and test resolvers for each "when" List whenChildren = new ArrayList(); List whenTests = new ArrayList(); // Nodes for otherwise (if any) - ProcessingNode[] otherwhiseNodes = null; + ProcessingNode[] otherwiseNodes = null; Configuration[] childrenConfig = config.getChildren(); for (int i = 0; i < childrenConfig.length; i++) { @@ -94,19 +94,21 @@ if ("when".equals(name)) { checkNamespace(childConfig); - whenTests.add(MapStackResolver.getResolver(childConfig.getAttribute("test"))); + whenTests.add( + VariableResolverFactory.getResolver(childConfig.getAttribute("test"), this.manager) + ); whenChildren.add(buildChildNodes(childConfig)); } else if ("otherwise".equals(name)) { checkNamespace(childConfig); - if (otherwhiseNodes != null) { + if (otherwiseNodes != null) { String msg = "Duplicate " + name + " (only one is allowed) at " + childConfig.getLocation(); getLogger().error(msg); throw new ConfigurationException(msg); } - otherwhiseNodes = buildChildNodes(childConfig); + otherwiseNodes = buildChildNodes(childConfig); } else if (isParameter(childConfig)) { // ignore it. It is handled automatically in setupNode() @@ -114,17 +116,32 @@ } else { // Unknown element String msg = "Unknown element '" + name + "' in select at " + childConfig.getLocation(); - getLogger().error(msg); throw new ConfigurationException(msg); } } - node.setCases( - (ProcessingNode[][])whenChildren.toArray(new ProcessingNode[0][0]), - (MapStackResolver[])whenTests.toArray(new MapStackResolver[whenTests.size()]), - otherwhiseNodes - ); + ProcessingNode[][] whenChildrenNodes = (ProcessingNode[][])whenChildren.toArray(new ProcessingNode[0][0]); + VariableResolver[] whenResolvers = (VariableResolver[])whenTests.toArray(new VariableResolver[whenTests.size()]); + + // Get the type and class for this selector + ComponentsSelector compSelector = (ComponentsSelector)this.manager.lookup(SELECTOR_ROLE); + Class clazz = null; + try { + // Find selector class + Selector selector = (Selector)compSelector.select(type); + try { + clazz = selector.getClass(); + } finally { + compSelector.release(selector); + } + } finally { + this.manager.release(compSelector); + } + + SelectNode node = new SelectNode(type); + this.treeBuilder.setupNode(node, config); + node.setCases(whenChildrenNodes, whenResolvers, otherwiseNodes); return node; } } 1.1.2.2 +10 -9 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java Index: SerializeNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNode.java,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- SerializeNode.java 8 Aug 2002 03:21:28 -0000 1.1.2.1 +++ SerializeNode.java 25 Nov 2002 21:51:59 -0000 1.1.2.2 @@ -58,9 +58,10 @@ import org.apache.cocoon.sitemap.PatternException; -import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode; import org.apache.cocoon.components.treeprocessor.InvokeContext; +import org.apache.cocoon.components.treeprocessor.PipelineEventComponentProcessingNode; import org.apache.cocoon.components.treeprocessor.ProcessingNode; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; import java.util.*; /** @@ -69,7 +70,7 @@ * @version CVS $Id$ */ -public class SerializeNode extends AbstractProcessingNode { +public class SerializeNode extends PipelineEventComponentProcessingNode { private String serializerName; @@ -77,7 +78,6 @@ private int statusCode; - private Map views; /** * Build a SerializerNode having a name, a mime-type and a status code (HTTP codes). @@ -92,15 +92,13 @@ this.statusCode = statusCode; } - public void setViews(Map views) { - this.views = views; - } public final boolean invoke(Environment env, InvokeContext context) throws Exception { // Check view if (this.views != null) { + String cocoonView = env.getView(); if (cocoonView != null) { @@ -125,7 +123,10 @@ StreamPipeline pipeline = context.getStreamPipeline(); - if (this.mimeType == null) { + List mapStack = context.getMapStack(); + Map objectModel = env.getObjectModel(); + + if (this.mimeType == null) { // No mime-type set on node pipeline.setSerializer( this.serializerName, @@ -138,7 +139,7 @@ pipeline.setSerializer( this.serializerName, null, - Parameters.EMPTY_PARAMETERS, + Parameters.EMPTY_PARAMETERS, // No parameters on serializers this.mimeType ); } 1.1.2.1 +1 -1 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNodeBuilder.java Index: SerializeNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SerializeNodeBuilder.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 1.4.2.3 +12 -6 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java Index: SitemapLanguage.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java,v retrieving revision 1.4.2.2 retrieving revision 1.4.2.3 diff -u -r1.4.2.2 -r1.4.2.3 --- SitemapLanguage.java 30 Jun 2002 20:45:54 -0000 1.4.2.2 +++ SitemapLanguage.java 25 Nov 2002 21:51:59 -0000 1.4.2.3 @@ -100,7 +100,9 @@ Configuration config = tree.getChild("components", false); if (config == null) { - getLogger().debug("Sitemap has no components definition at " + tree.getLocation()); + if (this.getLogger().isDebugEnabled()) { + getLogger().debug("Sitemap has no components definition at " + tree.getLocation()); + } config = new DefaultConfiguration("", ""); } @@ -205,7 +207,9 @@ * @param view the view name */ public void addViewForLabel(String label, String view) { - getLogger().debug("views:addViewForLabel(" + label + ", " + view + ")"); + if (this.getLogger().isDebugEnabled()) { + getLogger().debug("views:addViewForLabel(" + label + ", " + view + ")"); + } Set views = (Set)this.labelViews.get(label); if (views == null) { views = new HashSet(); @@ -259,7 +263,7 @@ } } catch(Exception e) { // Ignore (no selector for this role) - getLogger().debug("No selector for role " + role); + getLogger().warn("No selector for role " + role); } finally { this.manager.release( selector ); } @@ -300,7 +304,9 @@ if (views.size() == 0) { views = null; - getLogger().debug(statement.getName() + " has no views at " + statement.getLocation()); + if (getLogger().isDebugEnabled()) { + getLogger().debug(statement.getName() + " has no views at " + statement.getLocation()); + } } else { if (getLogger().isDebugEnabled()) { // Dump matching views @@ -366,5 +372,5 @@ } else { return Arrays.asList(StringUtils.split(labels, ", \t\n\r")); } - } + } } 1.1.2.1 +13 -14 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/TransformNode.java Index: TransformNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/TransformNode.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- TransformNode.java 5 Mar 2002 08:26:23 -0000 1.1 +++ TransformNode.java 25 Nov 2002 21:52:00 -0000 1.1.2.1 @@ -53,11 +53,13 @@ import org.apache.cocoon.environment.Environment; import org.apache.cocoon.sitemap.PatternException; -import org.apache.cocoon.components.treeprocessor.AbstractProcessingNode; import org.apache.cocoon.components.treeprocessor.InvokeContext; -import org.apache.cocoon.components.treeprocessor.MapStackResolver; 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.avalon.framework.parameters.Parameters; import java.util.List; import java.util.Map; @@ -68,42 +70,39 @@ * @version CVS $Id$ */ -public class TransformNode extends AbstractProcessingNode implements ParameterizableProcessingNode { +public class TransformNode extends PipelineEventComponentProcessingNode implements ParameterizableProcessingNode { private String transformerName; - private MapStackResolver source; + private VariableResolver source; private Map parameters; - private Map views; - public TransformNode(String name, String source) throws PatternException { + public TransformNode(String name, VariableResolver source) throws PatternException { this.transformerName = name; - this.source = MapStackResolver.getResolver(source); + this.source = source; } public void setParameters(Map parameterMap) { this.parameters = parameterMap; } - public void setViews(Map views) { - this.views = views; - } public final boolean invoke(Environment env, InvokeContext context) throws Exception { - List mapStack = context.getMapStack(); + Map objectModel = env.getObjectModel(); context.getEventPipeline().addTransformer( this.transformerName, - source.resolve(mapStack), - MapStackResolver.buildParameters(this.parameters, mapStack) + source.resolve(context, objectModel), + VariableResolver.buildParameters(this.parameters, context, objectModel) ); // Check view if (this.views != null) { + String cocoonView = env.getView(); if (cocoonView != null) { 1.1.2.1 +9 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/TransformNodeBuilder.java Index: TransformNodeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/TransformNodeBuilder.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- TransformNodeBuilder.java 5 Mar 2002 08:26:23 -0000 1.1 +++ TransformNodeBuilder.java 25 Nov 2002 21:52:00 -0000 1.1.2.1 @@ -57,6 +57,8 @@ 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.VariableResolver; +import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory; import java.util.*; @@ -79,7 +81,12 @@ this.views = ((SitemapLanguage)this.treeBuilder).getViewsForStatement(Transformer.ROLE, type, config); - this.node = new TransformNode(type, config.getAttribute("src", null)); + + this.node = new TransformNode( + type, + VariableResolverFactory.getResolver(config.getAttribute("src", null), this.manager) + ); + return this.treeBuilder.setupNode(node, config); } 1.1.2.1 +7 -3 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/package.html Index: package.html =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/package.html,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 --- package.html 5 Mar 2002 08:26:23 -0000 1.1 +++ package.html 25 Nov 2002 21:52:00 -0000 1.1.2.1 @@ -1,6 +1,10 @@ -package description + + Implemention of the Sitemap language + - Implemention of the Sitemap language. +

Implemention of the Sitemap language

+

+

- \ No newline at end of file + No revision No revision 1.3.2.1 +1 -6 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/NOPVariableResolver.java Index: NOPVariableResolver.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/NOPVariableResolver.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- NOPVariableResolver.java 12 Oct 2002 05:11:40 -0000 1.3 +++ NOPVariableResolver.java 25 Nov 2002 21:52:01 -0000 1.3.2.1 @@ -64,15 +64,10 @@ private String expression = null; public NOPVariableResolver(String expression) { + super(expression); if (expression != null) { - // Keep the original unescaped expression - this.originalExpr = expression; this.expression = VariableResolverFactory.unescape(expression); } - } - - public String toString() { - return this.originalExpr; } public final String resolve(InvokeContext context, Map objectModel) { 1.6.2.1 +2 -3 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolver.java Index: PreparedVariableResolver.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolver.java,v retrieving revision 1.6 retrieving revision 1.6.2.1 diff -u -r1.6 -r1.6.2.1 --- PreparedVariableResolver.java 29 Oct 2002 13:16:12 -0000 1.6 +++ PreparedVariableResolver.java 25 Nov 2002 21:52:01 -0000 1.6.2.1 @@ -78,7 +78,6 @@ private ComponentSelector selector; final private List items = new ArrayList(); - final private String originalExpr; // Special constants used for levels static final int ROOT = 0; @@ -95,7 +94,7 @@ public PreparedVariableResolver(String expr, ComponentManager manager) throws PatternException { - this.originalExpr = expr; + super(expr); this.manager = manager; @@ -267,7 +266,7 @@ { String name = (String) this.items.get(++i); Object variable = this.items.get(++i); - Map levelResult = context.getMapByAnchor(name); + Map levelResult = null; //context.getMapByAnchor(name); if (levelResult == null) { throw new PatternException("Error while evaluating '" + this.originalExpr + 1.3.2.1 +13 -8 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/VariableResolver.java Index: VariableResolver.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/VariableResolver.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -r1.3 -r1.3.2.1 --- VariableResolver.java 12 Oct 2002 05:11:40 -0000 1.3 +++ VariableResolver.java 25 Nov 2002 21:52:01 -0000 1.3.2.1 @@ -72,9 +72,13 @@ public static final Map EMPTY_MAP = Collections.unmodifiableMap(new java.util.HashMap(0)); - protected String originalExpr = null; + protected final String originalExpr; + + protected VariableResolver(String expr) { + this.originalExpr = expr; + } - public String getKey() { + public final String toString() { return this.originalExpr; } @@ -83,11 +87,12 @@ */ public boolean equals(Object object) { if (object instanceof VariableResolver) { - if (((VariableResolver)object).getKey().equals(this.getKey())) { - return true; - } + VariableResolver other = (VariableResolver)object; + return (this.originalExpr == null && other.originalExpr == null) || + (this.originalExpr.equals(other.originalExpr)); + } else { + return false; } - return false; } /** @@ -95,7 +100,7 @@ * needed to determine uniqueness within hashtables */ public int hashCode() { - return (int) HashUtil.hash(this.getKey()); + return this.originalExpr == null ? 0 : this.originalExpr.hashCode(); } /** 1.1.2.1 +0 -0 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/VariableResolverFactory.java Index: VariableResolverFactory.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/variables/VariableResolverFactory.java,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 ---------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org For additional commands, e-mail: cocoon-cvs-help@xml.apache.org