2
* Copyright 2003,2004 The Apache Software Foundation.
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 at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* 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 and
14
* limitations under the License.
17
package org.apache.struts.chain;
20
import org.apache.commons.chain.Command;
21
import org.apache.commons.chain.Context;
22
import org.apache.commons.chain.web.WebContext;
23
import org.apache.struts.config.ModuleConfig;
27
* <p>Perform forwarding or redirection based on the specified
28
* <code>String</code> (if any).</p>
31
* @version $Revision: 1.4 $ $Date: 2004/04/29 03:08:44 $
34
public abstract class AbstractPerformInclude implements Command {
37
// ------------------------------------------------------ Instance Variables
40
private String includeKey = Constants.INCLUDE_KEY;
41
private String moduleConfigKey = Constants.MODULE_CONFIG_KEY;
44
// -------------------------------------------------------------- Properties
48
* <p>Return the context attribute key under which the
49
* include uri for the currently selected application
50
* action is stored.</p>
52
public String getIncludeKey() {
54
return (this.includeKey);
60
* <p>Set the context attribute key under which the
61
* include uri for the currently selected application
62
* action is stored.</p>
64
* @param includeKey The new context attribute key
66
public void setIncludeKey(String includeKey) {
68
this.includeKey = includeKey;
73
* <p>Return the context attribute key under which the
74
* <code>ModuleConfig</code> for the currently selected application
75
* module is stored.</p>
77
public String getModuleConfigKey() {
79
return (this.moduleConfigKey);
85
* <p>Set the context attribute key under which the
86
* <code>ModuleConfig</code> for the currently selected application
87
* module is stored.</p>
89
* @param moduleConfigKey The new context attribute key
91
public void setModuleConfigKey(String moduleConfigKey) {
93
this.moduleConfigKey = moduleConfigKey;
98
// ---------------------------------------------------------- Public Methods
102
* <p>Perform an include based on the specified
103
* include uri (if any).</p>
105
* @param context The <code>Context</code> for the current request
107
* @return <code>true</code> so that processing completes
109
public boolean execute(Context context) throws Exception {
111
// Retrieve module config instance
112
WebContext wcontext = (WebContext) context;
113
ModuleConfig moduleConfig = (ModuleConfig)
114
wcontext.get(getModuleConfigKey());
116
// Is there an include to be performed?
117
String include = (String)
118
context.get(getIncludeKey());
119
if (include == null) {
123
// Determine the currect uri
124
String uri = moduleConfig.getPrefix() + include;
126
// Perform the appropriate processing on this include uri
127
perform(context, uri);
133
// ------------------------------------------------------- Protected Methods
137
* <p>Perform the appropriate processing on the specified
140
* @param context The context for this request
141
* @param include The forward to be performed
143
protected abstract void perform(Context context,