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