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