Coverage Report - org.apache.turbine.modules.pages.VelocityPage
 
Classes in this File Line Coverage Branch Coverage Complexity
VelocityPage
100%
8/8
N/A
1
 
 1  
 package org.apache.turbine.modules.pages;
 2  
 
 3  
 
 4  
 /*
 5  
  * Licensed to the Apache Software Foundation (ASF) under one
 6  
  * or more contributor license agreements.  See the NOTICE file
 7  
  * distributed with this work for additional information
 8  
  * regarding copyright ownership.  The ASF licenses this file
 9  
  * to you under the Apache License, Version 2.0 (the
 10  
  * "License"); you may not use this file except in compliance
 11  
  * with the License.  You may obtain a copy of the License at
 12  
  *
 13  
  *   http://www.apache.org/licenses/LICENSE-2.0
 14  
  *
 15  
  * Unless required by applicable law or agreed to in writing,
 16  
  * software distributed under the License is distributed on an
 17  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 18  
  * KIND, either express or implied.  See the License for the
 19  
  * specific language governing permissions and limitations
 20  
  * under the License.
 21  
  */
 22  
 
 23  
 
 24  
 import org.apache.turbine.annotation.TurbineService;
 25  
 import org.apache.turbine.pipeline.PipelineData;
 26  
 import org.apache.turbine.services.velocity.VelocityService;
 27  
 import org.apache.turbine.util.RunData;
 28  
 import org.apache.velocity.context.Context;
 29  
 
 30  
 /**
 31  
  * Extends TemplatePage to set the template Context.
 32  
  *
 33  
  * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a>
 34  
  * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
 35  
  * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
 36  
  * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a>
 37  
  * @version $Id: VelocityPage.java 1773378 2016-12-09 13:19:59Z tv $
 38  
  */
 39  3
 public class VelocityPage
 40  
     extends TemplatePage
 41  
 {
 42  
     /** Injected service instance */
 43  
     @TurbineService
 44  
     private VelocityService velocity;
 45  
 
 46  
     /**
 47  
      * Stuffs the Context into the PipelineData so that it is available to
 48  
      * the Action module and the Screen module via getContext().
 49  
      *
 50  
      * @param pipelineData Turbine information.
 51  
      * @throws Exception a generic exception.
 52  
      */
 53  
     @Override
 54  
     protected void doBuildBeforeAction(PipelineData pipelineData)
 55  
         throws Exception
 56  
     {
 57  3
         RunData data = getRunData(pipelineData);
 58  3
         Context context = velocity.getContext(pipelineData);
 59  3
         data.getTemplateInfo()
 60  
             .setTemplateContext(VelocityService.CONTEXT, context);
 61  3
     }
 62  
 
 63  
     /**
 64  
      * Allows the VelocityService to perform post-request actions.
 65  
      * (releases the (non-global) tools in the context for reuse later)
 66  
      */
 67  
     @Override
 68  
     protected void doPostBuild(PipelineData pipelineData)
 69  
         throws Exception
 70  
     {
 71  2
         Context context = velocity.getContext(pipelineData);
 72  2
         velocity.requestFinished(context);
 73  2
     }
 74  
 }