1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.jetspeed.services.forward;
17
18
19 import org.apache.turbine.util.DynamicURI;
20 import org.apache.turbine.services.pull.ApplicationTool;
21
22
23 import org.apache.jetspeed.util.ServiceUtil;
24 import org.apache.jetspeed.services.rundata.JetspeedRunData;
25
26 /***
27 * <p>Provides a tool interface to forwards</p>
28 *
29 *
30 * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
31 * @version $Id: ForwardTool.java,v 1.5 2004/02/23 03:51:09 jford Exp $
32 */
33 public class ForwardTool implements ApplicationTool
34 {
35 /***
36 *<p>Request to which we refer.</p>
37 */
38 private JetspeedRunData rundata = null;
39
40 ForwardService service = null;
41
42 /***
43 * Forward to a specific forward by name.
44 *
45 * @param name Forward to this abstract forward name.
46 * @return DynamicURI the full link to the referenced page
47 */
48 public DynamicURI forward(String forwardName)
49 {
50 if (null == service)
51 {
52 service = (ForwardService)ServiceUtil.getServiceByName(ForwardService.SERVICE_NAME);
53 }
54 return service.forward(this.rundata, forwardName);
55 }
56
57 /***
58 * For the given portlet and given action, forward to the target
59 * defined in the forward configuration for the portlet + action.
60 *
61 * @param portlet The name of the portlet for which we are forwarding.
62 * @param target A logical target name. Portlets can have 1 or more targets.
63 * @return DynamicURI the full link to the referenced page
64 */
65 public DynamicURI forward(String portlet, String target)
66 {
67 if (null == service)
68 {
69 service = (ForwardService)ServiceUtil.getServiceByName(ForwardService.SERVICE_NAME);
70 }
71 return service.forward(this.rundata, portlet, target);
72 }
73
74
75 /***
76 * Methods required by ApplictionTool interface
77 *
78 */
79
80 /***
81 * This will initialise a JetspeedLink object that was
82 * constructed with the default constructor (ApplicationTool
83 * method).
84 *
85 * @param data assumed to be a RunData object
86 */
87
88 public void init(Object data)
89 {
90
91 if (data instanceof JetspeedRunData)
92 {
93 this.rundata = (JetspeedRunData) data;
94 }
95 else
96 {
97 this.rundata = null;
98 }
99 return;
100 }
101 /***
102 * Refresh method - does nothing
103 */
104 public void refresh()
105 {
106
107 }
108 }