Source Code Cross Referenced for ApplicationRequest.java in  » Sevlet-Container » tomcat-catalina » org » apache » catalina » core » 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 » Sevlet Container » tomcat catalina » org.apache.catalina.core 
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:
017:        package org.apache.catalina.core;
018:
019:        import java.util.Enumeration;
020:        import java.util.HashMap;
021:
022:        import javax.servlet.ServletRequest;
023:        import javax.servlet.ServletRequestWrapper;
024:
025:        import org.apache.catalina.Globals;
026:        import org.apache.catalina.util.Enumerator;
027:        import org.apache.catalina.util.StringManager;
028:
029:        /**
030:         * Wrapper around a <code>javax.servlet.ServletRequest</code>
031:         * that transforms an application request object (which might be the original
032:         * one passed to a servlet, or might be based on the 2.3
033:         * <code>javax.servlet.ServletRequestWrapper</code> class)
034:         * back into an internal <code>org.apache.catalina.Request</code>.
035:         * <p>
036:         * <strong>WARNING</strong>:  Due to Java's lack of support for multiple
037:         * inheritance, all of the logic in <code>ApplicationRequest</code> is
038:         * duplicated in <code>ApplicationHttpRequest</code>.  Make sure that you
039:         * keep these two classes in synchronization when making changes!
040:         *
041:         * @author Craig R. McClanahan
042:         * @version $Revision: 1.4 $ $Date: 2004/02/27 14:58:42 $
043:         */
044:
045:        class ApplicationRequest extends ServletRequestWrapper {
046:
047:            // ------------------------------------------------------- Static Variables
048:
049:            /**
050:             * The set of attribute names that are special for request dispatchers.
051:             */
052:            protected static final String specials[] = {
053:                    Globals.INCLUDE_REQUEST_URI_ATTR,
054:                    Globals.INCLUDE_CONTEXT_PATH_ATTR,
055:                    Globals.INCLUDE_SERVLET_PATH_ATTR,
056:                    Globals.INCLUDE_PATH_INFO_ATTR,
057:                    Globals.INCLUDE_QUERY_STRING_ATTR,
058:                    Globals.FORWARD_REQUEST_URI_ATTR,
059:                    Globals.FORWARD_CONTEXT_PATH_ATTR,
060:                    Globals.FORWARD_SERVLET_PATH_ATTR,
061:                    Globals.FORWARD_PATH_INFO_ATTR,
062:                    Globals.FORWARD_QUERY_STRING_ATTR };
063:
064:            // ----------------------------------------------------------- Constructors
065:
066:            /**
067:             * Construct a new wrapped request around the specified servlet request.
068:             *
069:             * @param request The servlet request being wrapped
070:             */
071:            public ApplicationRequest(ServletRequest request) {
072:
073:                super (request);
074:                setRequest(request);
075:
076:            }
077:
078:            // ----------------------------------------------------- Instance Variables
079:
080:            /**
081:             * The request attributes for this request.  This is initialized from the
082:             * wrapped request, but updates are allowed.
083:             */
084:            protected HashMap attributes = new HashMap();
085:
086:            /**
087:             * The string manager for this package.
088:             */
089:            protected static StringManager sm = StringManager
090:                    .getManager(Constants.Package);
091:
092:            // ------------------------------------------------- ServletRequest Methods
093:
094:            /**
095:             * Override the <code>getAttribute()</code> method of the wrapped request.
096:             *
097:             * @param name Name of the attribute to retrieve
098:             */
099:            public Object getAttribute(String name) {
100:
101:                synchronized (attributes) {
102:                    return (attributes.get(name));
103:                }
104:
105:            }
106:
107:            /**
108:             * Override the <code>getAttributeNames()</code> method of the wrapped
109:             * request.
110:             */
111:            public Enumeration getAttributeNames() {
112:
113:                synchronized (attributes) {
114:                    return (new Enumerator(attributes.keySet()));
115:                }
116:
117:            }
118:
119:            /**
120:             * Override the <code>removeAttribute()</code> method of the
121:             * wrapped request.
122:             *
123:             * @param name Name of the attribute to remove
124:             */
125:            public void removeAttribute(String name) {
126:
127:                synchronized (attributes) {
128:                    attributes.remove(name);
129:                    if (!isSpecial(name))
130:                        getRequest().removeAttribute(name);
131:                }
132:
133:            }
134:
135:            /**
136:             * Override the <code>setAttribute()</code> method of the
137:             * wrapped request.
138:             *
139:             * @param name Name of the attribute to set
140:             * @param value Value of the attribute to set
141:             */
142:            public void setAttribute(String name, Object value) {
143:
144:                synchronized (attributes) {
145:                    attributes.put(name, value);
146:                    if (!isSpecial(name))
147:                        getRequest().setAttribute(name, value);
148:                }
149:
150:            }
151:
152:            // ------------------------------------------ ServletRequestWrapper Methods
153:
154:            /**
155:             * Set the request that we are wrapping.
156:             *
157:             * @param request The new wrapped request
158:             */
159:            public void setRequest(ServletRequest request) {
160:
161:                super .setRequest(request);
162:
163:                // Initialize the attributes for this request
164:                synchronized (attributes) {
165:                    attributes.clear();
166:                    Enumeration names = request.getAttributeNames();
167:                    while (names.hasMoreElements()) {
168:                        String name = (String) names.nextElement();
169:                        Object value = request.getAttribute(name);
170:                        attributes.put(name, value);
171:                    }
172:                }
173:
174:            }
175:
176:            // ------------------------------------------------------ Protected Methods
177:
178:            /**
179:             * Is this attribute name one of the special ones that is added only for
180:             * included servlets?
181:             *
182:             * @param name Attribute name to be tested
183:             */
184:            protected boolean isSpecial(String name) {
185:
186:                for (int i = 0; i < specials.length; i++) {
187:                    if (specials[i].equals(name))
188:                        return (true);
189:                }
190:                return (false);
191:
192:            }
193:
194:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.