Save This Page
Home » cocoon-2.1.11-src » org.apache » cocoon » components » treeprocessor » sitemap » [javadoc | source]
    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    * 
    9    *      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.Map;
   20   
   21   import org.apache.avalon.framework.parameters.Parameters;
   22   import org.apache.cocoon.components.treeprocessor.InvokeContext;
   23   import org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode;
   24   import org.apache.cocoon.components.treeprocessor.PipelineEventComponentProcessingNode;
   25   import org.apache.cocoon.components.treeprocessor.ProcessingNode;
   26   import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
   27   import org.apache.cocoon.environment.Environment;
   28   import org.apache.cocoon.sitemap.PatternException;
   29   
   30   /**
   31    *
   32    * @author <a href="mailto:sylvain@apache.org">Sylvain Wallez</a>
   33    * @version CVS $Id: GenerateNode.java 433543 2006-08-22 06:22:54Z crossley $
   34    */
   35   public class GenerateNode extends PipelineEventComponentProcessingNode implements ParameterizableProcessingNode {
   36   
   37       private String generatorName;
   38   
   39       private VariableResolver source;
   40   
   41       private Map parameters;
   42   
   43   
   44       public GenerateNode(String name, VariableResolver source) throws PatternException {
   45           this.generatorName = name;
   46           this.source = source;
   47       }
   48   
   49       public void setParameters(Map parameterMap) {
   50           this.parameters = parameterMap;
   51       }
   52   
   53       public final boolean invoke(Environment env, InvokeContext context)
   54       throws Exception {
   55   
   56           Map objectModel = env.getObjectModel();
   57   
   58           context.getProcessingPipeline().setGenerator(
   59               this.generatorName,
   60               source.resolve(context, objectModel),
   61               VariableResolver.buildParameters(this.parameters, context, objectModel),
   62               this.pipelineHints == null
   63                   ? Parameters.EMPTY_PARAMETERS
   64                   : VariableResolver.buildParameters(this.pipelineHints, context, objectModel)
   65           );
   66   
   67   
   68           // Check view
   69           if (this.views != null) {
   70   	 
   71               //inform the pipeline that we have a branch point
   72               context.getProcessingPipeline().informBranchPoint();
   73   
   74               String cocoonView = env.getView();
   75               if (cocoonView != null) {
   76   
   77                   // Get view node
   78                   ProcessingNode viewNode = (ProcessingNode)this.views.get(cocoonView);
   79   
   80                   if (viewNode != null) {
   81                       if (getLogger().isInfoEnabled()) {
   82                           getLogger().info("Jumping to view " + cocoonView + " from generator at " + this.getLocation());
   83                       }
   84                       return viewNode.invoke(env, context);
   85                   }
   86               }
   87           }
   88   
   89           // Return false to continue sitemap invocation
   90           return false;
   91       }
   92   }

Save This Page
Home » cocoon-2.1.11-src » org.apache » cocoon » components » treeprocessor » sitemap » [javadoc | source]