View Javadoc

1   // ========================================================================
2   // Copyright (c) 2004-2009 Mort Bay Consulting Pty. Ltd.
3   // ------------------------------------------------------------------------
4   // All rights reserved. This program and the accompanying materials
5   // are made available under the terms of the Eclipse Public License v1.0
6   // and Apache License v2.0 which accompanies this distribution.
7   // The Eclipse Public License is available at 
8   // http://www.eclipse.org/legal/epl-v10.html
9   // The Apache License v2.0 is available at
10  // http://www.opensource.org/licenses/apache2.0.php
11  // You may elect to redistribute this code under either of these licenses. 
12  // ========================================================================
13  
14  package org.eclipse.jetty.servlet;
15  
16  import java.util.ArrayList;
17  import java.util.Arrays;
18  import java.util.Collections;
19  import java.util.EnumSet;
20  import java.util.EventListener;
21  import java.util.HashMap;
22  import java.util.HashSet;
23  import java.util.List;
24  import java.util.Map;
25  import java.util.Set;
26  
27  import javax.servlet.Filter;
28  import javax.servlet.RequestDispatcher;
29  import javax.servlet.Servlet;
30  import javax.servlet.ServletContext;
31  import javax.servlet.ServletContextEvent;
32  import javax.servlet.ServletContextListener;
33  import javax.servlet.ServletException;
34  
35  import org.eclipse.jetty.security.ConstraintAware;
36  import org.eclipse.jetty.security.ConstraintSecurityHandler;
37  import org.eclipse.jetty.security.SecurityHandler;
38  import org.eclipse.jetty.server.Dispatcher;
39  import org.eclipse.jetty.server.DispatcherType;
40  import org.eclipse.jetty.server.Handler;
41  import org.eclipse.jetty.server.HandlerContainer;
42  import org.eclipse.jetty.server.handler.ContextHandler;
43  import org.eclipse.jetty.server.handler.ErrorHandler;
44  import org.eclipse.jetty.server.handler.HandlerCollection;
45  import org.eclipse.jetty.server.handler.HandlerWrapper;
46  import org.eclipse.jetty.server.session.SessionHandler;
47  import org.eclipse.jetty.servlet.api.FilterRegistration;
48  import org.eclipse.jetty.servlet.api.ServletRegistration;
49  import org.eclipse.jetty.util.Loader;
50  
51  
52  /* ------------------------------------------------------------ */
53  /** Servlet Context.
54   * This extension to the ContextHandler allows for
55   * simple construction of a context with ServletHandler and optionally
56   * session and security handlers, et.<pre>
57   *   new ServletContext("/context",Context.SESSIONS|Context.NO_SECURITY);
58   * </pre>
59   * <p/>
60   * This class should have been called ServletContext, but this would have
61   * cause confusion with {@link ServletContext}.
62   */
63  public class ServletContextHandler extends ContextHandler
64  {   
65      public final static int SESSIONS=1;
66      public final static int SECURITY=2;
67      public final static int NO_SESSIONS=0;
68      public final static int NO_SECURITY=0;
69  
70      protected final List<Decorator> _decorators= new ArrayList<Decorator>();
71      protected Class<? extends SecurityHandler> _defaultSecurityHandlerClass=org.eclipse.jetty.security.ConstraintSecurityHandler.class;
72      protected SessionHandler _sessionHandler;
73      protected SecurityHandler _securityHandler;
74      protected ServletHandler _servletHandler;
75      protected HandlerWrapper _wrapper;
76      protected int _options;
77      protected Object _restrictedContextListeners;
78      
79      /* ------------------------------------------------------------ */
80      public ServletContextHandler()
81      {
82          this(null,null,null,null,null);
83      }
84      
85      /* ------------------------------------------------------------ */
86      public ServletContextHandler(int options)
87      {
88          this(null,null,options);
89      }
90      
91      /* ------------------------------------------------------------ */
92      public ServletContextHandler(HandlerContainer parent, String contextPath)
93      {
94          this(parent,contextPath,null,null,null,null);
95      }
96      
97      /* ------------------------------------------------------------ */
98      public ServletContextHandler(HandlerContainer parent, String contextPath, int options)
99      {
100         this(parent,contextPath,null,null,null,null);
101         _options=options;
102     }
103     
104     /* ------------------------------------------------------------ */
105     public ServletContextHandler(HandlerContainer parent, String contextPath, boolean sessions, boolean security)
106     {
107         this(parent,contextPath,(sessions?SESSIONS:0)|(security?SECURITY:0));
108     }
109 
110     /* ------------------------------------------------------------ */
111     public ServletContextHandler(HandlerContainer parent, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)
112     {   
113         this(parent,null,sessionHandler,securityHandler,servletHandler,errorHandler);
114     }
115 
116     /* ------------------------------------------------------------ */
117     public ServletContextHandler(HandlerContainer parent, String contextPath, SessionHandler sessionHandler, SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler)
118     {   
119         super((ContextHandler.Context)null);
120         _scontext = new Context();
121         _sessionHandler = sessionHandler;
122         _securityHandler = securityHandler;
123         _servletHandler = servletHandler;
124             
125         if (errorHandler!=null)
126             setErrorHandler(errorHandler);
127 
128         if (contextPath!=null)
129             setContextPath(contextPath);
130 
131         if (parent instanceof HandlerWrapper)
132             ((HandlerWrapper)parent).setHandler(this);
133         else if (parent instanceof HandlerCollection)
134             ((HandlerCollection)parent).addHandler(this);
135     }    
136 
137     /* ------------------------------------------------------------ */
138     /**
139      * @see org.eclipse.jetty.server.handler.ContextHandler#doStop()
140      */
141     @Override
142     protected void doStop() throws Exception
143     {
144         super.doStop();
145         if (_decorators != null)
146             _decorators.clear();
147         if (_wrapper != null)
148             _wrapper.setHandler(null);
149     }
150 
151     /* ------------------------------------------------------------ */
152     /** Get the defaultSecurityHandlerClass.
153      * @return the defaultSecurityHandlerClass
154      */
155     public Class<? extends SecurityHandler> getDefaultSecurityHandlerClass()
156     {
157         return _defaultSecurityHandlerClass;
158     }
159 
160     /* ------------------------------------------------------------ */
161     /** Set the defaultSecurityHandlerClass.
162      * @param defaultSecurityHandlerClass the defaultSecurityHandlerClass to set
163      */
164     public void setDefaultSecurityHandlerClass(Class<? extends SecurityHandler> defaultSecurityHandlerClass)
165     {
166         _defaultSecurityHandlerClass = defaultSecurityHandlerClass;
167     }
168 
169     /* ------------------------------------------------------------ */
170     protected SessionHandler newSessionHandler()
171     {
172         return new SessionHandler();
173     }
174     
175     /* ------------------------------------------------------------ */
176     protected SecurityHandler newSecurityHandler()
177     {
178         try
179         {
180             return (SecurityHandler)_defaultSecurityHandlerClass.newInstance();
181         }
182         catch(Exception e)
183         {
184             throw new IllegalStateException(e);
185         }
186     }
187 
188     /* ------------------------------------------------------------ */
189     protected ServletHandler newServletHandler()
190     {
191         return new ServletHandler();
192     }
193 
194     /* ------------------------------------------------------------ */
195     /**
196      * Finish constructing handlers and link them together.
197      * 
198      * @see org.eclipse.jetty.server.handler.ContextHandler#startContext()
199      */
200     protected void startContext() throws Exception
201     {
202         // force creation of missing handlers.
203         getSessionHandler();
204         getSecurityHandler();
205         getServletHandler();
206         
207         Handler handler = _servletHandler;
208         if (_securityHandler!=null)
209         {
210             _securityHandler.setHandler(handler);
211             handler=_securityHandler;
212         }
213         
214         if (_sessionHandler!=null)
215         {
216             _sessionHandler.setHandler(handler);
217             handler=_sessionHandler;
218         }
219         
220         // skip any wrapped handlers 
221         _wrapper=this;
222         while (_wrapper!=handler && _wrapper.getHandler() instanceof HandlerWrapper)
223             _wrapper=(HandlerWrapper)_wrapper.getHandler();
224         
225         // if we are not already linked
226         if (_wrapper!=handler)
227         {
228             if (_wrapper.getHandler()!=null )
229                 throw new IllegalStateException("!ScopedHandler");
230             _wrapper.setHandler(handler);
231         }
232         
233     	super.startContext();
234 
235     	// OK to Initialize servlet handler now
236     	if (_servletHandler != null && _servletHandler.isStarted())
237     	{
238     	    for (int i=_decorators.size()-1;i>=0; i--)
239     	    {
240     	        Decorator decorator = _decorators.get(i);
241                 if (_servletHandler.getFilters()!=null)
242                     for (FilterHolder holder:_servletHandler.getFilters())
243                         decorator.decorateFilterHolder(holder);
244     	        if(_servletHandler.getServlets()!=null)
245     	            for (ServletHolder holder:_servletHandler.getServlets())
246     	                decorator.decorateServletHolder(holder);
247     	    }   
248     	        
249     	    _servletHandler.initialize();
250     	}
251     }
252 
253     /* ------------------------------------------------------------ */
254     /**
255      * @return Returns the securityHandler.
256      */
257     public SecurityHandler getSecurityHandler()
258     {
259         if (_securityHandler==null && (_options&SECURITY)!=0 && !isStarted()) 
260             _securityHandler=newSecurityHandler();
261         
262         return _securityHandler;
263     }
264 
265     /* ------------------------------------------------------------ */
266     /**
267      * @return Returns the servletHandler.
268      */
269     public ServletHandler getServletHandler()
270     {
271         if (_servletHandler==null && !isStarted()) 
272             _servletHandler=newServletHandler();
273         return _servletHandler;
274     }
275 
276     /* ------------------------------------------------------------ */
277     /**
278      * @return Returns the sessionHandler.
279      */
280     public SessionHandler getSessionHandler()
281     {
282         if (_sessionHandler==null && (_options&SESSIONS)!=0 && !isStarted()) 
283             _sessionHandler=newSessionHandler();
284         return _sessionHandler;
285     }
286 
287     /* ------------------------------------------------------------ */
288     /** conveniance method to add a servlet.
289      */
290     public ServletHolder addServlet(String className,String pathSpec)
291     {
292         return getServletHandler().addServletWithMapping(className, pathSpec);
293     }
294 
295     /* ------------------------------------------------------------ */
296     /** conveniance method to add a servlet.
297      */
298     public ServletHolder addServlet(Class<? extends Servlet> servlet,String pathSpec)
299     {
300         return getServletHandler().addServletWithMapping(servlet.getName(), pathSpec);
301     }
302     
303     /* ------------------------------------------------------------ */
304     /** conveniance method to add a servlet.
305      */
306     public void addServlet(ServletHolder servlet,String pathSpec)
307     {
308         getServletHandler().addServletWithMapping(servlet, pathSpec);
309     }
310 
311     /* ------------------------------------------------------------ */
312     /** conveniance method to add a filter
313      */
314     public void addFilter(FilterHolder holder,String pathSpec,EnumSet<DispatcherType> dispatches)
315     {
316         getServletHandler().addFilterWithMapping(holder,pathSpec,dispatches);
317     }
318 
319     /* ------------------------------------------------------------ */
320     /** convenience method to add a filter
321      */
322     public FilterHolder addFilter(Class<? extends Filter> filterClass,String pathSpec,EnumSet<DispatcherType> dispatches)
323     {
324         return getServletHandler().addFilterWithMapping(filterClass,pathSpec,dispatches);
325     }
326 
327     /* ------------------------------------------------------------ */
328     /** convenience method to add a filter
329      */
330     public FilterHolder addFilter(String filterClass,String pathSpec,EnumSet<DispatcherType> dispatches)
331     {
332         return getServletHandler().addFilterWithMapping(filterClass,pathSpec,dispatches);
333     }
334     
335 
336     /* ------------------------------------------------------------ */
337     /** conveniance method to add a filter
338      */
339     public void addFilter(FilterHolder holder,String pathSpec,int dispatches)
340     {
341         getServletHandler().addFilterWithMapping(holder,pathSpec,dispatches);
342     }
343 
344     /* ------------------------------------------------------------ */
345     /** convenience method to add a filter
346      */
347     public FilterHolder addFilter(Class<? extends Filter> filterClass,String pathSpec,int dispatches)
348     {
349         return getServletHandler().addFilterWithMapping(filterClass,pathSpec,dispatches);
350     }
351 
352     /* ------------------------------------------------------------ */
353     /** convenience method to add a filter
354      */
355     public FilterHolder addFilter(String filterClass,String pathSpec,int dispatches)
356     {
357         return getServletHandler().addFilterWithMapping(filterClass,pathSpec,dispatches);
358     }
359 
360  
361 
362     public void callContextInitialized(ServletContextListener l, ServletContextEvent e)
363     {       
364         l.contextInitialized(e);  
365     }
366 
367 
368     public void callContextDestroyed(ServletContextListener l, ServletContextEvent e)
369     {
370         l.contextDestroyed(e);
371     }
372 
373 
374 
375     /* ------------------------------------------------------------ */
376     /**
377      * @param sessionHandler The sessionHandler to set.
378      */
379     public void setSessionHandler(SessionHandler sessionHandler)
380     {
381         if (isStarted())
382             throw new IllegalStateException("STARTED");
383 
384         _sessionHandler = sessionHandler;
385     }
386 
387     /* ------------------------------------------------------------ */
388     /**
389      * @param securityHandler The {@link SecurityHandler} to set on this context.
390      */
391     public void setSecurityHandler(SecurityHandler securityHandler)
392     {
393         if (isStarted())
394             throw new IllegalStateException("STARTED");
395 
396         _securityHandler = securityHandler;
397     }
398 
399     /* ------------------------------------------------------------ */
400     /**
401      * @param servletHandler The servletHandler to set.
402      */
403     public void setServletHandler(ServletHandler servletHandler)
404     {
405         if (isStarted())
406             throw new IllegalStateException("STARTED");
407 
408         _servletHandler = servletHandler;
409     }
410 
411     /* ------------------------------------------------------------ */
412     /**
413      * @return The decorator list used to resource inject new Filters, Servlets and EventListeners
414      */
415     public List<Decorator> getDecorators()
416     {
417         return Collections.unmodifiableList(_decorators);
418     }
419 
420     /* ------------------------------------------------------------ */
421     /**
422      * @param decorators The lis of {@link Decorator}s
423      */
424     public void setDecorators(List<Decorator> decorators)
425     {
426         _decorators.clear();
427         _decorators.addAll(decorators);
428     }
429     
430     /* ------------------------------------------------------------ */
431     /**
432      * @param decorator The decorator to add
433      */
434     public void addDecorator(Decorator decorator)
435     {
436         _decorators.add(decorator);
437     }
438 
439     /* ------------------------------------------------------------ */
440     void destroyServlet(Servlet servlet)
441     {
442         for (Decorator decorator : _decorators)
443             decorator.destroyServletInstance(servlet);
444     }
445 
446     /* ------------------------------------------------------------ */
447     void destroyFilter(Filter filter)
448     {
449         for (Decorator decorator : _decorators)
450             decorator.destroyFilterInstance(filter);
451     }
452     
453     /* ------------------------------------------------------------ */
454     public class Context extends ContextHandler.Context
455     {
456         /* ------------------------------------------------------------ */
457         /* 
458          * @see javax.servlet.ServletContext#getNamedDispatcher(java.lang.String)
459          */
460         @Override
461         public RequestDispatcher getNamedDispatcher(String name)
462         {
463             ContextHandler context=org.eclipse.jetty.servlet.ServletContextHandler.this;
464             if (_servletHandler==null || _servletHandler.getServlet(name)==null)
465                 return null;
466             return new Dispatcher(context, name);
467         }
468         
469         /* ------------------------------------------------------------ */
470         /**
471          * @since servlet-api-3.0
472          */
473         public FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass)
474         {
475             if (isStarted())
476                 throw new IllegalStateException();
477 
478             final ServletHandler handler = ServletContextHandler.this.getServletHandler();
479             final FilterHolder holder= handler.newFilterHolder();
480             holder.setName(filterName);
481             holder.setHeldClass(filterClass);
482             handler.addFilter(holder);
483             return holder.getRegistration();
484         }
485 
486         /* ------------------------------------------------------------ */
487         /**
488          * @since servlet-api-3.0
489          */
490         public FilterRegistration.Dynamic addFilter(String filterName, String className)
491         {
492             if (isStarted())
493                 throw new IllegalStateException();
494 
495             final ServletHandler handler = ServletContextHandler.this.getServletHandler();
496             final FilterHolder holder= handler.newFilterHolder();
497             holder.setName(filterName);
498             holder.setClassName(className);
499             handler.addFilter(holder);
500             return holder.getRegistration();
501         }
502 
503 
504         /* ------------------------------------------------------------ */
505         /**
506          * @since servlet-api-3.0
507          */
508         public FilterRegistration.Dynamic addFilter(String filterName, Filter filter)
509         {
510             if (isStarted())
511                 throw new IllegalStateException();
512 
513             final ServletHandler handler = ServletContextHandler.this.getServletHandler();
514             final FilterHolder holder= handler.newFilterHolder();
515             holder.setName(filterName);
516             holder.setFilter(filter);
517             handler.addFilter(holder);
518             return holder.getRegistration();
519         }
520         
521         /* ------------------------------------------------------------ */
522         /**
523          * @since servlet-api-3.0
524          */
525         public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass)
526         {
527             if (!isStarting())
528                 throw new IllegalStateException();
529 
530             final ServletHandler handler = ServletContextHandler.this.getServletHandler();
531             final ServletHolder holder= handler.newServletHolder();
532             holder.setName(servletName);
533             holder.setHeldClass(servletClass);
534             handler.addServlet(holder);
535             return holder.getRegistration();
536         }
537 
538         /* ------------------------------------------------------------ */
539         /**
540          * @since servlet-api-3.0
541          */
542         public ServletRegistration.Dynamic addServlet(String servletName, String className)
543         {
544             if (!isStarting())
545                 throw new IllegalStateException();
546             
547             final ServletHandler handler = ServletContextHandler.this.getServletHandler();
548             final ServletHolder holder= handler.newServletHolder();
549             holder.setName(servletName);
550             holder.setClassName(className);
551             handler.addServlet(holder);
552             return holder.getRegistration();
553         }
554 
555         /* ------------------------------------------------------------ */
556         /**
557          * @since servlet-api-3.0
558          */
559         public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet)
560         {
561             if (!isStarting())
562                 throw new IllegalStateException();
563 
564             final ServletHandler handler = ServletContextHandler.this.getServletHandler();
565             final ServletHolder holder= handler.newServletHolder();
566             holder.setName(servletName);
567             holder.setServlet(servlet);
568             handler.addServlet(holder);
569             return holder.getRegistration();
570         }
571 
572         /* ------------------------------------------------------------ */
573         public boolean setInitParameter(String name, String value)
574         {
575             // TODO other started conditions
576             if (!isStarting())
577                 throw new IllegalStateException();
578             
579             return super.setInitParameter(name,value);
580         }
581 
582         /* ------------------------------------------------------------ */
583         public <T extends Filter> T createFilter(Class<T> c) throws ServletException
584         {
585             try
586             {
587                 T f = c.newInstance();
588                 for (int i=_decorators.size()-1; i>=0; i--)
589                 {
590                     Decorator decorator = _decorators.get(i);
591                     f=decorator.decorateFilterInstance(f);
592                 }
593                 return f;
594             }
595             catch (InstantiationException e)
596             {
597                 throw new ServletException(e);
598             }
599             catch (IllegalAccessException e)
600             {
601                 throw new ServletException(e);
602             }
603         }
604 
605         /* ------------------------------------------------------------ */
606         public <T extends Servlet> T createServlet(Class<T> c) throws ServletException
607         {
608             try
609             {
610                 T s = c.newInstance();
611                 for (int i=_decorators.size()-1; i>=0; i--)
612                 {
613                     Decorator decorator = _decorators.get(i);
614                     s=decorator.decorateServletInstance(s);
615                 }
616                 return s;
617             }
618             catch (InstantiationException e)
619             {
620                 throw new ServletException(e);
621             }
622             catch (IllegalAccessException e)
623             {
624                 throw new ServletException(e);
625             }
626         }
627         
628         public FilterRegistration getFilterRegistration(String filterName)
629         {   
630             final FilterHolder holder=ServletContextHandler.this.getServletHandler().getFilter(filterName);
631             return (holder==null)?null:holder.getRegistration();
632         }
633 
634         
635         public Map<String, ? extends FilterRegistration> getFilterRegistrations()
636         {
637             HashMap<String, FilterRegistration> registrations = new HashMap<String, FilterRegistration>();
638             ServletHandler handler=ServletContextHandler.this.getServletHandler();
639             FilterHolder[] holders=handler.getFilters();
640             if (holders!=null)
641             {
642                 for (FilterHolder holder : holders)
643                     registrations.put(holder.getName(),holder.getRegistration());
644             }
645             return registrations;
646         }
647 
648         
649         public ServletRegistration getServletRegistration(String servletName)
650         { 
651             final ServletHolder holder=ServletContextHandler.this.getServletHandler().getServlet(servletName);
652             return (holder==null)?null:holder.getRegistration();
653         }
654 
655         
656         public Map<String, ? extends ServletRegistration> getServletRegistrations()
657         { 
658             HashMap<String, ServletRegistration> registrations = new HashMap<String, ServletRegistration>();
659             ServletHandler handler=ServletContextHandler.this.getServletHandler();
660             ServletHolder[] holders=handler.getServlets();
661             if (holders!=null)
662             {
663                 for (ServletHolder holder : holders)
664                     registrations.put(holder.getName(),holder.getRegistration());
665             }
666             return registrations;
667         }
668 
669   
670         public void addListener(String className)
671         {
672             // TODO other started conditions
673             if (!isStarting())
674                 throw new IllegalStateException();
675             try
676             {
677                 Class<? extends EventListener> clazz = getClassLoader()==null?Loader.loadClass(ContextHandler.class,className):getClassLoader().loadClass(className);
678                 addListener(clazz);
679             }
680             catch (ClassNotFoundException e)
681             {
682                 throw new IllegalArgumentException(e);
683             }
684         }
685 
686       
687         public <T extends EventListener> void addListener(T t)
688         {
689             if (!isStarting())
690                 throw new IllegalStateException();
691          
692             ServletContextHandler.this.addEventListener(t);
693         }
694 
695       
696         public void addListener(Class<? extends EventListener> listenerClass)
697         {
698             if (!isStarting())
699                 throw new IllegalStateException();
700 
701             try
702             {
703                 EventListener l = createListener(listenerClass);
704                 ServletContextHandler.this.addEventListener(l);
705             }
706             catch (ServletException e)
707             {
708                 throw new IllegalStateException(e);
709             }
710         }
711 
712    
713         public <T extends EventListener> T createListener(Class<T> clazz) throws ServletException
714         {
715             try
716             {
717                 T l = null;
718                 try
719                 {
720                     l = clazz.newInstance();
721                 }
722                 catch (InstantiationException e)
723                 {
724                     throw new ServletException(e);
725                 }
726                 catch (IllegalAccessException e)
727                 {
728                     throw new ServletException(e);
729                 }
730 
731                 for (int i=_decorators.size()-1; i>=0; i--)
732                 {
733                     Decorator decorator = _decorators.get(i);
734                     l=decorator.decorateListenerInstance(l);
735                 }
736                 return l;
737             }
738             catch(ServletException e)
739             {
740                 throw e;
741             }
742             catch(Exception e)
743             {
744                 throw new ServletException(e);
745             }
746         }
747 
748      
749         public void declareRoles(String... roleNames)
750         {
751             if (!isStarting())
752                 throw new IllegalStateException();
753            
754             //Get a reference to the SecurityHandler, which must be ConstraintAware
755             if (_securityHandler != null && _securityHandler instanceof ConstraintAware)
756             {
757                 HashSet<String> union = new HashSet<String>();
758                 Set<String> existing = ((ConstraintAware)_securityHandler).getRoles();
759                 if (existing != null)
760                     union.addAll(existing);
761                 union.addAll(Arrays.asList(roleNames));
762                 ((ConstraintSecurityHandler)_securityHandler).setRoles(union);
763             }
764         }
765     }
766     
767     
768     /* ------------------------------------------------------------ */
769     /** Interface to decorate loaded classes.
770      */
771     public interface Decorator
772     {
773         <T extends Filter> T decorateFilterInstance(T filter) throws ServletException;
774         <T extends Servlet> T decorateServletInstance(T servlet) throws ServletException;
775         <T extends EventListener> T decorateListenerInstance(T listener) throws ServletException;
776 
777         void decorateFilterHolder(FilterHolder filter) throws ServletException;
778         void decorateServletHolder(ServletHolder servlet) throws ServletException;
779         
780         void destroyServletInstance(Servlet s);
781         void destroyFilterInstance(Filter f);
782         void destroyListenerInstance(EventListener f);
783     }
784 }