KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > config > ConfigHelperInterface


1 /*
2  * $Id: ConfigHelperInterface.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19
20 package org.apache.struts.config;
21
22
23 import javax.sql.DataSource JavaDoc;
24
25 import org.apache.struts.action.ActionForm;
26 import org.apache.struts.action.ActionFormBean;
27 import org.apache.struts.action.ActionForward;
28 import org.apache.struts.action.ActionMapping;
29 import org.apache.struts.action.ActionMessages;
30 import org.apache.struts.upload.MultipartRequestWrapper;
31 import org.apache.struts.util.MessageResources;
32
33
34 /**
35  * NOTE: THIS CLASS IS UNDER ACTIVE DEVELOPMENT.
36  * THE CURRENT CODE IS WRITTEN FOR CLARITY NOT EFFICIENCY.
37  * NOT EVERY API FUNCTION HAS BEEN IMPLEMENTED YET.
38  *
39  * A helper object to expose the Struts shared resources,
40  * which are be stored in the application, session, or
41  * request contexts, as appropriate.
42  *
43  * An instance should be created for each request
44  * processed. The methods which return resources from
45  * the request or session contexts are not thread-safe.
46  *
47  * Provided for use by other servlets in the application
48  * so they can easily access the Struts shared resources.
49  *
50  * The resources are stored under attributes in the
51  * application, session, or request contexts.
52  *
53  * The ActionConfig methods simply return the resources
54  * from under the context and key used by the Struts
55  * ActionServlet when the resources are created.
56  *
57  * @since Struts 1.1
58  * @version $Rev: 54929 $ $Date: 2004-10-16 17:38:42 +0100 (Sat, 16 Oct 2004) $
59  */

60 public interface ConfigHelperInterface {
61
62
63 // ------------------------------------------------ Application Context
64

65     public DataSource JavaDoc getDataSource();
66
67     /**
68      * The <code>org.apache.struts.action.ActionFormBeans</code> collection
69      * for this application.
70      */

71     public ActionMessages getActionMessages();
72
73     /**
74      * The application resources for this application.
75      */

76     public MessageResources getMessageResources();
77
78     /**
79      * The path-mapped pattern (<code>/action/*</code>) or
80      * extension mapped pattern ((<code>*.do</code>)
81      * used to determine our Action URIs in this application.
82      */

83     public String JavaDoc getServletMapping();
84
85
86 // ---------------------------------------------------- Session Context
87

88     /**
89      * The transaction token stored in this session, if it is used.
90      */

91     public String JavaDoc getToken();
92
93
94 // ---------------------------------------------------- Request Context
95

96
97     /**
98      * The runtime JspException that may be been thrown by a Struts tag
99      * extension, or compatible presentation extension, and placed
100      * in the request.
101      */

102     public Throwable JavaDoc getException();
103
104
105     /**
106      * The multipart object for this request.
107      */

108     public MultipartRequestWrapper getMultipartRequestWrapper();
109
110
111    /**
112      * The <code>org.apache.struts.ActionMapping</code>
113      * instance for this request.
114      */

115     public ActionMapping getMapping();
116
117
118
119 // ---------------------------------------------------- Utility Methods
120

121     /**
122      * Return true if a message string for the specified message key
123      * is present for the user's Locale.
124      *
125      * @param key Message key
126      */

127     public boolean isMessage(String JavaDoc key);
128
129
130
131     /*
132      * Retrieve and return the <code>ActionForm</code> bean associated with
133      * this mapping, creating and stashing one if necessary. If there is no
134      * form bean associated with this mapping, return <code>null</code>.
135      *
136      */

137      public ActionForm getActionForm();
138
139
140
141     /**
142      * Return the form bean definition associated with the specified
143      * logical name, if any; otherwise return <code>null</code>.
144      *
145      * @param name Logical name of the requested form bean definition
146      */

147     public ActionFormBean getFormBean(String JavaDoc name);
148
149
150
151     /**
152      * Return the forwarding associated with the specified logical name,
153      * if any; otherwise return <code>null</code>.
154      *
155      * @param name Logical name of the requested forwarding
156      */

157     public ActionForward getActionForward(String JavaDoc name);
158
159
160
161     /**
162      * Return the mapping associated with the specified request path, if any;
163      * otherwise return <code>null</code>.
164      *
165      * @param path Request path for which a mapping is requested
166      */

167     public ActionMapping getActionMapping(String JavaDoc path);
168
169
170
171     /**
172      * Return the form action converted into an action mapping path. The
173      * value of the <code>action</code> property is manipulated as follows in
174      * computing the name of the requested mapping:
175      * <ul>
176      * <li>Any filename extension is removed (on the theory that extension
177      * mapping is being used to select the controller servlet).</li>
178      * <li>If the resulting value does not start with a slash, then a
179      * slash is prepended.</li>
180      * </ul>
181      * :FIXME: Bad assumption =:o)
182      */

183     public String JavaDoc getActionMappingName(String JavaDoc action);
184
185
186
187     /**
188      * Return the form action converted into a server-relative URL.
189      */

190     public String JavaDoc getActionMappingURL(String JavaDoc action);
191
192
193
194     /**
195      * Return the url encoded to maintain the user session, if any.
196      */

197     public String JavaDoc getEncodeURL(String JavaDoc url);
198
199
200
201 // ------------------------------------------------ Presentation API
202

203
204     /**
205      * Renders the reference for a HTML <base> element
206      */

207     public String JavaDoc getOrigRef();
208
209
210
211     /**
212      * Renders the reference for a HTML <base> element
213      */

214     public String JavaDoc getBaseRef();
215
216
217
218     /**
219      * Return the path for the specified forward,
220      * otherwise return <code>null</code>.
221      *
222      * @param name Name given to local or global forward.
223      */

224      public String JavaDoc getLink(String JavaDoc name);
225
226
227     /**
228      * Return the localized message for the specified key,
229      * otherwise return <code>null</code>.
230      *
231      * @param key Message key
232      */

233     public String JavaDoc getMessage(String JavaDoc key);
234
235
236     /**
237      * Look up and return a message string, based on the specified parameters.
238      *
239      * @param key Message key to be looked up and returned
240      * @param args Replacement parameters for this message
241      */

242     public String JavaDoc getMessage(String JavaDoc key, Object JavaDoc args[]);
243
244
245     /**
246      * Return the URL for the specified ActionMapping,
247      * otherwise return <code>null</code>.
248      *
249      * @param path Name given to local or global forward.
250      */

251     public String JavaDoc getAction(String JavaDoc path);
252
253
254 }
255
Popular Tags