Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
LegacyVelocityAction |
|
| 1.3333333333333333;1,333 |
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.util.RunData; | |
26 | import org.apache.velocity.context.Context; | |
27 | ||
28 | /** | |
29 | * This class provides a methods for Turbine2 Velocity Actions to use. Since | |
30 | * this class is abstract, it should only be extended and not used directly. | |
31 | * | |
32 | * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a> | |
33 | * @deprecated Use VelocityAction directly | |
34 | */ | |
35 | @Deprecated | |
36 | 0 | public abstract class LegacyVelocityAction extends VelocityAction |
37 | { | |
38 | /** | |
39 | * You SHOULD override this method and implement it in your action. | |
40 | * | |
41 | * @param data Turbine information. | |
42 | * @param context Context for web pages. | |
43 | * @throws Exception a generic exception. | |
44 | */ | |
45 | public abstract void doPerform(RunData data, Context context) | |
46 | throws Exception; | |
47 | ||
48 | /** | |
49 | * Adapter method for legacy signature | |
50 | * | |
51 | * @param pipelineData Turbine information. | |
52 | * @param context Context for web pages. | |
53 | * @throws Exception a generic exception. | |
54 | */ | |
55 | @Override | |
56 | public void doPerform(PipelineData pipelineData, Context context) | |
57 | throws Exception | |
58 | { | |
59 | 0 | doPerform(pipelineData.getRunData(), context); |
60 | 0 | } |
61 | ||
62 | /** | |
63 | * This overrides the default Action.doPerform() to execute the | |
64 | * doEvent() method. If that fails, then it will execute the | |
65 | * doPerform() method instead. | |
66 | * | |
67 | * @param pipelineData A Turbine RunData object. | |
68 | * @throws Exception a generic exception. | |
69 | */ | |
70 | @Override | |
71 | public void doPerform(PipelineData pipelineData) | |
72 | throws Exception | |
73 | { | |
74 | 0 | if (!initialized) |
75 | { | |
76 | 0 | initialize(); |
77 | } | |
78 | ||
79 | 0 | RunData data = pipelineData.getRunData(); |
80 | 0 | ParameterParser pp = pipelineData.get(Turbine.class, ParameterParser.class); |
81 | 0 | Context context = velocity.getContext(pipelineData); |
82 | 0 | executeEvents(pp, new Class<?>[]{ RunData.class, Context.class }, |
83 | new Object[]{ data, context }); | |
84 | 0 | } |
85 | } |