KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > blogs > ServletResources


1 /*
2  * ____.
3  * __/\ ______| |__/\. _______
4  * __ .____| | \ | +----+ \
5  * _______| /--| | | - \ _ | : - \_________
6  * \\______: :---| : : | : | \________>
7  * |__\---\_____________:______: :____|____:_____\
8  * /_____|
9  *
10  * . . . i n j a h i a w e t r u s t . . .
11  *
12  *
13  *
14  * ----- BEGIN LICENSE BLOCK -----
15  * Version: JCSL 1.0
16  *
17  * The contents of this file are subject to the Jahia Community Source License
18  * 1.0 or later (the "License"); you may not use this file except in
19  * compliance with the License. You may obtain a copy of the License at
20  * http://www.jahia.org/license
21  *
22  * Software distributed under the License is distributed on an "AS IS" basis,
23  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
24  * for the rights, obligations and limitations governing use of the contents
25  * of the file. The Original and Upgraded Code is the Jahia CMS and Portal
26  * Server. The developer of the Original and Upgraded Code is JAHIA Ltd. JAHIA
27  * Ltd. owns the copyrights in the portions it created. All Rights Reserved.
28  *
29  * The Shared Modifications are Jahia View Helper.
30  *
31  * The Developer of the Shared Modifications is Jahia Solution Sàrl.
32  * Portions created by the Initial Developer are Copyright (C) 2002 by the
33  * Initial Developer. All Rights Reserved.
34  *
35  * ----- END LICENSE BLOCK -----
36  */

37
38 package org.jahia.blogs;
39
40 import javax.servlet.ServletConfig JavaDoc;
41 import javax.servlet.http.HttpServletRequest JavaDoc;
42 import javax.servlet.http.HttpServletResponse JavaDoc;
43
44 /**
45  * Holds ThreadLocal variables containing needed resources throughout a
46  * request processing.
47  *
48  * @author Xavier Lawrence
49  */

50 public class ServletResources {
51     
52     private static ThreadLocal JavaDoc currentConfig = new ThreadLocal JavaDoc();
53     private static ThreadLocal JavaDoc currentRequest = new ThreadLocal JavaDoc();
54     private static ThreadLocal JavaDoc currentResponse = new ThreadLocal JavaDoc();
55     
56     /**
57      * Returns the HttpServletRequest object for the current Thread
58      */

59     public static HttpServletRequest JavaDoc getCurrentRequest() {
60         return (HttpServletRequest JavaDoc)currentRequest.get();
61     }
62     
63     /**
64      * Sets the HttpServletRequest object for the current Thread
65      */

66     public static void setCurrentRequest(HttpServletRequest JavaDoc request) {
67         currentRequest.set(request);
68     }
69     
70     /**
71      * Returns the HttpServletResponse object for the current Thread
72      */

73     public static HttpServletResponse JavaDoc getCurrentResponse() {
74         return (HttpServletResponse JavaDoc)currentResponse.get();
75     }
76     
77     /**
78      * Sets the HttpServletResponse object for the current Thread
79      */

80     public static void setCurrentResponse(HttpServletResponse JavaDoc response) {
81         currentResponse.set(response);
82     }
83     
84     /**
85      * Returns the ServletConfig object for the current Thread
86      */

87     public static ServletConfig JavaDoc getCurrentConfig() {
88         return (ServletConfig JavaDoc)currentConfig.get();
89     }
90     
91     /**
92      * Sets the ServletConfig object for the current Thread
93      */

94     public static void setCurrentConfig(ServletConfig JavaDoc config) {
95         currentConfig.set(config);
96     }
97 }
98
Popular Tags