comparison src/org/eclipse/jetty/server/handler/ContextHandler.java @ 994:4e9d373bf6e9

remove ContextHandler.Context
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 18 Oct 2016 16:34:18 -0600
parents d9d95acded81
children 0eba8f555c19
comparison
equal deleted inserted replaced
993:d9d95acded81 994:4e9d373bf6e9
80 80
81 /* ------------------------------------------------------------ */ 81 /* ------------------------------------------------------------ */
82 /** 82 /**
83 * ContextHandler. 83 * ContextHandler.
84 * 84 *
85 * This handler wraps a call to handle by setting the context and servlet path, plus setting the context classloader. 85 * This handler wraps a call to handle by setting the context and servlet path.
86 * 86 *
87 * <p>
88 * If the context init parameter "org.eclipse.jetty.server.context.ManagedAttributes" is set to a comma separated list of names, then they are treated as
89 * context attribute names, which if set as attributes are passed to the servers Container so that they may be managed with JMX.
90 * <p>
91 * The maximum size of a form that can be processed by this context is controlled by the system properties org.eclipse.jetty.server.Request.maxFormKeys
92 * and org.eclipse.jetty.server.Request.maxFormContentSize. These can also be configured with {@link #setMaxFormContentSize(int)} and {@link #setMaxFormKeys(int)}
93 *
94 * @org.apache.xbean.XBean description="Creates a basic HTTP context"
95 */ 87 */
96 public final class ContextHandler extends HandlerWrapper implements Server.Graceful 88 public final class ContextHandler extends HandlerWrapper implements Server.Graceful
97 { 89 {
98 private static final Logger LOG = LoggerFactory.getLogger(ContextHandler.class); 90 private static final Logger LOG = LoggerFactory.getLogger(ContextHandler.class);
99 91
100 private static final ThreadLocal<Context> __context = new ThreadLocal<Context>();
101
102 /* ------------------------------------------------------------ */
103 /**
104 * Get the current ServletContext implementation.
105 *
106 * @return ServletContext implementation
107 */
108 public static ContextHandler getCurrentContext()
109 {
110 Context context = __context.get();
111 return context==null ? null : context.getContextHandler();
112 }
113
114 private Context _scontext;
115
116 private final AttributesMap _contextAttributes;
117 private String _contextPath = "/"; 92 private String _contextPath = "/";
118 private Resource _baseResource; 93 private Resource _baseResource;
119 private Logger _logger; 94 private Logger _logger;
120 95
121 private boolean _shutdown = false; 96 private boolean _shutdown = false;
124 private final static int __STOPPED = 0, __AVAILABLE = 1, __SHUTDOWN = 2; 99 private final static int __STOPPED = 0, __AVAILABLE = 1, __SHUTDOWN = 2;
125 100
126 public ContextHandler() 101 public ContextHandler()
127 { 102 {
128 super(); 103 super();
129 _scontext = new Context();
130 _contextAttributes = new AttributesMap();
131 } 104 }
132 105
133 public ContextHandler(String contextPath) 106 public ContextHandler(String contextPath)
134 { 107 {
135 this(); 108 this();
148 121
149 @Override 122 @Override
150 public void dump(Appendable out, String indent) throws IOException 123 public void dump(Appendable out, String indent) throws IOException
151 { 124 {
152 dumpThis(out); 125 dumpThis(out);
153 dump(out,indent,TypeUtil.asList(getHandlers()),getBeans(), 126 dump(out,indent,TypeUtil.asList(getHandlers()),getBeans());
154 _contextAttributes.getAttributeEntrySet());
155 }
156
157 public Context getServletContext()
158 {
159 return _scontext;
160 } 127 }
161 128
162 public String getContextPath() 129 public String getContextPath()
163 { 130 {
164 return _contextPath; 131 return _contextPath;
180 _availability = isRunning()?(_shutdown?__SHUTDOWN:__AVAILABLE):__STOPPED; 147 _availability = isRunning()?(_shutdown?__SHUTDOWN:__AVAILABLE):__STOPPED;
181 } 148 }
182 } 149 }
183 150
184 /* ------------------------------------------------------------ */ 151 /* ------------------------------------------------------------ */
185 public Logger getLogger()
186 {
187 return _logger;
188 }
189
190 /* ------------------------------------------------------------ */
191 public void setLogger(Logger logger)
192 {
193 _logger = logger;
194 }
195
196 /* ------------------------------------------------------------ */
197 /* 152 /*
198 * @see org.eclipse.thread.AbstractLifeCycle#doStart() 153 * @see org.eclipse.thread.AbstractLifeCycle#doStart()
199 */ 154 */
200 @Override 155 @Override
201 protected void doStart() throws Exception 156 protected void doStart() throws Exception
204 159
205 if (_contextPath == null) 160 if (_contextPath == null)
206 throw new IllegalStateException("Null contextPath"); 161 throw new IllegalStateException("Null contextPath");
207 162
208 _logger = LoggerFactory.getLogger(getContextPath()); 163 _logger = LoggerFactory.getLogger(getContextPath());
209 ClassLoader old_classloader = null; 164
210 Thread current_thread = null; 165 super.doStart();
211 Context old_context = null; 166
212 167 synchronized(this)
213 try 168 {
214 { 169 _availability = _shutdown?__SHUTDOWN:__AVAILABLE;
215 old_context = __context.get();
216 __context.set(_scontext);
217
218 super.doStart();
219
220 synchronized(this)
221 {
222 _availability = _shutdown?__SHUTDOWN:__AVAILABLE;
223 }
224 }
225 finally
226 {
227 __context.set(old_context);
228 } 170 }
229 } 171 }
230 172
231 /* ------------------------------------------------------------ */ 173 /* ------------------------------------------------------------ */
232 /* 174 /*
235 @Override 177 @Override
236 protected void doStop() throws Exception 178 protected void doStop() throws Exception
237 { 179 {
238 _availability = __STOPPED; 180 _availability = __STOPPED;
239 181
240 ClassLoader old_classloader = null; 182 super.doStop();
241 Thread current_thread = null; 183 LOG.info("stopped {}",this);
242
243 Context old_context = __context.get();
244 __context.set(_scontext);
245 try
246 {
247 super.doStop();
248 }
249 finally
250 {
251 LOG.info("stopped {}",this);
252 __context.set(old_context);
253 }
254
255 _contextAttributes.clearAttributes();
256 } 184 }
257 185
258 private boolean checkContext(final String target, final Request baseRequest, final HttpServletResponse response) throws IOException, ServletException 186 private boolean checkContext(final String target, final Request baseRequest, final HttpServletResponse response) throws IOException, ServletException
259 { 187 {
260 switch (_availability) 188 switch (_availability)
296 public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException 224 public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
297 { 225 {
298 if (LOG.isDebugEnabled()) 226 if (LOG.isDebugEnabled())
299 LOG.debug("scope {}|{}|{} @ {}",baseRequest.getContextPath(),baseRequest.getServletPath(),baseRequest.getPathInfo(),this); 227 LOG.debug("scope {}|{}|{} @ {}",baseRequest.getContextPath(),baseRequest.getServletPath(),baseRequest.getPathInfo(),this);
300 228
301 Context old_context = null;
302 String old_context_path = null; 229 String old_context_path = null;
303 String old_servlet_path = null; 230 String old_servlet_path = null;
304 String old_path_info = null; 231 String old_path_info = null;
305 ClassLoader old_classloader = null;
306 Thread current_thread = null;
307 String pathInfo = target; 232 String pathInfo = target;
308 233
309 old_context = baseRequest.getContext(); 234 ContextHandler oldContextHandler = baseRequest._contextHandler;
310 235
311 // Are we already in this context? 236 // Are we already in this context?
312 if (old_context != _scontext) 237 if (oldContextHandler != this)
313 { 238 {
314 if (!checkContext(target,baseRequest,response)) 239 if (!checkContext(target,baseRequest,response))
315 return; 240 return;
316 241
317 if (target.length() > _contextPath.length()) 242 if (target.length() > _contextPath.length())
337 old_context_path = baseRequest.getContextPath(); 262 old_context_path = baseRequest.getContextPath();
338 old_servlet_path = baseRequest.getServletPath(); 263 old_servlet_path = baseRequest.getServletPath();
339 old_path_info = baseRequest.getPathInfo(); 264 old_path_info = baseRequest.getPathInfo();
340 265
341 // Update the paths 266 // Update the paths
342 baseRequest.setContext(_scontext); 267 baseRequest._contextHandler = this;
343 __context.set(_scontext);
344 if (target.startsWith("/")) 268 if (target.startsWith("/"))
345 { 269 {
346 if (_contextPath.length() == 1) 270 if (_contextPath.length() == 1)
347 baseRequest.setContextPath(""); 271 baseRequest.setContextPath("");
348 else 272 else
365 response.sendError(e.getStatus(),e.getReason()); 289 response.sendError(e.getStatus(),e.getReason());
366 } 290 }
367 } 291 }
368 finally 292 finally
369 { 293 {
370 if (old_context != _scontext) 294 if (oldContextHandler != this)
371 { 295 {
372 // reset the context and servlet path. 296 // reset the context and servlet path.
373 baseRequest.setContext(old_context); 297 baseRequest._contextHandler = oldContextHandler;
374 __context.set(old_context);
375 baseRequest.setContextPath(old_context_path); 298 baseRequest.setContextPath(old_context_path);
376 baseRequest.setServletPath(old_servlet_path); 299 baseRequest.setServletPath(old_servlet_path);
377 baseRequest.setPathInfo(old_path_info); 300 baseRequest.setPathInfo(old_path_info);
378 } 301 }
379 } 302 }
384 if (contextPath != null && contextPath.length() > 1 && contextPath.endsWith("/")) 307 if (contextPath != null && contextPath.length() > 1 && contextPath.endsWith("/"))
385 throw new IllegalArgumentException("ends with /"); 308 throw new IllegalArgumentException("ends with /");
386 _contextPath = contextPath; 309 _contextPath = contextPath;
387 } 310 }
388 311
389 /* ------------------------------------------------------------ */
390 /**
391 * @return Returns the resourceBase.
392 */
393 public Resource getBaseResource() 312 public Resource getBaseResource()
394 { 313 {
395 return _baseResource; 314 return _baseResource;
396 } 315 }
397 316
398 /* ------------------------------------------------------------ */
399 /**
400 * @return Returns the base resource as a string.
401 */
402 public String getResourceBase() 317 public String getResourceBase()
403 { 318 {
404 if (_baseResource == null) 319 if (_baseResource == null)
405 return null; 320 return null;
406 return _baseResource.toString(); 321 return _baseResource.toString();
407 } 322 }
408 323
409 /* ------------------------------------------------------------ */
410 /**
411 * @param base
412 * The resourceBase to set.
413 */
414 public void setBaseResource(Resource base) 324 public void setBaseResource(Resource base)
415 { 325 {
416 _baseResource = base; 326 _baseResource = base;
417 } 327 }
418 328
419 /* ------------------------------------------------------------ */
420 /**
421 * @param resourceBase
422 * The base resource as a string.
423 */
424 public void setResourceBase(String resourceBase) 329 public void setResourceBase(String resourceBase)
425 { 330 {
426 try 331 try
427 { 332 {
428 setBaseResource(Resource.newResource(resourceBase)); 333 setBaseResource(Resource.newResource(resourceBase));
457 b.append('}'); 362 b.append('}');
458 363
459 return b.toString(); 364 return b.toString();
460 } 365 }
461 366
462 /* ------------------------------------------------------------ */
463 /*
464 */
465 public Resource getResource(String path) throws MalformedURLException 367 public Resource getResource(String path) throws MalformedURLException
466 { 368 {
467 if (path == null || !path.startsWith(URIUtil.SLASH)) 369 if (path == null || !path.startsWith(URIUtil.SLASH))
468 throw new MalformedURLException(path); 370 throw new MalformedURLException(path);
469 371
513 { 415 {
514 LOG.trace("",e); 416 LOG.trace("",e);
515 } 417 }
516 return Collections.emptySet(); 418 return Collections.emptySet();
517 } 419 }
518
519 /* ------------------------------------------------------------ */
520 /**
521 * Context.
522 * <p>
523 * A partial implementation of {@link javax.servlet.ServletContext}. A complete implementation is provided by the derived {@link ContextHandler}.
524 * </p>
525 *
526 *
527 */
528 public final class Context implements ServletContext
529 {
530 protected int _majorVersion = 3;
531 protected int _minorVersion = 0;
532
533 /* ------------------------------------------------------------ */
534 protected Context()
535 {
536 }
537
538 /* ------------------------------------------------------------ */
539 public ContextHandler getContextHandler()
540 {
541 // TODO reduce visibility of this method
542 return ContextHandler.this;
543 }
544
545 /* ------------------------------------------------------------ */
546 /*
547 * @see javax.servlet.ServletContext#getContext(java.lang.String)
548 */
549 @Override
550 public ServletContext getContext(String uripath)
551 {
552 List<ContextHandler> contexts = new ArrayList<ContextHandler>();
553 Handler[] handlers = getServer().getChildHandlersByClass(ContextHandler.class);
554 String matched_path = null;
555
556 for (Handler handler : handlers)
557 {
558 if (handler == null)
559 continue;
560 ContextHandler ch = (ContextHandler)handler;
561 String context_path = ch.getContextPath();
562
563 if (uripath.equals(context_path) || (uripath.startsWith(context_path) && uripath.charAt(context_path.length()) == '/')
564 || "/".equals(context_path))
565 {
566 if (matched_path == null || context_path.length() > matched_path.length())
567 {
568 contexts.clear();
569 matched_path = context_path;
570 }
571
572 if (matched_path.equals(context_path))
573 contexts.add(ch);
574 }
575 }
576
577 if (contexts.size() > 0)
578 return contexts.get(0)._scontext;
579
580 // try again ignoring virtual hosts
581 matched_path = null;
582 for (Handler handler : handlers)
583 {
584 if (handler == null)
585 continue;
586 ContextHandler ch = (ContextHandler)handler;
587 String context_path = ch.getContextPath();
588
589 if (uripath.equals(context_path) || (uripath.startsWith(context_path) && uripath.charAt(context_path.length()) == '/')
590 || "/".equals(context_path))
591 {
592 if (matched_path == null || context_path.length() > matched_path.length())
593 {
594 contexts.clear();
595 matched_path = context_path;
596 }
597
598 if (matched_path.equals(context_path))
599 contexts.add(ch);
600 }
601 }
602
603 if (contexts.size() > 0)
604 return contexts.get(0)._scontext;
605 return null;
606 }
607
608 /* ------------------------------------------------------------ */
609 /*
610 * @see javax.servlet.ServletContext#getMajorVersion()
611 */
612 @Override
613 public int getMajorVersion()
614 {
615 return 3;
616 }
617
618
619 /* ------------------------------------------------------------ */
620 /*
621 * @see javax.servlet.ServletContext#getMimeType(java.lang.String)
622 */
623 @Override
624 public String getMimeType(String file)
625 {
626 return null;
627 }
628
629 /* ------------------------------------------------------------ */
630 /*
631 * @see javax.servlet.ServletContext#getMinorVersion()
632 */
633 @Override
634 public int getMinorVersion()
635 {
636 return 0;
637 }
638
639 /* ------------------------------------------------------------ */
640 /*
641 * @see javax.servlet.ServletContext#getNamedDispatcher(java.lang.String)
642 */
643 @Override
644 public RequestDispatcher getNamedDispatcher(String name)
645 {
646 throw new UnsupportedOperationException();
647 }
648
649 /* ------------------------------------------------------------ */
650 /*
651 * @see javax.servlet.ServletContext#getRequestDispatcher(java.lang.String)
652 */
653 @Override
654 public RequestDispatcher getRequestDispatcher(String uriInContext)
655 {
656 throw new UnsupportedOperationException();
657 }
658
659 /* ------------------------------------------------------------ */
660 /*
661 * @see javax.servlet.ServletContext#getRealPath(java.lang.String)
662 */
663 @Override
664 public String getRealPath(String path)
665 {
666 if (path == null)
667 return null;
668 if (path.length() == 0)
669 path = URIUtil.SLASH;
670 else if (path.charAt(0) != '/')
671 path = URIUtil.SLASH + path;
672
673 try
674 {
675 Resource resource = ContextHandler.this.getResource(path);
676 if (resource != null)
677 {
678 File file = resource.getFile();
679 if (file != null)
680 return file.getCanonicalPath();
681 }
682 }
683 catch (Exception e)
684 {
685 LOG.trace("",e);
686 }
687
688 return null;
689 }
690
691 /* ------------------------------------------------------------ */
692 @Override
693 public URL getResource(String path) throws MalformedURLException
694 {
695 Resource resource = ContextHandler.this.getResource(path);
696 if (resource != null && resource.exists())
697 return resource.getURL();
698 return null;
699 }
700
701 /* ------------------------------------------------------------ */
702 /*
703 * @see javax.servlet.ServletContext#getResourceAsStream(java.lang.String)
704 */
705 @Override
706 public InputStream getResourceAsStream(String path)
707 {
708 try
709 {
710 URL url = getResource(path);
711 if (url == null)
712 return null;
713 Resource r = Resource.newResource(url);
714 return r.getInputStream();
715 }
716 catch (Exception e)
717 {
718 LOG.trace("",e);
719 return null;
720 }
721 }
722
723 /* ------------------------------------------------------------ */
724 /*
725 * @see javax.servlet.ServletContext#getResourcePaths(java.lang.String)
726 */
727 @Override
728 public Set getResourcePaths(String path)
729 {
730 return ContextHandler.this.getResourcePaths(path);
731 }
732
733 /* ------------------------------------------------------------ */
734 /*
735 * @see javax.servlet.ServletContext#getServerInfo()
736 */
737 @Override
738 public String getServerInfo()
739 {
740 return "jetty/" + Server.version;
741 }
742
743 /* ------------------------------------------------------------ */
744 /*
745 * @see javax.servlet.ServletContext#getServlet(java.lang.String)
746 */
747 @Override
748 @Deprecated
749 public Servlet getServlet(String name) throws ServletException
750 {
751 throw new UnsupportedOperationException();
752 }
753
754 /* ------------------------------------------------------------ */
755 /*
756 * @see javax.servlet.ServletContext#getServletNames()
757 */
758 @SuppressWarnings("unchecked")
759 @Override
760 @Deprecated
761 public Enumeration getServletNames()
762 {
763 throw new UnsupportedOperationException();
764 }
765
766 /* ------------------------------------------------------------ */
767 /*
768 * @see javax.servlet.ServletContext#getServlets()
769 */
770 @SuppressWarnings("unchecked")
771 @Override
772 @Deprecated
773 public Enumeration getServlets()
774 {
775 throw new UnsupportedOperationException();
776 }
777
778 /* ------------------------------------------------------------ */
779 /*
780 * @see javax.servlet.ServletContext#log(java.lang.Exception, java.lang.String)
781 */
782 @Override
783 public void log(Exception exception, String msg)
784 {
785 _logger.warn(msg,exception);
786 }
787
788 /* ------------------------------------------------------------ */
789 /*
790 * @see javax.servlet.ServletContext#log(java.lang.String)
791 */
792 @Override
793 public void log(String msg)
794 {
795 _logger.info(msg);
796 }
797
798 /* ------------------------------------------------------------ */
799 /*
800 * @see javax.servlet.ServletContext#log(java.lang.String, java.lang.Throwable)
801 */
802 @Override
803 public void log(String message, Throwable throwable)
804 {
805 _logger.warn(message,throwable);
806 }
807
808 /* ------------------------------------------------------------ */
809 /*
810 * @see javax.servlet.ServletContext#getInitParameter(java.lang.String)
811 */
812 @Override
813 public String getInitParameter(String name)
814 {
815 return null;
816 }
817
818 /* ------------------------------------------------------------ */
819 /*
820 * @see javax.servlet.ServletContext#getInitParameterNames()
821 */
822 @SuppressWarnings("unchecked")
823 @Override
824 public Enumeration getInitParameterNames()
825 {
826 return null;
827 }
828
829 /* ------------------------------------------------------------ */
830 /*
831 * @see javax.servlet.ServletContext#getAttribute(java.lang.String)
832 */
833 @Override
834 public synchronized Object getAttribute(String name)
835 {
836 if (_contextAttributes != null)
837 return _contextAttributes.getAttribute(name);
838 return null;
839 }
840
841 /* ------------------------------------------------------------ */
842 /*
843 * @see javax.servlet.ServletContext#getAttributeNames()
844 */
845 @SuppressWarnings("unchecked")
846 @Override
847 public synchronized Enumeration getAttributeNames()
848 {
849 HashSet<String> set = new HashSet<String>();
850 if (_contextAttributes != null)
851 {
852 Enumeration<String> e = _contextAttributes.getAttributeNames();
853 while (e.hasMoreElements())
854 set.add(e.nextElement());
855 }
856
857 return Collections.enumeration(set);
858 }
859
860 /* ------------------------------------------------------------ */
861 /*
862 * @see javax.servlet.ServletContext#setAttribute(java.lang.String, java.lang.Object)
863 */
864 @Override
865 public synchronized void setAttribute(String name, Object value)
866 {
867 Object old_value = _contextAttributes.getAttribute(name);
868
869 if (value == null)
870 _contextAttributes.removeAttribute(name);
871 else
872 _contextAttributes.setAttribute(name,value);
873 }
874
875 /* ------------------------------------------------------------ */
876 /*
877 * @see javax.servlet.ServletContext#removeAttribute(java.lang.String)
878 */
879 @Override
880 public synchronized void removeAttribute(String name)
881 {
882 if (_contextAttributes == null)
883 {
884 // Set it on the handler
885 return;
886 }
887
888 _contextAttributes.removeAttribute(name);
889 }
890
891 /* ------------------------------------------------------------ */
892 /*
893 * @see javax.servlet.ServletContext#getServletContextName()
894 */
895 @Override
896 public String getServletContextName()
897 {
898 return ContextHandler.this.getContextPath();
899 }
900
901 /* ------------------------------------------------------------ */
902 @Override
903 public String getContextPath()
904 {
905 if ((_contextPath != null) && _contextPath.equals(URIUtil.SLASH))
906 return "";
907
908 return _contextPath;
909 }
910
911 /* ------------------------------------------------------------ */
912 @Override
913 public String toString()
914 {
915 return "ServletContext@" + ContextHandler.this.toString();
916 }
917
918 /* ------------------------------------------------------------ */
919 @Override
920 public boolean setInitParameter(String name, String value)
921 {
922 return false;
923 }
924
925 /* ------------------------------------------------------------ */
926 final private static String __unimplmented="Unimplemented - use org.eclipse.jetty.servlet.ServletContextHandler";
927
928 @Override
929 public Dynamic addFilter(String filterName, Class<? extends Filter> filterClass)
930 {
931 throw new UnsupportedOperationException();
932 }
933
934 @Override
935 public Dynamic addFilter(String filterName, Filter filter)
936 {
937 throw new UnsupportedOperationException();
938 }
939
940 @Override
941 public Dynamic addFilter(String filterName, String className)
942 {
943 throw new UnsupportedOperationException();
944 }
945
946 @Override
947 public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass)
948 {
949 throw new UnsupportedOperationException();
950 }
951
952 @Override
953 public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet)
954 {
955 throw new UnsupportedOperationException();
956 }
957
958 @Override
959 public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, String className)
960 {
961 throw new UnsupportedOperationException();
962 }
963
964 @Override
965 public <T extends Filter> T createFilter(Class<T> c) throws ServletException
966 {
967 throw new UnsupportedOperationException();
968 }
969
970 @Override
971 public <T extends Servlet> T createServlet(Class<T> c) throws ServletException
972 {
973 throw new UnsupportedOperationException();
974 }
975
976 @Override
977 public Set<SessionTrackingMode> getDefaultSessionTrackingModes()
978 {
979 throw new UnsupportedOperationException();
980 }
981
982 @Override
983 public Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
984 {
985 throw new UnsupportedOperationException();
986 }
987
988 @Override
989 public FilterRegistration getFilterRegistration(String filterName)
990 {
991 throw new UnsupportedOperationException();
992 }
993
994 @Override
995 public Map<String, ? extends FilterRegistration> getFilterRegistrations()
996 {
997 throw new UnsupportedOperationException();
998 }
999
1000 @Override
1001 public ServletRegistration getServletRegistration(String servletName)
1002 {
1003 throw new UnsupportedOperationException();
1004 }
1005
1006 @Override
1007 public Map<String, ? extends ServletRegistration> getServletRegistrations()
1008 {
1009 throw new UnsupportedOperationException();
1010 }
1011
1012 @Override
1013 public SessionCookieConfig getSessionCookieConfig()
1014 {
1015 throw new UnsupportedOperationException();
1016 }
1017
1018 @Override
1019 public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
1020 {
1021 throw new UnsupportedOperationException();
1022 }
1023
1024 @Override
1025 public void addListener(String className)
1026 {
1027 throw new UnsupportedOperationException();
1028 }
1029
1030 @Override
1031 public <T extends EventListener> void addListener(T t)
1032 {
1033 throw new UnsupportedOperationException();
1034 }
1035
1036 @Override
1037 public void addListener(Class<? extends EventListener> listenerClass)
1038 {
1039 throw new UnsupportedOperationException();
1040 }
1041
1042 @Override
1043 public <T extends EventListener> T createListener(Class<T> clazz) throws ServletException
1044 {
1045 try
1046 {
1047 return clazz.newInstance();
1048 }
1049 catch (InstantiationException e)
1050 {
1051 throw new ServletException(e);
1052 }
1053 catch (IllegalAccessException e)
1054 {
1055 throw new ServletException(e);
1056 }
1057 }
1058
1059 @Override
1060 public ClassLoader getClassLoader()
1061 {
1062 AccessController.checkPermission(new RuntimePermission("getClassLoader"));
1063 return null;
1064 }
1065
1066 @Override
1067 public int getEffectiveMajorVersion()
1068 {
1069 return _majorVersion;
1070 }
1071
1072 @Override
1073 public int getEffectiveMinorVersion()
1074 {
1075 return _minorVersion;
1076 }
1077
1078 public void setEffectiveMajorVersion (int v)
1079 {
1080 _majorVersion = v;
1081 }
1082
1083 public void setEffectiveMinorVersion (int v)
1084 {
1085 _minorVersion = v;
1086 }
1087
1088 @Override
1089 public JspConfigDescriptor getJspConfigDescriptor()
1090 {
1091 throw new UnsupportedOperationException();
1092 }
1093
1094 public void setJspConfigDescriptor(JspConfigDescriptor d)
1095 {
1096 throw new UnsupportedOperationException();
1097 }
1098
1099 @Override
1100 public void declareRoles(String... roleNames)
1101 {
1102 throw new UnsupportedOperationException();
1103 }
1104 }
1105
1106 } 420 }