1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package javax.faces.context;
20
21 import java.io.IOException;
22 import java.io.OutputStream;
23 import java.io.Writer;
24 import java.util.Iterator;
25 import java.util.List;
26 import java.util.Locale;
27 import java.util.Map;
28 import java.util.Set;
29
30
31
32
33
34
35
36 public abstract class ExternalContext
37 {
38 public static final String BASIC_AUTH = "BASIC";
39 public static final String CLIENT_CERT_AUTH = "CLIENT_CERT";
40 public static final String DIGEST_AUTH = "DIGEST";
41 public static final String FORM_AUTH = "FORM";
42
43
44
45
46
47
48
49
50
51 public void addResponseCookie(String name, String value, Map<String, Object> properties)
52 {
53 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
54
55 if (ctx == null)
56 {
57 throw new UnsupportedOperationException();
58 }
59
60 ctx.addResponseCookie(name, value, properties);
61 }
62
63
64
65
66
67
68
69
70 public void addResponseHeader(String name, String value)
71 {
72 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
73
74 if (ctx == null)
75 {
76 throw new UnsupportedOperationException();
77 }
78
79 ctx.addResponseHeader(name, value);
80 }
81
82 public abstract void dispatch(String path) throws IOException;
83
84 public abstract String encodeActionURL(String url);
85
86
87
88
89
90
91
92
93 public String encodeBookmarkableURL(String baseUrl, Map<String,List<String>> parameters)
94 {
95 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
96
97 if (ctx == null)
98 {
99 throw new UnsupportedOperationException();
100 }
101
102 return ctx.encodeBookmarkableURL(baseUrl, parameters);
103 }
104
105 public abstract String encodeNamespace(String name);
106
107
108
109
110
111 public String encodePartialActionURL(String url)
112 {
113
114 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
115
116 if (ctx == null)
117 {
118 throw new UnsupportedOperationException();
119 }
120
121 return ctx.encodePartialActionURL(url);
122 }
123
124
125
126
127
128
129
130
131 public String encodeRedirectURL(String baseUrl, Map<String,List<String>> parameters)
132 {
133 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
134
135 if (ctx == null)
136 {
137 throw new UnsupportedOperationException();
138 }
139
140 return ctx.encodeRedirectURL(baseUrl, parameters);
141 }
142
143 public abstract String encodeResourceURL(String url);
144
145 public abstract Map<String, Object> getApplicationMap();
146
147 public abstract String getAuthType();
148
149 public abstract Object getContext();
150
151
152
153
154
155
156
157
158 public String getContextName()
159 {
160 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
161
162 if (ctx == null)
163 {
164 throw new UnsupportedOperationException();
165 }
166
167 return ctx.getContextName();
168 }
169
170
171
172
173 public Flash getFlash()
174 {
175 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
176
177 if (ctx == null)
178 {
179 throw new UnsupportedOperationException();
180 }
181
182 return ctx.getFlash();
183 }
184
185 public abstract String getInitParameter(String name);
186
187
188 public abstract Map getInitParameterMap();
189
190
191
192
193 public String getMimeType(String file)
194 {
195 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
196
197 if (ctx == null)
198 {
199 throw new UnsupportedOperationException();
200 }
201
202 return ctx.getMimeType(file);
203 }
204
205
206
207
208 public String getRealPath(String path)
209 {
210 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
211
212 if (ctx == null)
213 {
214 throw new UnsupportedOperationException();
215 }
216
217 return ctx.getRealPath(path);
218 }
219
220 public abstract String getRemoteUser();
221
222 public abstract Object getRequest();
223
224 public String getRequestCharacterEncoding()
225 {
226 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
227
228 if (ctx == null)
229 {
230 throw new UnsupportedOperationException();
231 }
232
233 return ctx.getRequestCharacterEncoding();
234 }
235
236
237
238
239
240
241
242 public int getRequestContentLength()
243 {
244 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
245
246 if (ctx == null)
247 {
248 throw new UnsupportedOperationException();
249 }
250
251 return ctx.getRequestContentLength();
252 }
253
254 public String getRequestContentType()
255 {
256 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
257
258 if (ctx == null)
259 {
260 throw new UnsupportedOperationException();
261 }
262
263 return ctx.getRequestContentType();
264 }
265
266 public abstract String getRequestContextPath();
267
268 public abstract Map<String, Object> getRequestCookieMap();
269
270 public abstract Map<String, String> getRequestHeaderMap();
271
272 public abstract Map<String, String[]> getRequestHeaderValuesMap();
273
274 public abstract Locale getRequestLocale();
275
276 public abstract Iterator<Locale> getRequestLocales();
277
278 public abstract Map<String, Object> getRequestMap();
279
280 public abstract Map<String, String> getRequestParameterMap();
281
282 public abstract Iterator<String> getRequestParameterNames();
283
284 public abstract Map<String, String[]> getRequestParameterValuesMap();
285
286 public abstract String getRequestPathInfo();
287
288
289
290
291 public String getRequestScheme()
292 {
293 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
294
295 if (ctx == null)
296 {
297 throw new UnsupportedOperationException();
298 }
299
300 return ctx.getRequestScheme();
301 }
302
303
304
305
306 public String getRequestServerName()
307 {
308 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
309
310 if (ctx == null)
311 {
312 throw new UnsupportedOperationException();
313 }
314
315 return ctx.getRequestServerName();
316 }
317
318
319
320
321 public int getRequestServerPort()
322 {
323 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
324
325 if (ctx == null)
326 {
327 throw new UnsupportedOperationException();
328 }
329
330 return ctx.getRequestServerPort();
331 }
332
333 public abstract String getRequestServletPath();
334
335 public abstract java.net.URL getResource(String path) throws java.net.MalformedURLException;
336
337 public abstract java.io.InputStream getResourceAsStream(String path);
338
339 public abstract Set<String> getResourcePaths(String path);
340
341 public abstract Object getResponse();
342
343
344
345
346
347
348
349 public int getResponseBufferSize()
350 {
351 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
352
353 if (ctx == null)
354 {
355 throw new UnsupportedOperationException();
356 }
357
358 return ctx.getResponseBufferSize();
359 }
360
361 public String getResponseCharacterEncoding()
362 {
363 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
364
365 if (ctx == null)
366 {
367 throw new UnsupportedOperationException("JSF 1.2 : figure out how to tell if this is a Portlet request");
368 }
369
370 return ctx.getResponseCharacterEncoding();
371 }
372
373
374
375
376
377
378 public String getResponseContentType()
379 {
380 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
381
382 if (ctx == null)
383 {
384 throw new UnsupportedOperationException();
385 }
386
387 return ctx.getResponseContentType();
388 }
389
390
391
392
393 public OutputStream getResponseOutputStream() throws IOException
394 {
395 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
396
397 if (ctx == null)
398 {
399 throw new UnsupportedOperationException();
400 }
401
402 return ctx.getResponseOutputStream();
403 }
404
405
406
407
408 public Writer getResponseOutputWriter() throws IOException
409 {
410 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
411
412 if (ctx == null)
413 {
414 throw new UnsupportedOperationException();
415 }
416
417 return ctx.getResponseOutputWriter();
418 }
419
420 public abstract Object getSession(boolean create);
421
422 public abstract Map<String, Object> getSessionMap();
423
424 public abstract java.security.Principal getUserPrincipal();
425
426
427
428
429 public void invalidateSession()
430 {
431 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
432
433 if (ctx == null)
434 {
435 throw new UnsupportedOperationException();
436 }
437
438 ctx.invalidateSession();
439 }
440
441
442
443
444 public boolean isResponseCommitted()
445 {
446 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
447
448 if (ctx == null)
449 {
450 throw new UnsupportedOperationException();
451 }
452
453 return ctx.isResponseCommitted();
454 }
455
456 public abstract boolean isUserInRole(String role);
457
458
459
460
461 public abstract void log(String message);
462
463
464
465
466 public abstract void log(String message, Throwable exception);
467
468 public abstract void redirect(String url) throws java.io.IOException;
469
470
471
472
473
474
475
476 public void responseFlushBuffer() throws IOException
477 {
478 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
479
480 if (ctx == null)
481 {
482 throw new UnsupportedOperationException();
483 }
484
485 ctx.responseFlushBuffer();
486 }
487
488
489
490
491
492 public void responseReset()
493 {
494 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
495
496 if (ctx == null)
497 {
498 throw new UnsupportedOperationException();
499 }
500
501 ctx.responseReset();
502 }
503
504
505
506
507
508
509
510
511
512 public void responseSendError(int statusCode, String message) throws IOException
513 {
514 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
515
516 if (ctx == null)
517 {
518 throw new UnsupportedOperationException();
519 }
520
521 ctx.responseSendError(statusCode, message);
522 }
523
524
525
526
527
528
529
530 public void setRequest(Object request)
531 {
532 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
533
534 if (ctx == null)
535 {
536 throw new UnsupportedOperationException();
537 }
538
539 ctx.setRequest(request);
540 }
541
542
543
544
545
546
547
548
549 public void setRequestCharacterEncoding(java.lang.String encoding)
550 throws java.io.UnsupportedEncodingException
551 {
552 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
553
554 if (ctx == null)
555 {
556 throw new UnsupportedOperationException();
557 }
558
559 ctx.setRequestCharacterEncoding(encoding);
560 }
561
562
563
564
565
566
567
568 public void setResponse(Object response)
569 {
570 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
571
572 if (ctx == null)
573 {
574 throw new UnsupportedOperationException();
575 }
576
577 ctx.setResponse(response);
578 }
579
580
581
582
583
584
585
586 public void setResponseBufferSize(int size)
587 {
588 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
589
590 if (ctx == null)
591 {
592 throw new UnsupportedOperationException();
593 }
594
595 ctx.setResponseBufferSize(size);
596 }
597
598
599
600
601
602
603
604 public void setResponseCharacterEncoding(String encoding)
605 {
606 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
607
608 if (ctx == null)
609 {
610 throw new UnsupportedOperationException();
611 }
612
613 ctx.setResponseCharacterEncoding(encoding);
614 }
615
616
617
618
619
620
621
622 public void setResponseContentLength(int length)
623 {
624 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
625
626 if (ctx == null)
627 {
628 throw new UnsupportedOperationException();
629 }
630
631 ctx.setResponseContentLength(length);
632 }
633
634
635
636
637
638
639
640 public void setResponseContentType(String contentType)
641 {
642 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
643
644 if (ctx == null)
645 {
646 throw new UnsupportedOperationException();
647 }
648
649 ctx.setResponseContentType(contentType);
650 }
651
652
653
654
655
656
657
658
659 public void setResponseHeader(String name, String value)
660 {
661 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
662
663 if (ctx == null)
664 {
665 throw new UnsupportedOperationException();
666 }
667
668 ctx.setResponseHeader(name, value);
669 }
670
671
672
673
674
675
676
677 public void setResponseStatus(int statusCode)
678 {
679 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
680
681 if (ctx == null)
682 {
683 throw new UnsupportedOperationException();
684 }
685
686 ctx.setResponseStatus(statusCode);
687 }
688
689
690
691
692
693
694 public boolean isSecure()
695 {
696 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
697
698 if (ctx == null)
699 {
700 throw new UnsupportedOperationException();
701 }
702
703 return ctx.isSecure();
704 }
705
706
707
708
709
710
711 public int getSessionMaxInactiveInterval()
712 {
713 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
714
715 if (ctx == null)
716 {
717 throw new UnsupportedOperationException();
718 }
719
720 return ctx.getSessionMaxInactiveInterval();
721 }
722
723
724
725
726
727
728 public void setSessionMaxInactiveInterval(int interval)
729 {
730 ExternalContext ctx = _MyFacesExternalContextHelper.firstInstance.get();
731
732 if (ctx == null)
733 {
734 throw new UnsupportedOperationException();
735 }
736
737 ctx.setSessionMaxInactiveInterval(interval);
738 }
739 }