1 16 package org.apache.cocoon.components.treeprocessor.sitemap; 17 18 import java.util.Map ; 19 20 import org.apache.avalon.framework.parameters.Parameters; 21 import org.apache.cocoon.components.treeprocessor.InvokeContext; 22 import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode; 23 import org.apache.cocoon.components.treeprocessor.PipelineEventComponentProcessingNode; 24 import org.apache.cocoon.components.treeprocessor.ProcessingNode; 25 import org.apache.cocoon.components.treeprocessor.variables.VariableResolver; 26 import org.apache.cocoon.environment.Environment; 27 import org.apache.cocoon.sitemap.PatternException; 28 29 34 public class GenerateNode extends PipelineEventComponentProcessingNode implements ParameterizableProcessingNode { 35 36 private String generatorName; 37 38 private VariableResolver source; 39 40 private Map parameters; 41 42 43 public GenerateNode(String name, VariableResolver source) throws PatternException { 44 this.generatorName = name; 45 this.source = source; 46 } 47 48 public void setParameters(Map parameterMap) { 49 this.parameters = parameterMap; 50 } 51 52 public final boolean invoke(Environment env, InvokeContext context) 53 throws Exception { 54 55 Map objectModel = env.getObjectModel(); 56 57 context.getProcessingPipeline().setGenerator( 58 this.generatorName, 59 source.resolve(context, objectModel), 60 VariableResolver.buildParameters(this.parameters, context, objectModel), 61 this.pipelineHints == null 62 ? Parameters.EMPTY_PARAMETERS 63 : VariableResolver.buildParameters(this.pipelineHints, context, objectModel) 64 ); 65 66 67 if (this.views != null) { 69 70 context.getProcessingPipeline().informBranchPoint(); 72 73 String cocoonView = env.getView(); 74 if (cocoonView != null) { 75 76 ProcessingNode viewNode = (ProcessingNode)this.views.get(cocoonView); 78 79 if (viewNode != null) { 80 if (getLogger().isInfoEnabled()) { 81 getLogger().info("Jumping to view " + cocoonView + " from generator at " + this.getLocation()); 82 } 83 return viewNode.invoke(env, context); 84 } 85 } 86 } 87 88 return false; 90 } 91 } 92 | Popular Tags |