1/*2 * Copyright 2000-2004 The Apache Software Foundation.3 * 4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 * 8 * http://www.apache.org/licenses/LICENSE-2.09 * 10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16packageorg.apache.jetspeed.services.forward;
1718// Turbine19import org.apache.turbine.util.DynamicURI;
20import org.apache.turbine.services.pull.ApplicationTool;
2122// Jetspeed23import org.apache.jetspeed.util.ServiceUtil;
24import org.apache.jetspeed.services.rundata.JetspeedRunData;
2526/***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 */33publicclassForwardTool implements ApplicationTool
34 {
35/***36 *<p>Request to which we refer.</p>37 */38privateJetspeedRunData rundata = null;
3940ForwardService service = null;
4142/***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 page47 */48public DynamicURI forward(String forwardName)
49 {
50if (null == service)
51 {
52 service = (ForwardService)ServiceUtil.getServiceByName(ForwardService.SERVICE_NAME);
53 }
54return service.forward(this.rundata, forwardName);
55 }
5657/***58 * For the given portlet and given action, forward to the target59 * 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 page64 */65public DynamicURI forward(String portlet, String target)
66 {
67if (null == service)
68 {
69 service = (ForwardService)ServiceUtil.getServiceByName(ForwardService.SERVICE_NAME);
70 }
71return service.forward(this.rundata, portlet, target);
72 }
737475/***76 * Methods required by ApplictionTool interface77 *78 */7980/***81 * This will initialise a JetspeedLink object that was82 * constructed with the default constructor (ApplicationTool83 * method).84 *85 * @param data assumed to be a RunData object86 */8788publicvoid init(Object data)
89 {
90// Keeping init small and fast91if (data instanceof JetspeedRunData)
92 {
93this.rundata = (JetspeedRunData) data;
94 }
95else96 {
97this.rundata = null;
98 }
99return;
100 }
101/***102 * Refresh method - does nothing103 */104publicvoid refresh()
105 {
106// empty107 }
108 }