KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * Copyright 1999-2005 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 java.util.ArrayList JavaDoc;
19 import java.util.List JavaDoc;
20
21 import org.apache.avalon.framework.configuration.Configuration;
22 import org.apache.avalon.framework.configuration.ConfigurationException;
23 import org.apache.avalon.framework.thread.ThreadSafe;
24 import org.apache.cocoon.components.treeprocessor.ContainerNodeBuilder;
25 import org.apache.cocoon.components.treeprocessor.ProcessingNode;
26 import org.apache.cocoon.components.treeprocessor.ProcessingNodeBuilder;
27
28 /**
29  * Builds a <map:pipelines>
30  *
31  * @author <a HREF="mailto:juergen.seitz@basf-it-services.com">J&uuml;rgen Seitz</a>
32  * @author <a HREF="mailto:bluetkemeier@s-und-n.de">Bj&ouml;rn L&uuml;tkemeier</a>
33  * @author <a HREF="mailto:sylvain@apache.org">Sylvain Wallez</a>
34  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
35  * @version $Id: PipelinesNodeBuilder.java 157153 2005-03-11 20:47:16Z vgritsenko $
36  */

37 public class PipelinesNodeBuilder extends ContainerNodeBuilder implements ThreadSafe {
38
39     public ProcessingNode buildNode(Configuration config)
40     throws Exception JavaDoc {
41         // Check for component configurations
42
Configuration child = config.getChild("component-configurations", false);
43         if (child != null) {
44             checkNamespace(child);
45             this.treeBuilder.getProcessor().setComponentConfigurations(child);
46         }
47
48         PipelinesNode node = new PipelinesNode();
49         this.treeBuilder.setupNode(node, config);
50
51         Configuration[] childConfigs = config.getChildren();
52         List JavaDoc children = new ArrayList JavaDoc();
53         HandleErrorsNode handler = null;
54
55         for (int i = 0; i < childConfigs.length; i++) {
56             Configuration childConfig = childConfigs[i];
57             if (isChild(childConfig)) {
58
59                 ProcessingNodeBuilder builder = this.treeBuilder.createNodeBuilder(childConfig);
60                 if (builder instanceof HandleErrorsNodeBuilder) {
61                     handler = (HandleErrorsNode)builder.buildNode(childConfig);
62                 } else {
63                     // Regular builder
64
children.add(builder.buildNode(childConfig));
65                 }
66             }
67         }
68
69         if (children.size() == 0) {
70             String JavaDoc msg = "There must be at least one pipeline at " + config.getLocation();
71             throw new ConfigurationException(msg);
72         }
73
74         node.setChildren(toNodeArray(children));
75         node.setErrorHandler(handler);
76
77         return node;
78     }
79 }
80
Popular Tags