You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2002/03/27 16:10:35 UTC
cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap ActionSetNode.java ActionSetNodeBuilder.java
sylvain 02/03/27 07:10:35
Modified: src/java/org/apache/cocoon/components/treeprocessor/sitemap
ActionSetNode.java ActionSetNodeBuilder.java
Log:
Fix parameter handling in action-sets : local parameters are now correctly merged with the ones coming from the pipeline (reported by Torsten).
Revision Changes Path
1.2 +22 -9 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ActionSetNode.java 5 Mar 2002 08:26:23 -0000 1.1
+++ ActionSetNode.java 27 Mar 2002 15:10:35 -0000 1.2
@@ -59,10 +59,10 @@
import org.apache.cocoon.acting.Action;
import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.sitemap.PatternException;
-import org.apache.cocoon.sitemap.SitemapRedirector;
import org.apache.cocoon.components.treeprocessor.InvokeContext;
import org.apache.cocoon.components.treeprocessor.MapStackResolver;
@@ -74,7 +74,7 @@
/**
*
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: ActionSetNode.java,v 1.1 2002/03/05 08:26:23 sylvain Exp $
+ * @version CVS $Id: ActionSetNode.java,v 1.2 2002/03/27 15:10:35 sylvain Exp $
*/
public class ActionSetNode extends SimpleSelectorProcessingNode
@@ -91,12 +91,18 @@
/** The src for each action */
private MapStackResolver[] sources;
+
+ /** The parameters for each action */
+ private Map[] parameters;
- public ActionSetNode(String name, String[] types, String[] actionNames, MapStackResolver[] sources) {
+ public ActionSetNode(
+ String name, String[] types, String[] actionNames,
+ MapStackResolver[] sources, Map[] parameters) {
super(name);
this.types = types;
this.actionNames = actionNames;
this.sources = sources;
+ this.parameters = parameters;
}
public void compose(ComponentManager manager) throws ComponentException {
@@ -125,10 +131,10 @@
public final Map call(Environment env, InvokeContext context, Parameters params) throws Exception {
// Prepare data needed by the actions
- Map objectModel = env.getObjectModel();
- SitemapRedirector redirector = PipelinesNode.getRedirector(env);
- SourceResolver resolver = getSourceResolver(objectModel);
- List mapStack = context.getMapStack();
+ Map objectModel = env.getObjectModel();
+ Redirector redirector = PipelinesNode.getRedirector(env);
+ SourceResolver resolver = getSourceResolver(objectModel);
+ List mapStack = context.getMapStack();
String cocoonAction = env.getAction();
@@ -145,19 +151,26 @@
String actionName = actionNames[i];
String source = sources[i].resolve(mapStack);
if (actionName == null || actionName.equals(cocoonAction)) {
+
+ Parameters actionParams = MapStackResolver.buildParameters(parameters[i], mapStack);
+ if (actionParams == Parameters.EMPTY_PARAMETERS) {
+ actionParams = params;
+ } else {
+ actionParams.merge(params);
+ }
// If action is ThreadSafe, avoid select() and try/catch block (faster !)
if ((action = this.threadSafeActions[i]) != null) {
actionResult = action.act(
- redirector, resolver, objectModel, source, params);
+ redirector, resolver, objectModel, source, actionParams);
} else {
action = (Action)this.selector.select(this.types[i]);
try {
actionResult = action.act(
- redirector, resolver, objectModel, source, params);
+ redirector, resolver, objectModel, source, actionParams);
} finally {
this.selector.release(action);
}
1.2 +5 -2 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ActionSetNodeBuilder.java 5 Mar 2002 08:26:23 -0000 1.1
+++ ActionSetNodeBuilder.java 27 Mar 2002 15:10:35 -0000 1.2
@@ -65,7 +65,7 @@
/**
*
* @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
- * @version CVS $Id: ActionSetNodeBuilder.java,v 1.1 2002/03/05 08:26:23 sylvain Exp $
+ * @version CVS $Id: ActionSetNodeBuilder.java,v 1.2 2002/03/27 15:10:35 sylvain Exp $
*/
public class ActionSetNodeBuilder extends AbstractProcessingNodeBuilder implements ThreadSafe {
@@ -78,6 +78,7 @@
List actionTypes = new ArrayList();
List actionNames = new ArrayList();
List actionSources = new ArrayList();
+ List actionParameters = new ArrayList();
Configuration[] childrenConfig = config.getChildren();
for (int i = 0; i < childrenConfig.length; i++) {
@@ -93,6 +94,7 @@
actionTypes.add(type);
actionNames.add(childConfig.getAttribute("action", null));
actionSources.add(MapStackResolver.getResolver(childConfig.getAttribute("src", null)));
+ actionParameters.add(this.getParameters(childConfig));
} else {
// Unknown element
@@ -104,10 +106,11 @@
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()]);
- ActionSetNode node = new ActionSetNode(actionSetName, types, actions, sources);
+ ActionSetNode node = new ActionSetNode(actionSetName, types, actions, sources, parameters);
this.treeBuilder.setupNode(node, config);
return node;
----------------------------------------------------------------------
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