01: /*
02: * $Id: AbstractExecuteAction.java 471754 2006-11-06 14:55:09Z husted $
03: *
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "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: package org.apache.struts.chain.commands;
22:
23: import org.apache.struts.action.Action;
24: import org.apache.struts.action.ActionForm;
25: import org.apache.struts.chain.contexts.ActionContext;
26: import org.apache.struts.config.ActionConfig;
27: import org.apache.struts.config.ForwardConfig;
28:
29: /**
30: * <p>Invoke the appropriate <code>Action</code> for this request, and cache
31: * the returned <code>ActionForward</code>.</p>
32: *
33: * @version $Rev: 471754 $ $Date: 2005-06-04 10:58:46 -0400 (Sat, 04 Jun 2005)
34: * $
35: */
36: public abstract class AbstractExecuteAction extends ActionCommandBase {
37: // ---------------------------------------------------------- Public Methods
38:
39: /**
40: * <p>Invoke the appropriate <code>Action</code> for this request, and
41: * cache the returned <code>ActionForward</code>.</p>
42: *
43: * @param actionCtx The <code>Context</code> for the current request
44: * @return <code>false</code> so that processing continues
45: * @throws Exception if thrown by the Action class
46: */
47: public boolean execute(ActionContext actionCtx) throws Exception {
48: // Skip processing if the current request is not valid
49: Boolean valid = actionCtx.getFormValid();
50:
51: if ((valid == null) || !valid.booleanValue()) {
52: return (false);
53: }
54:
55: // Acquire the resources we will need to send to the Action
56: Action action = actionCtx.getAction();
57:
58: if (action == null) {
59: return (false);
60: }
61:
62: ActionConfig actionConfig = actionCtx.getActionConfig();
63: ActionForm actionForm = actionCtx.getActionForm();
64:
65: // Execute the Action for this request, caching returned ActionForward
66: ForwardConfig forwardConfig = execute(actionCtx, action,
67: actionConfig, actionForm);
68:
69: actionCtx.setForwardConfig(forwardConfig);
70:
71: return (false);
72: }
73:
74: // ------------------------------------------------------- Protected Methods
75:
76: /**
77: * <p>Execute the specified <code>Action</code>, and return the resulting
78: * <code>ForwardConfig</code>.</p>
79: *
80: * @param context The <code>Context</code> for this request
81: * @param action The <code>Action</code> to be executed
82: * @param actionConfig The <code>ActionConfig</code> defining this action
83: * @param actionForm The <code>ActionForm</code> (if any) for this
84: * action
85: * @return ForwardConfig The next location, or null
86: * @throws Exception if thrown by the <code>Action</code>
87: */
88: protected abstract ForwardConfig execute(ActionContext context,
89: Action action, ActionConfig actionConfig,
90: ActionForm actionForm) throws Exception;
91: }
|