KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > jsf > context > ServletExternalContext


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * Resin Open Source is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2
11  * as published by the Free Software Foundation.
12  *
13  * Resin Open Source is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
16  * of NON-INFRINGEMENT. See the GNU General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with Resin Open Source; if not, write to the
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place, Suite 330
24  * Boston, MA 02111-1307 USA
25  *
26  * @author Scott Ferguson
27  */

28
29 package com.caucho.jsf.context;
30
31 import java.io.*;
32 import java.net.URL JavaDoc;
33 import java.net.MalformedURLException JavaDoc;
34 import java.util.*;
35 import java.security.*;
36
37 import javax.faces.*;
38 import javax.faces.context.*;
39
40 import javax.servlet.*;
41 import javax.servlet.http.*;
42
43 import com.caucho.server.connection.*;
44
45 public class ServletExternalContext extends ExternalContext {
46   private ServletContext _webApp;
47   private HttpServletRequest _request;
48   private HttpServletResponse _response;
49
50   ServletExternalContext(ServletContext webApp,
51              HttpServletRequest request,
52              HttpServletResponse response)
53   {
54     _webApp = webApp;
55     _request = request;
56     _response = response;
57   }
58   
59   public void dispatch(String JavaDoc path)
60     throws IOException
61   {
62     try {
63       _request.getRequestDispatcher(path).include(_request, _response);
64     } catch (ServletException e) {
65       throw new FacesException(e);
66     }
67   }
68
69   public String JavaDoc encodeActionURL(String JavaDoc url)
70   {
71     throw new UnsupportedOperationException JavaDoc();
72   }
73
74   public String JavaDoc encodeNamespace(String JavaDoc name)
75   {
76     throw new UnsupportedOperationException JavaDoc();
77   }
78
79   public String JavaDoc encodeResourceURL(String JavaDoc url)
80   {
81     throw new UnsupportedOperationException JavaDoc();
82   }
83
84   public Map<String JavaDoc,Object JavaDoc> getApplicationMap()
85   {
86     throw new UnsupportedOperationException JavaDoc();
87   }
88
89   public String JavaDoc getAuthType()
90   {
91     throw new UnsupportedOperationException JavaDoc();
92   }
93
94   public Object JavaDoc getContext()
95   {
96     return _webApp;
97   }
98
99   public String JavaDoc getInitParameter(String JavaDoc name)
100   {
101     throw new UnsupportedOperationException JavaDoc();
102   }
103
104   public Map getInitParameterMap()
105   {
106     throw new UnsupportedOperationException JavaDoc();
107   }
108
109   public String JavaDoc getRemoteUser()
110   {
111     throw new UnsupportedOperationException JavaDoc();
112   }
113
114   public Object JavaDoc getRequest()
115   {
116     return _request;
117   }
118
119   /**
120    * @Since 1.2
121    */

122   public void setRequest(Object JavaDoc request)
123   {
124     _request = (HttpServletRequest) request;
125   }
126
127   /**
128    * @Since 1.2
129    */

130   public void setRequestCharacterEncoding(String JavaDoc encoding)
131     throws UnsupportedEncodingException
132   {
133     _request.setCharacterEncoding(encoding);
134   }
135
136   public String JavaDoc getRequestContextPath()
137   {
138     return _request.getContextPath();
139   }
140
141   public Map<String JavaDoc,Object JavaDoc> getRequestCookieMap()
142   {
143     throw new UnsupportedOperationException JavaDoc();
144   }
145
146   public Map<String JavaDoc,String JavaDoc> getRequestHeaderMap()
147   {
148     throw new UnsupportedOperationException JavaDoc();
149   }
150
151   public Map<String JavaDoc,String JavaDoc[]> getRequestHeaderValuesMap()
152   {
153     throw new UnsupportedOperationException JavaDoc();
154   }
155
156   public Locale getRequestLocale()
157   {
158     throw new UnsupportedOperationException JavaDoc();
159   }
160
161   public Iterator<Locale> getRequestLocales()
162   {
163     throw new UnsupportedOperationException JavaDoc();
164   }
165
166   public Map<String JavaDoc,Object JavaDoc> getRequestMap()
167   {
168     throw new UnsupportedOperationException JavaDoc();
169   }
170
171   public Map<String JavaDoc,String JavaDoc> getRequestParameterMap()
172   {
173     throw new UnsupportedOperationException JavaDoc();
174   }
175
176   public Iterator<String JavaDoc> getRequestParameterNames()
177   {
178     throw new UnsupportedOperationException JavaDoc();
179   }
180
181   public Map<String JavaDoc,String JavaDoc[]> getRequestParameterValuesMap()
182   {
183     throw new UnsupportedOperationException JavaDoc();
184   }
185
186   public String JavaDoc getRequestPathInfo()
187   {
188     if (_request instanceof CauchoRequest) {
189       return ((CauchoRequest) _request).getPagePathInfo();
190     }
191     else {
192       // XXX: include
193

194       return _request.getPathInfo();
195     }
196   }
197
198   public String JavaDoc getRequestServletPath()
199   {
200     if (_request instanceof CauchoRequest) {
201       return ((CauchoRequest) _request).getPageServletPath();
202     }
203     else {
204       // XXX: include
205

206       return _request.getServletPath();
207     }
208   }
209
210   /**
211    * @Since 1.2
212    */

213   public String JavaDoc getRequestCharacterEncoding()
214   {
215     throw new UnsupportedOperationException JavaDoc(getClass().getName());
216   }
217
218   /**
219    * @Since 1.2
220    */

221   public String JavaDoc getRequestContentType()
222   {
223     throw new UnsupportedOperationException JavaDoc(getClass().getName());
224   }
225
226   /**
227    * @Since 1.2
228    */

229   public String JavaDoc getResponseCharacterEncoding()
230   {
231     throw new UnsupportedOperationException JavaDoc(getClass().getName());
232   }
233
234   /**
235    * @Since 1.2
236    */

237   public String JavaDoc getResponseContentType()
238   {
239     return _response.getContentType();
240   }
241
242   public URL JavaDoc getResource(String JavaDoc path)
243     throws MalformedURLException JavaDoc
244   {
245     return _webApp.getResource(path);
246   }
247
248   public InputStream getResourceAsStream(String JavaDoc path)
249   {
250     return _webApp.getResourceAsStream(path);
251   }
252
253   public Set<String JavaDoc> getResourcePath(String JavaDoc path)
254   {
255     throw new UnsupportedOperationException JavaDoc();
256   }
257
258   public Object JavaDoc getResponse()
259   {
260     return _response;
261   }
262
263   /**
264    * @Since 1.2
265    */

266   public void setResponse(Object JavaDoc response)
267   {
268     throw new UnsupportedOperationException JavaDoc(getClass().getName());
269   }
270
271   /**
272    * @Since 1.2
273    */

274   public void setResponseCharacterEncoding(String JavaDoc encoding)
275   {
276     throw new UnsupportedOperationException JavaDoc(getClass().getName());
277   }
278
279   public Object JavaDoc getSession(boolean create)
280   {
281     throw new UnsupportedOperationException JavaDoc();
282   }
283
284   public Map<String JavaDoc,Object JavaDoc> getSessionMap()
285   {
286     throw new UnsupportedOperationException JavaDoc();
287   }
288
289   public Principal getUserPrincipal()
290   {
291     throw new UnsupportedOperationException JavaDoc();
292   }
293
294   public boolean isUserInRole(String JavaDoc role)
295   {
296     throw new UnsupportedOperationException JavaDoc();
297   }
298
299   public void log(String JavaDoc message)
300     {
301     throw new UnsupportedOperationException JavaDoc();
302   }
303
304   public void log(String JavaDoc message, Throwable JavaDoc exn)
305   {
306     throw new UnsupportedOperationException JavaDoc();
307   }
308
309   public void redirect(String JavaDoc url)
310     throws IOException
311   {
312     throw new UnsupportedOperationException JavaDoc();
313   }
314 }
315
316
Popular Tags