KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > treeprocessor > sitemap > ScriptNodeBuilder


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.treeprocessor.sitemap;
17
18 import org.apache.avalon.framework.configuration.Configuration;
19 import org.apache.cocoon.components.treeprocessor.AbstractProcessingNodeBuilder;
20 import org.apache.cocoon.components.treeprocessor.LinkedProcessingNodeBuilder;
21 import org.apache.cocoon.components.treeprocessor.ProcessingNode;
22 import org.apache.cocoon.components.flow.Interpreter;
23
24 /**
25  * Builder class for creating a {@link ScriptNode} instance
26  * corresponding to a <map:script> element in the sitemap.
27  *
28  * @author <a HREF="mailto:ovidiu@apache.org">Ovidiu Predescu</a>
29  * @since March 13, 2002
30  * @version CVS $Id: ScriptNodeBuilder.java 30932 2004-07-29 17:35:38Z vgritsenko $
31  */

32 public class ScriptNodeBuilder
33   extends AbstractProcessingNodeBuilder
34   implements LinkedProcessingNodeBuilder
35 {
36   protected ScriptNode node;
37
38   public ProcessingNode buildNode(Configuration config)
39     throws Exception JavaDoc
40   {
41     String JavaDoc source = config.getAttribute("src");
42
43     this.node = new ScriptNode(source);
44     this.treeBuilder.setupNode(this.node, config);
45
46     return this.node;
47   }
48
49   /**
50    * Call the built node to register the script it contains with the
51    * flow interpreter.
52    */

53   public void linkNode()
54     throws Exception JavaDoc
55   {
56     FlowNode flowNode = (FlowNode)this.treeBuilder.getRegisteredNode("flow");
57     Interpreter interpreter = flowNode.getInterpreter();
58
59     this.node.registerScriptWithInterpreter(interpreter);
60   }
61 }
62
Popular Tags