Source Code Cross Referenced for ServletWebContext.java in  » Library » Apache-commons-chain-1.1-src » org » apache » commons » chain » web » servlet » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Library » Apache commons chain 1.1 src » org.apache.commons.chain.web.servlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1999-2004 The Apache Software Foundation
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.apache.commons.chain.web.servlet;
017:
018:        import java.util.Map;
019:        import javax.servlet.ServletContext;
020:        import javax.servlet.http.HttpServletRequest;
021:        import javax.servlet.http.HttpServletResponse;
022:        import org.apache.commons.chain.web.WebContext;
023:
024:        /**
025:         * <p>Concrete implementation of {@link WebContext} suitable for use in
026:         * Servlets and JSP pages.  The abstract methods are mapped to the appropriate
027:         * collections of the underlying servlet context, request, and response
028:         * instances that are passed to the constructor (or the initialize method).</p>
029:         *
030:         * @author Craig R. McClanahan
031:         * @version $Revision: 412789 $ $Date: 2006-06-08 17:19:14 +0100 (Thu, 08 Jun 2006) $
032:         */
033:
034:        public class ServletWebContext extends WebContext {
035:
036:            // ------------------------------------------------------------ Constructors
037:
038:            /**
039:             * <p>Construct an uninitialized {@link ServletWebContext} instance.</p>
040:             */
041:            public ServletWebContext() {
042:            }
043:
044:            /**
045:             * <p>Construct a {@link ServletWebContext} instance that is initialized
046:             * with the specified Servlet API objects.</p>
047:             *
048:             * @param context The <code>ServletContext</code> for this web application
049:             * @param request The <code>HttpServletRequest</code> for this request
050:             * @param response The <code>HttpServletResponse</code> for this request
051:             */
052:            public ServletWebContext(ServletContext context,
053:                    HttpServletRequest request, HttpServletResponse response) {
054:
055:                initialize(context, request, response);
056:
057:            }
058:
059:            // ------------------------------------------------------ Instance Variables
060:
061:            /**
062:             * <p>The lazily instantiated <code>Map</code> of application scope
063:             * attributes.</p>
064:             */
065:            private Map applicationScope = null;
066:
067:            /**
068:             * <p>The <code>ServletContext</code> for this web application.</p>
069:             */
070:            protected ServletContext context = null;
071:
072:            /**
073:             * <p>The lazily instantiated <code>Map</code> of header name-value
074:             * combinations (immutable).</p>
075:             */
076:            private Map header = null;
077:
078:            /**
079:             * <p>The lazily instantitated <code>Map</code> of header name-values
080:             * combinations (immutable).</p>
081:             */
082:            private Map headerValues = null;
083:
084:            /**
085:             * <p>The lazily instantiated <code>Map</code> of context initialization
086:             * parameters.</p>
087:             */
088:            private Map initParam = null;
089:
090:            /**
091:             * <p>The lazily instantiated <code>Map</code> of cookies.</p>
092:             */
093:            private Map cookieValues = null;
094:
095:            /**
096:             * <p>The lazily instantiated <code>Map</code> of request
097:             * parameter name-value.</p>
098:             */
099:            private Map param = null;
100:
101:            /**
102:             * <p>The lazily instantiated <code>Map</code> of request
103:             * parameter name-values.</p>
104:             */
105:            private Map paramValues = null;
106:
107:            /**
108:             * <p>The <code>HttpServletRequest</code> for this request.</p>
109:             */
110:            protected HttpServletRequest request = null;
111:
112:            /**
113:             * <p>The lazily instantiated <code>Map</code> of request scope
114:             * attributes.</p>
115:             */
116:            private Map requestScope = null;
117:
118:            /**
119:             * <p>The <code>HttpServletResponse</code> for this request.</p>
120:             */
121:            protected HttpServletResponse response = null;
122:
123:            /**
124:             * <p>The lazily instantiated <code>Map</code> of session scope
125:             * attributes.</p>
126:             */
127:            private Map sessionScope = null;
128:
129:            // ---------------------------------------------------------- Public Methods
130:
131:            /**
132:             * <p>Return the {@link ServletContext} for this context.</p>
133:             *
134:             * @return The <code>ServletContext</code> for this context.
135:             */
136:            public ServletContext getContext() {
137:
138:                return (this .context);
139:
140:            }
141:
142:            /**
143:             * <p>Return the {@link HttpServletRequest} for this context.</p>
144:             *
145:             * @return The <code>HttpServletRequest</code> for this context.
146:             */
147:            public HttpServletRequest getRequest() {
148:
149:                return (this .request);
150:
151:            }
152:
153:            /**
154:             * <p>Return the {@link HttpServletResponse} for this context.</p>
155:             *
156:             * @return The <code>HttpServletResponse</code> for this context.
157:             */
158:            public HttpServletResponse getResponse() {
159:
160:                return (this .response);
161:
162:            }
163:
164:            /**
165:             * <p>Initialize (or reinitialize) this {@link ServletWebContext} instance
166:             * for the specified Servlet API objects.</p>
167:             *
168:             * @param context The <code>ServletContext</code> for this web application
169:             * @param request The <code>HttpServletRequest</code> for this request
170:             * @param response The <code>HttpServletResponse</code> for this request
171:             */
172:            public void initialize(ServletContext context,
173:                    HttpServletRequest request, HttpServletResponse response) {
174:
175:                // Save the specified Servlet API object references
176:                this .context = context;
177:                this .request = request;
178:                this .response = response;
179:
180:                // Perform other setup as needed
181:
182:            }
183:
184:            /**
185:             * <p>Release references to allocated resources acquired in
186:             * <code>initialize()</code> of via subsequent processing.  After this
187:             * method is called, subsequent calls to any other method than
188:             * <code>initialize()</code> will return undefined results.</p>
189:             */
190:            public void release() {
191:
192:                // Release references to allocated collections
193:                applicationScope = null;
194:                header = null;
195:                headerValues = null;
196:                initParam = null;
197:                param = null;
198:                paramValues = null;
199:                cookieValues = null;
200:                requestScope = null;
201:                sessionScope = null;
202:
203:                // Release references to Servlet API objects
204:                context = null;
205:                request = null;
206:                response = null;
207:
208:            }
209:
210:            // ------------------------------------------------------ WebContext Methods
211:
212:            /**
213:             * See the {@link WebContext}'s Javadoc.
214:             *
215:             * @return Application scope Map.
216:             */
217:            public Map getApplicationScope() {
218:
219:                if ((applicationScope == null) && (context != null)) {
220:                    applicationScope = new ServletApplicationScopeMap(context);
221:                }
222:                return (applicationScope);
223:
224:            }
225:
226:            /**
227:             * See the {@link WebContext}'s Javadoc.
228:             *
229:             * @return Header values Map.
230:             */
231:            public Map getHeader() {
232:
233:                if ((header == null) && (request != null)) {
234:                    header = new ServletHeaderMap(request);
235:                }
236:                return (header);
237:
238:            }
239:
240:            /**
241:             * See the {@link WebContext}'s Javadoc.
242:             *
243:             * @return Header values Map.
244:             */
245:            public Map getHeaderValues() {
246:
247:                if ((headerValues == null) && (request != null)) {
248:                    headerValues = new ServletHeaderValuesMap(request);
249:                }
250:                return (headerValues);
251:
252:            }
253:
254:            /**
255:             * See the {@link WebContext}'s Javadoc.
256:             *
257:             * @return Initialization parameter Map.
258:             */
259:            public Map getInitParam() {
260:
261:                if ((initParam == null) && (context != null)) {
262:                    initParam = new ServletInitParamMap(context);
263:                }
264:                return (initParam);
265:
266:            }
267:
268:            /**
269:             * See the {@link WebContext}'s Javadoc.
270:             *
271:             * @return Request parameter Map.
272:             */
273:            public Map getParam() {
274:
275:                if ((param == null) && (request != null)) {
276:                    param = new ServletParamMap(request);
277:                }
278:                return (param);
279:
280:            }
281:
282:            /**
283:             * See the {@link WebContext}'s Javadoc.
284:             *
285:             * @return Request parameter Map.
286:             */
287:            public Map getParamValues() {
288:
289:                if ((paramValues == null) && (request != null)) {
290:                    paramValues = new ServletParamValuesMap(request);
291:                }
292:                return (paramValues);
293:
294:            }
295:
296:            /**
297:             * See the {@link WebContext}'s Javadoc.
298:             *
299:             * @return Map of Cookies.
300:             * @since Chain 1.1
301:             */
302:            public Map getCookies() {
303:
304:                if ((cookieValues == null) && (request != null)) {
305:                    cookieValues = new ServletCookieMap(request);
306:                }
307:                return (cookieValues);
308:
309:            }
310:
311:            /**
312:             * See the {@link WebContext}'s Javadoc.
313:             *
314:             * @return Request scope Map.
315:             */
316:            public Map getRequestScope() {
317:
318:                if ((requestScope == null) && (request != null)) {
319:                    requestScope = new ServletRequestScopeMap(request);
320:                }
321:                return (requestScope);
322:
323:            }
324:
325:            /**
326:             * See the {@link WebContext}'s Javadoc.
327:             *
328:             * @return Session scope Map.
329:             */
330:            public Map getSessionScope() {
331:
332:                if ((sessionScope == null) && (request != null)) {
333:                    sessionScope = new ServletSessionScopeMap(request);
334:                }
335:                return (sessionScope);
336:
337:            }
338:
339:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.