public final Map call(Environment env,
InvokeContext context,
Parameters params) throws Exception {
String cocoonAction = env.getAction();
// Store the parameters from the caller into the environment so that they can be merged with
// each action's parameters.
Map result = null;
// Call each action that either has no cocoonAction, or whose cocoonAction equals
// the one from the environment.
env.setAttribute(CALLER_PARAMETERS, params);
for (int i = 0; i < nodes.length; i++) {
String actionName = actionNames[i];
if (actionName == null || actionName.equals(cocoonAction)) {
this.nodes[i].invoke(env, context);
// Get action results. They're passed back through the environment since action-sets
// "violate" the tree hierarchy (the returned Map is visible outside of the node)
Map actionResult = (Map)env.getAttribute(ACTION_RESULTS);
// Don't forget to clear it
env.removeAttribute(ACTION_RESULTS);
if (actionResult != null) {
// Merge the result in the global result, creating it if necessary.
if (result == null) {
result = new HashMap(actionResult);
} else {
result.putAll(actionResult);
}
}
} // if (actionName...
} // for (int i...
return result;
}
Call the actions composing the action-set and return the combined result of
these actions. |