Source Code Cross Referenced for ExternalContextImpl.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » faces » context » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.faces.context 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.faces.context;
018:
019:        import org.apache.cocoon.environment.Context;
020:        import org.apache.cocoon.environment.Request;
021:        import org.apache.cocoon.environment.Response;
022:        import org.apache.cocoon.faces.FacesAction;
023:        import org.apache.cocoon.faces.FacesRedirector;
024:
025:        import org.apache.commons.collections.iterators.EnumerationIterator;
026:
027:        import javax.faces.context.ExternalContext;
028:        import java.io.IOException;
029:        import java.io.InputStream;
030:        import java.net.MalformedURLException;
031:        import java.net.URL;
032:        import java.security.Principal;
033:        import java.util.Collections;
034:        import java.util.Iterator;
035:        import java.util.Locale;
036:        import java.util.Map;
037:        import java.util.Set;
038:
039:        /**
040:         * Implementation of the Java Server Faces ExternalContext
041:         *
042:         * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
043:         * @version CVS $Id: ExternalContextImpl.java 433543 2006-08-22 06:22:54Z crossley $
044:         */
045:        public class ExternalContextImpl extends ExternalContext {
046:
047:            private Context context;
048:            private Request request;
049:            private Response response;
050:
051:            public ExternalContextImpl(Context context, Request request,
052:                    Response response) {
053:                this .context = context;
054:                this .request = request;
055:                this .response = response;
056:            }
057:
058:            public void dispatch(String url) throws IOException {
059:                FacesRedirector redirector = (FacesRedirector) request
060:                        .getAttribute(FacesAction.REQUEST_REDIRECTOR_ATTRIBUTE);
061:                if (redirector == null) {
062:                    throw new IOException("Can not dispatch to <" + url
063:                            + ">: Redirector missing.");
064:                }
065:
066:                redirector.dispatch(url);
067:            }
068:
069:            public String encodeActionURL(String url) {
070:                FacesRedirector redirector = (FacesRedirector) request
071:                        .getAttribute(FacesAction.REQUEST_REDIRECTOR_ATTRIBUTE);
072:                if (redirector == null) {
073:                    throw new RuntimeException("Can not encode action URL <"
074:                            + url + ">: Redirector missing.");
075:                }
076:
077:                return redirector.encodeActionURL(url);
078:            }
079:
080:            public String encodeNamespace(String ns) {
081:                return ns;
082:            }
083:
084:            public String encodeResourceURL(String url) {
085:                FacesRedirector redirector = (FacesRedirector) request
086:                        .getAttribute(FacesAction.REQUEST_REDIRECTOR_ATTRIBUTE);
087:                if (redirector == null) {
088:                    throw new RuntimeException("Can not encode resource URL <"
089:                            + url + ">: Redirector missing.");
090:                }
091:
092:                return redirector.encodeResourceURL(url);
093:            }
094:
095:            public Map getApplicationMap() {
096:                return new ApplicationMap(this .context);
097:            }
098:
099:            public String getAuthType() {
100:                return this .request.getAuthType();
101:            }
102:
103:            public Object getContext() {
104:                return this .context;
105:            }
106:
107:            public String getInitParameter(String parameter) {
108:                return this .context.getInitParameter(parameter);
109:            }
110:
111:            public Map getInitParameterMap() {
112:                return new InitParameterMap(this .context);
113:            }
114:
115:            public String getRemoteUser() {
116:                return this .request.getRemoteUser();
117:            }
118:
119:            public Object getRequest() {
120:                return this .request;
121:            }
122:
123:            public String getRequestContextPath() {
124:                return this .request.getContextPath();
125:            }
126:
127:            public Map getRequestCookieMap() {
128:                // TODO: Implement getRequestCookieMap
129:                System.err.println("WARNING: getRequestCookieMap called.");
130:                return Collections.EMPTY_MAP;
131:            }
132:
133:            public Map getRequestHeaderMap() {
134:                return new RequestHeaderMap(this .request);
135:            }
136:
137:            public Map getRequestHeaderValuesMap() {
138:                return new RequestHeaderValuesMap(this .request);
139:            }
140:
141:            public Locale getRequestLocale() {
142:                return this .request.getLocale();
143:            }
144:
145:            public Iterator getRequestLocales() {
146:                return new EnumerationIterator(this .request.getLocales());
147:            }
148:
149:            public Map getRequestMap() {
150:                return new RequestMap(this .request);
151:            }
152:
153:            public Map getRequestParameterMap() {
154:                return new RequestParameterMap(this .request);
155:            }
156:
157:            public Iterator getRequestParameterNames() {
158:                return new EnumerationIterator(this .request.getParameterNames());
159:            }
160:
161:            public Map getRequestParameterValuesMap() {
162:                return new RequestParameterValuesMap(this .request);
163:            }
164:
165:            public String getRequestPathInfo() {
166:                // HACK (VG):
167:                // Emulate servlet prefix mapping. This allows to bypass suffix mapping calculations,
168:                // as well as helps with WebSphere servlet container bugs (it treats default servlet
169:                // as prefix mapped servlet).
170:
171:                // JSF Specification, 2.2.1 Restore View:
172:                //   o Derive the view identifier that corresponds to this request, as follows:
173:                //     o If prefix mapping (such as ?/faces/*?) is used for FacesServlet, the viewId
174:                //       is set from the extra path information of the request URI.
175:
176:                StringBuffer path = new StringBuffer();
177:
178:                boolean slash = false;
179:                String s = request.getServletPath();
180:                if (s != null) {
181:                    path.append(s);
182:                    slash = s.endsWith("/");
183:                }
184:
185:                s = request.getPathInfo();
186:                if (s != null) {
187:                    if (s.startsWith("/")) {
188:                        if (slash) {
189:                            s = s.substring(1);
190:                        }
191:                    } else {
192:                        if (!slash) {
193:                            path.append('/');
194:                        }
195:                    }
196:                    path.append(s);
197:                }
198:
199:                return path.toString();
200:            }
201:
202:            public String getRequestServletPath() {
203:                // See #getRequestPathInfo
204:                return "";
205:            }
206:
207:            public URL getResource(String resource)
208:                    throws MalformedURLException {
209:                return this .context.getResource(resource);
210:            }
211:
212:            public InputStream getResourceAsStream(String resource) {
213:                return this .context.getResourceAsStream(resource);
214:            }
215:
216:            public Set getResourcePaths(String path) {
217:                // TODO: Implement getResourcePaths
218:                System.err.println("WARNING: getResourcePaths(" + path
219:                        + ") called.");
220:                throw new UnsupportedOperationException();
221:            }
222:
223:            public Object getResponse() {
224:                return this .response;
225:            }
226:
227:            public Object getSession(boolean create) {
228:                return this .request.getSession(create);
229:            }
230:
231:            public Map getSessionMap() {
232:                return new SessionMap(request.getSession());
233:            }
234:
235:            public Principal getUserPrincipal() {
236:                return this .request.getUserPrincipal();
237:            }
238:
239:            public boolean isUserInRole(String role) {
240:                return this .request.isUserInRole(role);
241:            }
242:
243:            public void log(String message) {
244:                // TODO: Implement
245:                System.err.println("WARNING: log(" + message + ") called.");
246:            }
247:
248:            public void log(String message, Throwable e) {
249:                // TODO: Implement
250:                System.err.println("WARNING: log(" + message + ", " + e
251:                        + ") called.");
252:            }
253:
254:            public void redirect(String url) throws IOException {
255:                FacesRedirector redirector = (FacesRedirector) request
256:                        .getAttribute(FacesAction.REQUEST_REDIRECTOR_ATTRIBUTE);
257:                if (redirector == null) {
258:                    throw new IOException("Can not redirect to <" + url
259:                            + ">: Redirector missing.");
260:                }
261:
262:                redirector.redirect(url);
263:            }
264:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.