1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package org.talika.tarsis.command.action;
24
25 import org.talika.tarsis.command.Request;
26 import org.talika.tarsis.command.Response;
27 import org.talika.tarsis.context.Context;
28
29 /**
30 * Base implementation of <code>Action</code> interface.<br>
31 * <br>
32 * Defines all method except <code>validate</code> and <code>execute</code> method.
33 *
34 * @author Jose M. Palomar
35 * @version $Revision: 121 $
36 */
37 public abstract class AbstractAction implements Action {
38
39
40 /**
41 * Tarsis context.
42 */
43 private Context context;
44
45 /**
46 * Constructs a new <code>AbstractAction</code> object.
47 */
48 public AbstractAction() {
49 }
50
51 /**
52 * Called by Tarsis MVC Framework to initialize action.<br>
53 * <br>
54 * This method should be used to initialize any static resource needed by action.<br>
55 * <br>
56 * This implementation simply saves context for later use.
57 *
58 * @param context Context contex of Tarsis MVC Framework.
59 * @throws ActionException if an exception has occurred that interferes with the
60 * action's normal operation.
61 * @see org.talika.tarsis.command.action.Action#init(Context)
62 */
63 public void init(Context context) throws ActionException {
64 this.context = context;
65 }
66
67 /**
68 * Called by Tarsis MVC Framework to destroy action.<br>
69 * <br>
70 * This implementation do nothing.
71 *
72 * @see org.talika.tarsis.command.action.Action#destroy()
73 */
74 public void destroy() {
75 }
76
77 /**
78 * Called by Tarsis MVC Framework to validate request everytime command is
79 * invoked.<br>
80 * <br>
81 * This method is called only if command is validable.
82 *
83 * @param request Request object representing client's request.
84 * @throws ActionException if an exception has occurred that interferes with the
85 * action's normal operation.
86 */
87 public abstract void validate(Request request) throws ActionException;
88
89 /**
90 * Called by Tarsis MVC Framework to handle request everytime command is
91 * invoked.<br>
92 *
93 * @param request Request object representing client's request.
94 * @param response Response object representing client's reponse.
95 * @return String the name of view to be forwarded or <code>null</code> for
96 * default view.
97 * @throws ActionException if an exception has occurred that interferes with the
98 * action's normal operation.
99 * @see org.talika.tarsis.command.action.Action#execute(Request, Response)
100 */
101 public abstract String execute(Request request, Response response) throws ActionException;
102
103 /**
104 * Returns the Tarsis context.
105 *
106 * @return Context the Tarsis context.
107 */
108 protected final Context getContext() {
109 return context;
110 }
111
112 }