1 16 package org.apache.cocoon.components.treeprocessor.sitemap; 17 18 import java.util.ArrayList ; 19 import java.util.List ; 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 37 public class PipelinesNodeBuilder extends ContainerNodeBuilder implements ThreadSafe { 38 39 public ProcessingNode buildNode(Configuration config) 40 throws Exception { 41 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 children = new ArrayList (); 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 children.add(builder.buildNode(childConfig)); 65 } 66 } 67 } 68 69 if (children.size() == 0) { 70 String 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 |