KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > turbine > RunData


1 package org.apache.turbine;
2
3 /* ====================================================================
4  * The Apache Software License, Version 1.1
5  *
6  * Copyright (c) 2001 The Apache Software Foundation. All rights
7  * reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution,
22  * if any, must include the following acknowledgment:
23  * "This product includes software developed by the
24  * Apache Software Foundation (http://www.apache.org/)."
25  * Alternately, this acknowledgment may appear in the software itself,
26  * if and wherever such third-party acknowledgments normally appear.
27  *
28  * 4. The names "Apache" and "Apache Software Foundation" and
29  * "Apache Turbine" must not be used to endorse or promote products
30  * derived from this software without prior written permission. For
31  * written permission, please contact apache@apache.org.
32  *
33  * 5. Products derived from this software may not be called "Apache",
34  * "Apache Turbine", nor may "Apache" appear in their name, without
35  * prior written permission of the Apache Software Foundation.
36  *
37  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
41  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
44  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
45  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
46  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
47  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48  * SUCH DAMAGE.
49  * ====================================================================
50  *
51  * This software consists of voluntary contributions made by many
52  * individuals on behalf of the Apache Software Foundation. For more
53  * information on the Apache Software Foundation, please see
54  * <http://www.apache.org/>.
55  */

56
57 import java.io.IOException JavaDoc;
58 import java.io.PrintWriter JavaDoc;
59 import java.util.Hashtable JavaDoc;
60 import java.util.Locale JavaDoc;
61
62 import javax.servlet.ServletConfig JavaDoc;
63 import javax.servlet.ServletContext JavaDoc;
64 import javax.servlet.http.HttpServletRequest JavaDoc;
65 import javax.servlet.http.HttpServletResponse JavaDoc;
66 import javax.servlet.http.HttpSession JavaDoc;
67
68 import org.apache.fulcrum.parser.CookieParser;
69 import org.apache.fulcrum.parser.ParameterParser;
70 import org.apache.fulcrum.security.entity.User;
71 import org.apache.fulcrum.security.util.AccessControlList;
72
73 /**
74  * RunData is an interface to run-rime information that is passed
75  * within Turbine. This provides the threading mechanism for the
76  * entire system because multiple requests can potentially come in
77  * at the same time. Thus, there is only one RunData implementation
78  * for each request that is being serviced.
79  *
80  * @author <a HREF="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
81  * @author <a HREF="mailto:jon@clearink.com">Jon S. Stevens</a>
82  * @author <a HREF="mailto:bhoeneis@ee.ethz.ch">Bernie Hoeneisen</a>
83  * @author <a HREF="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
84  * @version $Id: RunData.java,v 1.7 2004/11/12 10:26:30 epugh Exp $
85  */

86 public interface RunData
87 {
88     /**
89      * Gets the parameters.
90      *
91      * @return a parameter parser.
92      */

93     public ParameterParser getParameters();
94
95     /**
96      * Gets the cookies.
97      *
98      * @return a cookie parser.
99      */

100     public CookieParser getCookies();
101
102     /**
103      * Gets the servlet request.
104      *
105      * @return the request.
106      */

107     public HttpServletRequest JavaDoc getRequest();
108
109     /**
110      * Gets the servlet response.
111      *
112      * @return the resposne.
113      */

114     public HttpServletResponse JavaDoc getResponse();
115
116     /**
117      * Gets the servlet session information.
118      *
119      * @return the session.
120      */

121     public HttpSession JavaDoc getSession();
122
123     /**
124      * Gets the servlet configuration used during servlet init.
125      *
126      * @return the configuration.
127      */

128     public ServletConfig JavaDoc getServletConfig();
129
130     /**
131      * Gets the servlet context used during servlet init.
132      *
133      * @return the context.
134      */

135     public ServletContext JavaDoc getServletContext();
136
137     /**
138      * Gets the access control list.
139      *
140      * @return the access control list.
141      */

142     public AccessControlList getACL();
143
144     /**
145      * Sets the access control list.
146      *
147      * @param acl an access control list.
148      */

149     public void setACL(AccessControlList acl);
150
151     /**
152      * Whether or not an action has been defined.
153      *
154      * @return true if an action has been defined.
155      */

156     public boolean hasAction();
157
158     /**
159      * Gets the action. It returns an empty string if null so
160      * that it is easy to do conditionals on it based on the
161      * equalsIgnoreCase() method.
162      *
163      * @return a string, "" if null.
164      */

165     public String JavaDoc getAction();
166
167     /**
168      * Sets the action for the request.
169      *
170      * @param action a atring.
171      */

172     public void setAction(String JavaDoc action);
173
174     public String JavaDoc getTarget();
175     public void setTarget(String JavaDoc template);
176     public boolean hasTarget();
177
178     public void setTemp(String JavaDoc key, Object JavaDoc value);
179     public Object JavaDoc getTemp(String JavaDoc key);
180
181     /**
182      * Gets the character encoding to use for reading template files.
183      *
184      * @return the template encoding or null if not specified.
185      */

186     public String JavaDoc getTemplateEncoding();
187
188     /**
189      * Sets the character encoding to use for reading template files.
190      *
191      * @param encoding the template encoding.
192      */

193     public void setTemplateEncoding(String JavaDoc encoding);
194
195     /**
196      * Gets the title of the page.
197      *
198      * @return a string.
199      */

200     public String JavaDoc getTitle();
201
202     /**
203      * Sets the title of the page.
204      *
205      * @param title a string.
206      */

207     public void setTitle(String JavaDoc title);
208
209     /**
210      * Checks if a user exists in this session.
211      *
212      * @return true if a user exists in this session.
213      */

214     public boolean userExists();
215
216     /**
217      * Gets the user.
218      *
219      * @return a user.
220      */

221     public User getUser();
222
223     /**
224      * Sets the user.
225      *
226      * @param user a user.
227      */

228     public void setUser(User user);
229
230     /**
231      * Attempts to get the user from the session. If it does
232      * not exist, it returns null.
233      *
234      * @return a user.
235      */

236     public User getUserFromSession();
237
238     /**
239      * Allows one to invalidate the user in the default session.
240      *
241      * @return true if user was invalidated.
242      */

243     public boolean removeUserFromSession();
244
245     /**
246      * Attempts to get the ACL from the session. If it does
247      * not exist, it returns null.
248      *
249      * @return a acl.
250      */

251     public AccessControlList getACLFromSession();
252
253     /**
254      * Allows one to invalidate the acl in the default session.
255      *
256      * @return true if acl was invalidated.
257      */

258     public boolean removeACLFromSession();
259
260     /**
261      * Gets the print writer. First time calling this
262      * will set the print writer via the response.
263      *
264      * @return a print writer.
265      * @throws IOException
266      */

267     public PrintWriter JavaDoc getOut()
268         throws IOException JavaDoc;
269
270     /**
271      * Gets the locale. If it has not already been defined with
272      * setLocale(), then properties named "locale.default.lang"
273      * and "locale.default.country" are checked from the Resource
274      * Service and the corresponding locale is returned. If these
275      * properties are undefined, JVM's default locale is returned.
276      *
277      * @return the locale.
278      */

279     public Locale JavaDoc getLocale();
280
281     /**
282      * Sets the locale.
283      *
284      * @param locale the new locale.
285      */

286     public void setLocale(Locale JavaDoc locale);
287
288     /**
289      * Gets the charset. If it has not already been defined with
290      * setCharSet(), then a property named "locale.default.charset"
291      * is checked from the Resource Service and returned. If this
292      * property is undefined, the default charset of the locale
293      * is returned. If the locale is undefined, null is returned.
294      *
295      * @return the name of the charset or null.
296      */

297     public String JavaDoc getCharSet();
298
299     /**
300      * Sets the charset.
301      *
302      * @param charset the name of the new charset.
303      */

304     public void setCharSet(String JavaDoc charset);
305
306     /**
307      * Gets the HTTP content type to return. If a charset
308      * has been specified, it is included in the content type.
309      * If the charset has not been specified and the main type
310      * of the content type is "text", the default charset is
311      * included. If the default charset is undefined, but the
312      * default locale is defined and it is not the US locale,
313      * a locale specific charset is included.
314      *
315      * @return the content type or an empty string.
316      */

317     public String JavaDoc getContentType();
318
319     /**
320      * Sets the HTTP content type to return.
321      *
322      * @param ct the new content type.
323      */

324     public void setContentType(String JavaDoc ct);
325
326     /**
327      * Gets the redirect URI. If this is set, also make sure to set
328      * the status code to 302.
329      *
330      * @return a string, "" if null.
331      */

332     public String JavaDoc getRedirectURI();
333
334     /**
335      * Sets the redirect uri. If this is set, also make sure to set
336      * the status code to 302.
337      *
338      * @param ruri a string.
339      */

340     public void setRedirectURI(String JavaDoc ruri);
341
342     /**
343      * Gets the HTTP status code to return.
344      *
345      * @return the status.
346      */

347     public int getStatusCode();
348
349     /**
350      * Sets the HTTP status code to return.
351      *
352      * @param sc the status.
353      */

354     public void setStatusCode(int sc);
355
356     /**
357      * Gets the cached server scheme.
358      *
359      * @return a string.
360      */

361     public String JavaDoc getServerScheme();
362
363     /**
364      * Gets the cached server name.
365      *
366      * @return a string.
367      */

368     public String JavaDoc getServerName();
369
370     /**
371      * Gets the cached server port.
372      *
373      * @return an int.
374      */

375     public int getServerPort();
376
377     /**
378      * Gets the cached context path.
379      *
380      * @return a string.
381      */

382     public String JavaDoc getContextPath();
383
384     /**
385      * Gets the cached script name.
386      *
387      * @return a string.
388      */

389     public String JavaDoc getScriptName();
390
391     /**
392      * Gets the IP address of the client that sent the request.
393      *
394      * @return a string.
395      */

396     public String JavaDoc getRemoteAddr();
397
398     /**
399      * Gets the qualified name of the client that sent the request.
400      *
401      * @return a string.
402      */

403     public String JavaDoc getRemoteHost();
404
405     /**
406      * Get the user agent for the request.
407      *
408      * @return a string.
409      */

410     public String JavaDoc getUserAgent();
411
412     /**
413      * Pulls a user object and acl from the session and increments the access
414      * counter and sets the last access date for the object.
415      */

416     public void populate();
417
418     /**
419      * Saves a user object and acl into the session.
420      */

421     public void save();
422
423     /**
424      * Gets the stack trace if set.
425      *
426      * @return the stack trace.
427      */

428     public String JavaDoc getStackTrace();
429
430     /**
431      * Gets the stack trace exception if set.
432      *
433      * @return the stack exception.
434      */

435     public Throwable JavaDoc getStackTraceException();
436
437     /**
438      * Sets the stack trace.
439      *
440      * @param trace the stack trace.
441      * @param exp the exception.
442      */

443     public void setStackTrace(String JavaDoc trace,
444                               Throwable JavaDoc exp);
445
446     /**
447      * Gets a table of debug variables.
448      *
449      * @return a hashtable for debug variables.
450      */

451     public Hashtable JavaDoc getVarDebug();
452
453     // this seems to have been missing from the interface?
454
public void setParameterParser(ParameterParser p);
455
456     public void setMessage(String JavaDoc message);
457     public String JavaDoc getMessage();
458
459     public void setServerName(String JavaDoc serverName);
460     public void setServerScheme(String JavaDoc serverScheme);
461     public void setServerPort(int serverPort);
462     public void setScriptName(String JavaDoc scriptName);
463     public void setContextPath(String JavaDoc contextPath);
464     public void setRequest(HttpServletRequest JavaDoc req);
465     public void setResponse(HttpServletResponse JavaDoc res);
466 }
467
Popular Tags