ovidiu 02/03/13 11:03:59 Added: src/scratchpad/schecoon/src/org/apache/cocoon/components/treeprocessor/sitemap CallFunctionNode.java Log: Node handler for calling functions in the flow control layer. Revision Changes Path 1.1 xml-cocoon2/src/scratchpad/schecoon/src/org/apache/cocoon/components/treeprocessor/sitemap/CallFunctionNode.java Index: CallFunctionNode.java =================================================================== package org.apache.cocoon.components.treeprocessor.sitemap; import org.apache.avalon.framework.activity.Initializable; 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.ProcessingNode; import java.util.List; import java.util.Map; public class CallFunctionNode extends AbstractProcessingNode implements Initializable, ParameterizableProcessingNode { protected Map parameters; protected String functionName; protected MapStackResolver resourceResolver; public CallFunctionNode(String funName) { functionName = funName; } public void setParameters(Map params) { parameters = params; System.out.println("CallFunctionNode: params = " + params); } public void initialize() throws Exception { if (MapStackResolver.needsResolve(functionName)) { // Will always be resolved at invoke time this.resourceResolver = MapStackResolver.getResolver(functionName); } } public boolean invoke(Environment env, InvokeContext context) throws Exception { Map params = parameters; // Resolve parameters if (this.parameters != null) { params = MapStackResolver.resolveMap(this.parameters, context.getMapStack()); } String name = functionName; if (resourceResolver != null) { // Need to resolve the function name at runtime name = resourceResolver.resolve(context.getMapStack()); if (getLogger().isInfoEnabled()) { getLogger().info("Calling function " + name); } } System.out.println("CallFunctionNode: invoking " + name + ", params = " + params); return true; } }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]