ovidiu 2002/09/24 01:27:01
Modified: src/java/org/apache/cocoon/components/treeprocessor/sitemap
CallNodeBuilder.java
Log:
Modified to support using <map:call> for invoking resources, flow
functions and restarting continuations.
Revision Changes Path
1.6 +38 -20
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CallNodeBuilder.java 11 Sep 2002 10:08:34 -0000 1.5
+++ CallNodeBuilder.java 24 Sep 2002 08:27:01 -0000 1.6
@@ -59,6 +59,7 @@
import org.apache.cocoon.components.treeprocessor.CategoryNodeBuilder;
import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder;
import org.apache.cocoon.components.treeprocessor.ProcessingNode;
+import org.apache.cocoon.components.flow.Interpreter;
/**
*
@@ -73,20 +74,26 @@
protected ProcessingNode node;
protected String resourceName;
protected String functionName;
+ protected String continuationId;
public ProcessingNode buildNode(Configuration config)
throws Exception
{
- this.resourceName = config.getAttribute("resource", null);
- this.functionName = config.getAttribute("function", null);
+ resourceName = config.getAttribute("resource", null);
+ functionName = config.getAttribute("function", null);
+ continuationId = config.getAttribute("continuation", null);
+
+ if (resourceName == null) {
+ if (functionName == null && continuationId == null)
+ throw new ConfigurationException("<map:call> must have either a
'resource', a 'function' or a 'continuation' attribute!");
- if (resourceName == null && functionName == null)
- throw new ConfigurationException("<map:call> must have either a
'resource' or a 'function' attribute!");
-
- if (resourceName != null)
- this.node = new CallNode();
- else
- this.node = new CallFunctionNode(functionName);
+ node = new CallFunctionNode(functionName, continuationId);
+ }
+ else {
+ if (functionName != null || continuationId != null)
+ throw new ConfigurationException("<map:call> can be used to call
either a resource, or a function/continuation in the control flow! Please specify
either <map:call resource=\"...\"/> or <map:call function=\"...\"
continuation=\"...\"/>.");
+ node = new CallNode();
+ }
this.treeBuilder.setupNode(this.node, config);
if (node instanceof Configurable)
@@ -98,18 +105,29 @@
public void linkNode()
throws Exception
{
+ if (resourceName != null) {
+ // We have a <map:call resource="..."/>
CategoryNode resources
- = CategoryNodeBuilder.getCategoryNode(this.treeBuilder, "resources");
+ = CategoryNodeBuilder.getCategoryNode(treeBuilder, "resources");
- if (resources == null) {
- String msg = "This sitemap contains no resources. Cannot call at "
- + this.node.getLocation();
- throw new ConfigurationException(msg);
- }
+ if (resources == null)
+ throw new ConfigurationException("This sitemap contains no resources.
Cannot call at " + node.getLocation());
- if (resourceName != null)
- ((CallNode)this.node).setResource(resources, this.resourceName);
- else
- ((CallFunctionNode)this.node).setResources(resources);
+ ((CallNode)this.node).setResource(resources, this.resourceName);
+ }
+ else {
+ // We have a <map:call> with either "function" or
+ // "continuation", or both specified
+
+ // Check to see if a flow has been defined in this sitemap
+ FlowNode flow = (FlowNode)treeBuilder.getRegisteredNode("flow");
+ if (flow == null)
+ throw new ConfigurationException("This sitemap contains no control
flows defined, cannot call at " + node.getLocation() + ". Define a control flow using
<map:flow>, with embedded <map:script> elements.");
+
+ // Get the Interpreter instance and set it up in the
+ // CallFunctionNode function
+ Interpreter interpreter = flow.getInterpreter();
+ ((CallFunctionNode)node).setInterpreter(interpreter);
+ }
}
}
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]