1 package org.apache.turbine.modules.actions;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import org.apache.fulcrum.parser.ParameterParser;
23 import org.apache.turbine.Turbine;
24 import org.apache.turbine.pipeline.PipelineData;
25 import org.apache.turbine.services.velocity.TurbineVelocity;
26 import org.apache.turbine.util.RunData;
27 import org.apache.velocity.context.Context;
28
29 /**
30 * This class provides a methods for Turbine2 Velocity Actions to use. Since
31 * this class is abstract, it should only be extended and not used directly.
32 *
33 * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
34 * @deprecated Use VelocityAction directly
35 */
36 @Deprecated
37 public abstract class LegacyVelocityAction extends VelocityAction
38 {
39 /**
40 * You SHOULD override this method and implement it in your action.
41 *
42 * @param data Turbine information.
43 * @param context Context for web pages.
44 * @throws Exception a generic exception.
45 */
46 public abstract void doPerform(RunData data, Context context)
47 throws Exception;
48
49 /**
50 * Adapter method for legacy signature
51 *
52 * @param pipelineData Turbine information.
53 * @param context Context for web pages.
54 * @throws Exception a generic exception.
55 */
56 @Override
57 public void doPerform(PipelineData pipelineData, Context context)
58 throws Exception
59 {
60 doPerform(getRunData(pipelineData), context);
61 }
62
63 /**
64 * This overrides the default Action.doPerform() to execute the
65 * doEvent() method. If that fails, then it will execute the
66 * doPerform() method instead.
67 *
68 * @param pipelineData A Turbine RunData object.
69 * @exception Exception a generic exception.
70 */
71 @Override
72 public void doPerform(PipelineData pipelineData)
73 throws Exception
74 {
75 if (!initialized)
76 {
77 initialize();
78 }
79
80 RunData data = getRunData(pipelineData);
81 ParameterParser pp = pipelineData.get(Turbine.class, ParameterParser.class);
82 Context context = TurbineVelocity.getContext(pipelineData);
83 executeEvents(pp, new Class<?>[]{ RunData.class, Context.class },
84 new Object[]{ data, context });
85 }
86 }