001 package org.apache.turbine.modules.pages; 002 003 004 /* 005 * Licensed to the Apache Software Foundation (ASF) under one 006 * or more contributor license agreements. See the NOTICE file 007 * distributed with this work for additional information 008 * regarding copyright ownership. The ASF licenses this file 009 * to you under the Apache License, Version 2.0 (the 010 * "License"); you may not use this file except in compliance 011 * with the License. You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, 016 * software distributed under the License is distributed on an 017 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 018 * KIND, either express or implied. See the License for the 019 * specific language governing permissions and limitations 020 * under the License. 021 */ 022 023 024 import org.apache.turbine.pipeline.PipelineData; 025 import org.apache.turbine.services.velocity.TurbineVelocity; 026 import org.apache.turbine.services.velocity.VelocityService; 027 import org.apache.turbine.util.RunData; 028 import org.apache.velocity.context.Context; 029 030 /** 031 * Extends TemplatePage to set the template Context. 032 * 033 * @author <a href="mailto:mbryson@mont.mindspring.com">Dave Bryson</a> 034 * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a> 035 * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a> 036 * @author <a href="mailto:peter@courcoux.biz">Peter Courcoux</a> 037 * @version $Id: VelocityPage.java 1078552 2011-03-06 19:58:46Z tv $ 038 */ 039 public class VelocityPage 040 extends TemplatePage 041 { 042 /** 043 * Stuffs the Context into the RunData so that it is available to 044 * the Action module and the Screen module via getContext(). 045 * @deprecated Use PipelineData version instead. 046 * @param data Turbine information. 047 * @exception Exception, a generic exception. 048 */ 049 @Deprecated 050 @Override 051 protected void doBuildBeforeAction(RunData data) 052 throws Exception 053 { 054 Context context = TurbineVelocity.getContext(data); 055 data.getTemplateInfo() 056 .setTemplateContext(VelocityService.CONTEXT, context); 057 } 058 059 /** 060 * Allows the VelocityService to peform post-request actions. 061 * (releases the (non-global) tools in the context for reuse later) 062 * @deprecated. Use PipelineData version instead. 063 * 064 */ 065 @Override 066 protected void doPostBuild(RunData data) 067 throws Exception 068 { 069 Context context = TurbineVelocity.getContext(data); 070 TurbineVelocity.requestFinished(context); 071 } 072 073 074 /** 075 * Stuffs the Context into the RunData so that it is available to 076 * the Action module and the Screen module via getContext(). 077 * 078 * @param data Turbine information. 079 * @exception Exception, a generic exception. 080 */ 081 @Override 082 protected void doBuildBeforeAction(PipelineData pipelineData) 083 throws Exception 084 { 085 RunData data = getRunData(pipelineData); 086 Context context = TurbineVelocity.getContext(pipelineData); 087 data.getTemplateInfo() 088 .setTemplateContext(VelocityService.CONTEXT, context); 089 } 090 091 /** 092 * Allows the VelocityService to peform post-request actions. 093 * (releases the (non-global) tools in the context for reuse later) 094 */ 095 @Override 096 protected void doPostBuild(PipelineData pipelineData) 097 throws Exception 098 { 099 Context context = TurbineVelocity.getContext(pipelineData); 100 TurbineVelocity.requestFinished(context); 101 } 102 103 }