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
23 import static org.junit.Assert.assertNotNull;
24
25 import org.apache.fulcrum.factory.FactoryService;
26 import org.apache.turbine.annotation.TurbineService;
27 import org.apache.turbine.pipeline.PipelineData;
28 import org.apache.turbine.services.rundata.RunDataService;
29 import org.apache.velocity.context.Context;
30 /**
31 * This action is used in testing the injection of services.
32 *
33 * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
34 */
35 public class VelocityActionWithServiceInjection extends VelocityAction
36 {
37 // Test for explicit service name
38 @TurbineService( RunDataService.SERVICE_NAME )
39 private RunDataService runDataService;
40
41 // Test for implicit SERVICE_NAME
42 @TurbineService
43 private RunDataService runDataService2;
44
45 // Test for implicit ROLE
46 @TurbineService
47 private FactoryService factory;
48
49 /**
50 * Default action is nothing.
51 *
52 * @param pipelineData Current RunData information
53 * @param context Context to populate
54 * @throws Exception Thrown on error
55 */
56 @Override
57 public void doPerform(PipelineData pipelineData, Context context) throws Exception
58 {
59 log.debug("Calling doPerform(PipelineData)");
60 assertNotNull("runDataService object was Null.", runDataService);
61 log.debug("Injected service is " + runDataService.getName());
62 assertNotNull("runDataService2 object was Null.", runDataService2);
63 log.debug("Injected service is " + runDataService2.getName());
64 assertNotNull("factory object was Null.", factory);
65 log.debug("Injected service is " + factory.getClass());
66 }
67 }