    001package org.apache.turbine.modules.actions;
    002
    003/*
    004 * Licensed to the Apache Software Foundation (ASF) under one
    005 * or more contributor license agreements.  See the NOTICE file
    006 * distributed with this work for additional information
    007 * regarding copyright ownership.  The ASF licenses this file
    008 * to you under the Apache License, Version 2.0 (the
    009 * "License"); you may not use this file except in compliance
    010 * with the License.  You may obtain a copy of the License at
    011 *
    012 *   http://www.apache.org/licenses/LICENSE-2.0
    013 *
    014 * Unless required by applicable law or agreed to in writing,
    015 * software distributed under the License is distributed on an
    016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    017 * KIND, either express or implied.  See the License for the
    018 * specific language governing permissions and limitations
    019 * under the License.
    020 */
    021
    022import org.apache.fulcrum.parser.ParameterParser;
    023import org.apache.turbine.Turbine;
    024import org.apache.turbine.pipeline.PipelineData;
    025import org.apache.turbine.util.RunData;
    026import org.apache.velocity.context.Context;
    027
    028/**
    029 * This class provides a methods for Turbine2 Velocity Actions to use. Since
    030 * this class is abstract, it should only be extended and not used directly.
    031 *
    032 * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
    033 * @deprecated Use VelocityAction directly
    034 */
    035@Deprecated
    036public abstract class LegacyVelocityAction extends VelocityAction
    037{
    038    /**
    039     * You SHOULD override this method and implement it in your action.
    040     *
    041     * @param data Turbine information.
    042     * @param context Context for web pages.
    043     * @throws Exception a generic exception.
    044     */
    045    public abstract void doPerform(RunData data, Context context)
    046            throws Exception;
    047
    048    /**
    049     * Adapter method for legacy signature
    050     *
    051     * @param pipelineData Turbine information.
    052     * @param context Context for web pages.
    053     * @throws Exception a generic exception.
    054     */
    055    @Override
    056    public void doPerform(PipelineData pipelineData, Context context)
    057            throws Exception
    058    {
    059        doPerform(getRunData(pipelineData), context);
    060    }
    061
    062    /**
    063     * This overrides the default Action.doPerform() to execute the
    064     * doEvent() method.  If that fails, then it will execute the
    065     * doPerform() method instead.
    066     *
    067     * @param pipelineData A Turbine RunData object.
    068     * @throws Exception a generic exception.
    069     */
    070    @Override
    071    public void doPerform(PipelineData pipelineData)
    072            throws Exception
    073    {
    074        if (!initialized)
    075        {
    076            initialize();
    077        }
    078
    079        RunData data = getRunData(pipelineData);
    080        ParameterParser pp = pipelineData.get(Turbine.class, ParameterParser.class);
    081        Context context = velocity.getContext(pipelineData);
    082        executeEvents(pp, new Class<?>[]{ RunData.class, Context.class },
    083                new Object[]{ data, context });
    084    }
    085}