01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.components.treeprocessor.sitemap;
18:
19: import java.util.ArrayList;
20: import java.util.List;
21:
22: import org.apache.avalon.framework.configuration.Configuration;
23: import org.apache.avalon.framework.configuration.ConfigurationException;
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ürgen Seitz</a>
32: * @author <a href="mailto:bluetkemeier@s-und-n.de">Björn Lü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 433543 2006-08-22 06:22:54Z crossley $
36: */
37: public class PipelinesNodeBuilder extends ContainerNodeBuilder {
38:
39: public ProcessingNode buildNode(Configuration config)
40: throws Exception {
41: // Check for component configurations
42: Configuration child = config.getChild(
43: "component-configurations", false);
44: if (child != null) {
45: checkNamespace(child);
46: this .treeBuilder.getProcessor().setComponentConfigurations(
47: child);
48: }
49:
50: PipelinesNode node = new PipelinesNode();
51: this .treeBuilder.setupNode(node, config);
52:
53: Configuration[] childConfigs = config.getChildren();
54: List children = new ArrayList();
55: HandleErrorsNode handler = null;
56:
57: for (int i = 0; i < childConfigs.length; i++) {
58: Configuration childConfig = childConfigs[i];
59: if (isChild(childConfig)) {
60:
61: ProcessingNodeBuilder builder = this .treeBuilder
62: .createNodeBuilder(childConfig);
63: if (builder instanceof HandleErrorsNodeBuilder) {
64: handler = (HandleErrorsNode) builder
65: .buildNode(childConfig);
66: } else {
67: // Regular builder
68: children.add(builder.buildNode(childConfig));
69: }
70: }
71: }
72:
73: if (children.size() == 0) {
74: String msg = "There must be at least one pipeline at "
75: + config.getLocation();
76: throw new ConfigurationException(msg);
77: }
78:
79: node.setChildren(toNodeArray(children));
80: node.setErrorHandler(handler);
81:
82: return node;
83: }
84: }
|