Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   //
   //  ========================================================================
   //  Copyright (c) 1995-2012 Mort Bay Consulting Pty. Ltd.
   //  ------------------------------------------------------------------------
   //  All rights reserved. This program and the accompanying materials
   //  are made available under the terms of the Eclipse Public License v1.0
   //  and Apache License v2.0 which accompanies this distribution.
   //
   //      The Eclipse Public License is available at
  //      http://www.eclipse.org/legal/epl-v10.html
  //
  //      The Apache License v2.0 is available at
  //      http://www.opensource.org/licenses/apache2.0.php
  //
  //  You may elect to redistribute this code under either of these licenses.
  //  ========================================================================
  //
  
  package org.eclipse.jetty.servlet;
  
  import java.util.Arrays;
  import java.util.EnumSet;
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  
  
  
  
  /* ------------------------------------------------------------ */
Servlet Context. This extension to the ContextHandler allows for simple construction of a context with ServletHandler and optionally session and security handlers, et.
   new ServletContext("/context",Context.SESSIONS|Context.NO_SECURITY);
 

This class should have been called ServletContext, but this would have cause confusion with javax.servlet.ServletContext.

  
  public class ServletContextHandler extends ContextHandler
  {   
      public final static int SESSIONS=1;
      public final static int SECURITY=2;
      public final static int NO_SESSIONS=0;
      public final static int NO_SECURITY=0;
  
      protected final List<Decorator_decoratorsnew ArrayList<Decorator>();
      protected SessionHandler _sessionHandler;
      protected SecurityHandler _securityHandler;
      protected ServletHandler _servletHandler;
      protected HandlerWrapper _wrapper;
      protected int _options;
      protected JspConfigDescriptor _jspConfig;
      protected Object _restrictedContextListeners;
      private boolean _restrictListeners = true;
  
      /* ------------------------------------------------------------ */
      public ServletContextHandler()
      {
          this(null,null,null,null,null);
      }
     
     /* ------------------------------------------------------------ */
     public ServletContextHandler(int options)
     {
         this(null,null,options);
     }
     
     /* ------------------------------------------------------------ */
     public ServletContextHandler(HandlerContainer parentString contextPath)
     {
         this(parent,contextPath,null,null,null,null);
     }
     
     /* ------------------------------------------------------------ */
     public ServletContextHandler(HandlerContainer parentString contextPathint options)
     {
         this(parent,contextPath,null,null,null,null);
         =options;
     }
     
     /* ------------------------------------------------------------ */
     public ServletContextHandler(HandlerContainer parentString contextPathboolean sessionsboolean security)
     {
         this(parent,contextPath,(sessions?:0)|(security?:0));
     }
 
     /* ------------------------------------------------------------ */
     public ServletContextHandler(HandlerContainer parentSessionHandler sessionHandlerSecurityHandler securityHandlerServletHandler servletHandlerErrorHandler errorHandler)
     {   
         this(parent,null,sessionHandler,securityHandler,servletHandler,errorHandler);
     }
 
     /* ------------------------------------------------------------ */
     public ServletContextHandler(HandlerContainer parentString contextPathSessionHandler sessionHandlerSecurityHandler securityHandlerServletHandler servletHandlerErrorHandler errorHandler)
     {   
         super((ContextHandler.Context)null);
          = new Context();
          = sessionHandler;
          = securityHandler;
          = servletHandler;
             
         if (errorHandler!=null)
             setErrorHandler(errorHandler);
 
         if (contextPath!=null)
             setContextPath(contextPath);
 
         if (parent instanceof HandlerWrapper)
             ((HandlerWrapper)parent).setHandler(this);
         else if (parent instanceof HandlerCollection)
             ((HandlerCollection)parent).addHandler(this);
     }    
 
     /* ------------------------------------------------------------ */
    
 
     @Override
     protected void doStop() throws Exception
     {
         super.doStop();
         if ( != null)
             .clear();
         if ( != null)
             .setHandler(null);
     }
 
     /* ------------------------------------------------------------ */
    
Get the defaultSecurityHandlerClass.

Returns:
the defaultSecurityHandlerClass
 
     public Class<? extends SecurityHandlergetDefaultSecurityHandlerClass()
     {
         return ;
     }
 
     /* ------------------------------------------------------------ */
    
Set the defaultSecurityHandlerClass.

Parameters:
defaultSecurityHandlerClass the defaultSecurityHandlerClass to set
 
     public void setDefaultSecurityHandlerClass(Class<? extends SecurityHandlerdefaultSecurityHandlerClass)
     {
          = defaultSecurityHandlerClass;
     }
 
     /* ------------------------------------------------------------ */
     protected SessionHandler newSessionHandler()
     {
         return new SessionHandler();
     }
     
     /* ------------------------------------------------------------ */
     protected SecurityHandler newSecurityHandler()
     {
         try
         {
             return (SecurityHandler).newInstance();
         }
         catch(Exception e)
         {
             throw new IllegalStateException(e);
         }
     }
 
     /* ------------------------------------------------------------ */
     protected ServletHandler newServletHandler()
     {
         return new ServletHandler();
     }
 
     /* ------------------------------------------------------------ */
    
Finish constructing handlers and link them together.

 
     protected void startContext() throws Exception
     {
         // force creation of missing handlers.
         getSessionHandler();
         getSecurityHandler();
         getServletHandler();
         
         Handler handler = ;
         if (!=null)
         {
             .setHandler(handler);
             handler=;
         }
         
         if (!=null)
         {
             .setHandler(handler);
             handler=;
         }
         
         // skip any wrapped handlers 
         =this;
         while (!=handler && .getHandler() instanceof HandlerWrapper)
             =(HandlerWrapper).getHandler();
         
         // if we are not already linked
         if (!=handler)
         {
             if (.getHandler()!=null )
                 throw new IllegalStateException("!ScopedHandler");
             .setHandler(handler);
         }
         
     	super.startContext();
 
     	// OK to Initialize servlet handler now
     	if ( != null && .isStarted())
     	{
     	    for (int i=.size()-1;i>=0; i--)
     	    {
     	        Decorator decorator = .get(i);
                 if (.getFilters()!=null)
                     for (FilterHolder holder:.getFilters())
                         decorator.decorateFilterHolder(holder);
     	        if(.getServlets()!=null)
     	            for (ServletHolder holder:.getServlets())
     	                decorator.decorateServletHolder(holder);
     	    }   
     	        
     	    .initialize();
     	}
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
Returns the securityHandler.
 
     {
         if (==null && (&)!=0 && !isStarted()) 
             =newSecurityHandler();
         
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
Returns the servletHandler.
 
     {
         if (==null && !isStarted()) 
             =newServletHandler();
         return ;
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
Returns the sessionHandler.
 
     {
         if (==null && (&)!=0 && !isStarted()) 
             =newSessionHandler();
         return ;
     }
 
     /* ------------------------------------------------------------ */
    
conveniance method to add a servlet.
 
     public ServletHolder addServlet(String className,String pathSpec)
     {
         return getServletHandler().addServletWithMapping(classNamepathSpec);
     }
 
     /* ------------------------------------------------------------ */
    
conveniance method to add a servlet.
 
     public ServletHolder addServlet(Class<? extends Servletservlet,String pathSpec)
     {
         return getServletHandler().addServletWithMapping(servlet.getName(), pathSpec);
     }
     
     /* ------------------------------------------------------------ */
    
conveniance method to add a servlet.
 
     public void addServlet(ServletHolder servlet,String pathSpec)
     {
         getServletHandler().addServletWithMapping(servletpathSpec);
     }
 
     /* ------------------------------------------------------------ */
    
conveniance method to add a filter
 
     public void addFilter(FilterHolder holder,String pathSpec,EnumSet<DispatcherTypedispatches)
     {
         getServletHandler().addFilterWithMapping(holder,pathSpec,dispatches);
     }
 
     /* ------------------------------------------------------------ */
    
convenience method to add a filter
 
     public FilterHolder addFilter(Class<? extends FilterfilterClass,String pathSpec,EnumSet<DispatcherTypedispatches)
     {
         return getServletHandler().addFilterWithMapping(filterClass,pathSpec,dispatches);
     }
 
     /* ------------------------------------------------------------ */
    
convenience method to add a filter
 
     public FilterHolder addFilter(String filterClass,String pathSpec,EnumSet<DispatcherTypedispatches)
     {
         return getServletHandler().addFilterWithMapping(filterClass,pathSpec,dispatches);
     }

    
notification that a ServletRegistration has been created so we can track the annotations

Parameters:
holder new holder created through the api.
Returns:
the ServletRegistration.Dynamic
 
         return holder.getRegistration();
     }

    
delegate for ServletContext.declareRole method

Parameters:
roleNames role names to add
 
     protected void addRoles(String... roleNames) {
         //Get a reference to the SecurityHandler, which must be ConstraintAware
         if ( != null &&  instanceof ConstraintAware)
         {
             HashSet<Stringunion = new HashSet<String>();
             Set<Stringexisting = ((ConstraintAware)).getRoles();
             if (existing != null)
                 union.addAll(existing);
             union.addAll(Arrays.asList(roleNames));
             ((ConstraintSecurityHandler)).setRoles(union);
         }
     }

    
Delegate for ServletRegistration.Dynamic.setServletSecurity method

Parameters:
registration ServletRegistration.Dynamic instance that setServletSecurity was called on
servletSecurityElement new security info
Returns:
the set of exact URL mappings currently associated with the registration that are also present in the web.xml security constraints and thus will be unaffected by this call.
 
     public Set<StringsetServletSecurity(ServletRegistration.Dynamic registrationServletSecurityElement servletSecurityElement)
     {
         //Default implementation is to just accept them all. If using a webapp, then this behaviour is overridden in WebAppContext.setServletSecurity       
         Collection<StringpathSpecs = registration.getMappings();
         if (pathSpecs != null)
         {
             for (String pathSpec:pathSpecs)
             {
                 List<ConstraintMappingmappings = ConstraintSecurityHandler.createConstraintsWithMappingsForPath(registration.getName(), pathSpecservletSecurityElement);
                 for (ConstraintMapping m:mappings)
                     ((ConstraintAware)getSecurityHandler()).addConstraintMapping(m);
             }
         }
         return Collections.emptySet();
     }
 
 
     
     public void restrictEventListener (EventListener e)
     {
         if ( && e instanceof ServletContextListener)
              = LazyList.add(e);
     }
 
     public boolean isRestrictListeners() {
         return ;
     }
 
     public void setRestrictListeners(boolean restrictListeners) {
         this. = restrictListeners;
     }
 
     {
         try
         {
             //toggle state of the dynamic API so that the listener cannot use it
             if (LazyList.contains(l))
                 this.getServletContext().setEnabled(false);
             
             super.callContextInitialized(le);
         }
         finally
         {
             //untoggle the state of the dynamic API
             this.getServletContext().setEnabled(true);
         }
     }
 
     
     {
         super.callContextDestroyed(le);
     }
 
   
 
     /* ------------------------------------------------------------ */
    

Parameters:
sessionHandler The sessionHandler to set.
 
     public void setSessionHandler(SessionHandler sessionHandler)
     {
         if (isStarted())
             throw new IllegalStateException("STARTED");
 
          = sessionHandler;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
securityHandler The org.eclipse.jetty.security.SecurityHandler to set on this context.
 
     public void setSecurityHandler(SecurityHandler securityHandler)
     {
         if (isStarted())
             throw new IllegalStateException("STARTED");
 
          = securityHandler;
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
servletHandler The servletHandler to set.
 
     public void setServletHandler(ServletHandler servletHandler)
     {
         if (isStarted())
             throw new IllegalStateException("STARTED");
 
          = servletHandler;
     }
 
     /* ------------------------------------------------------------ */
    

Returns:
The decorator list used to resource inject new Filters, Servlets and EventListeners
 
     public List<DecoratorgetDecorators()
     {
         return Collections.unmodifiableList();
     }
 
     /* ------------------------------------------------------------ */
    

Parameters:
decorators The lis of ServletContextHandler.Decorators
 
     public void setDecorators(List<Decoratordecorators)
     {
         .clear();
         .addAll(decorators);
     }
     
     /* ------------------------------------------------------------ */
    

Parameters:
decorator The decorator to add
 
     public void addDecorator(Decorator decorator)
     {
         .add(decorator);
     }
 
     /* ------------------------------------------------------------ */
     void destroyServlet(Servlet servlet)
     {
         for (Decorator decorator : )
             decorator.destroyServletInstance(servlet);
     }
 
     /* ------------------------------------------------------------ */
     void destroyFilter(Filter filter)
     {
         for (Decorator decorator : )
             decorator.destroyFilterInstance(filter);
     }
     
     /* ------------------------------------------------------------ */
     public static class JspPropertyGroup implements JspPropertyGroupDescriptor
     {
         private List<String_urlPatterns = new ArrayList<String>();
         private String _elIgnored;
         private String _pageEncoding;
         private String _scriptingInvalid;
         private String _isXml;
         private List<String_includePreludes = new ArrayList<String>();
         private List<String_includeCodas = new ArrayList<String>();
         private String _deferredSyntaxAllowedAsLiteral;
         private String _trimDirectiveWhitespaces;
         private String _defaultContentType;
         private String _buffer;
         private String _errorOnUndeclaredNamespace;
        
        

        
 
         public Collection<StringgetUrlPatterns()
         {
             return new ArrayList<String>(); // spec says must be a copy
         }
         
         public void addUrlPattern (String s)
         {
             if (!.contains(s))
                 .add(s);
         }

        
 
         public String getElIgnored()
         {
             return ;
         }
         
         public void setElIgnored (String s)
         {
              = s;
         }

        
 
         public String getPageEncoding()
         {
             return ;
         }
         
         public void setPageEncoding(String pageEncoding)
         {
              = pageEncoding;
         }
 
         public void setScriptingInvalid(String scriptingInvalid)
         {
              = scriptingInvalid;
         }
 
         public void setIsXml(String isXml)
         {
              = isXml;
         }
 
         public void setDeferredSyntaxAllowedAsLiteral(String deferredSyntaxAllowedAsLiteral)
         {
              = deferredSyntaxAllowedAsLiteral;
         }
 
         public void setTrimDirectiveWhitespaces(String trimDirectiveWhitespaces)
         {
              = trimDirectiveWhitespaces;
         }
 
         public void setDefaultContentType(String defaultContentType)
         {
              = defaultContentType;
         }
 
         public void setBuffer(String buffer)
         {
              = buffer;
         }
 
         public void setErrorOnUndeclaredNamespace(String errorOnUndeclaredNamespace)
         {
              = errorOnUndeclaredNamespace;
         }

        
 
         public String getScriptingInvalid()
         {
             return ;
         }

        
 
         public String getIsXml()
         {
             return ;
         }

        
 
         public Collection<StringgetIncludePreludes()
         {
             return new ArrayList<String>(); //must be a copy
         }
         
         public void addIncludePrelude(String prelude)
         {
             if (!.contains(prelude))
                 .add(prelude);
         }

        
 
         public Collection<StringgetIncludeCodas()
         {
             return new ArrayList<String>(); //must be a copy
         }
 
         public void addIncludeCoda (String coda)
         {
             if (!.contains(coda))
                 .add(coda);
         }
        
        
 
         public String getDeferredSyntaxAllowedAsLiteral()
         {
             return ;
         }

        
 
         public String getTrimDirectiveWhitespaces()
         {
             return ;
         }

        
 
         public String getDefaultContentType()
         {
             return ;
         }

        
 
         public String getBuffer()
         {
             return ;
         }

        
 
         public String getErrorOnUndeclaredNamespace()
         {
             return ;
         }
         
         public String toString ()
         {
             StringBuffer sb = new StringBuffer();
             sb.append("JspPropertyGroupDescriptor:");
             sb.append(" el-ignored="+);
             sb.append(" is-xml="+);
             sb.append(" page-encoding="+);
             sb.append(" scripting-invalid="+);
             sb.append(" deferred-syntax-allowed-as-literal="+);
             sb.append(" trim-directive-whitespaces"+);
             sb.append(" default-content-type="+);
             sb.append(" buffer="+);
             sb.append(" error-on-undeclared-namespace="+);
             for (String prelude:)
                 sb.append(" include-prelude="+prelude);
             for (String coda:)
                 sb.append(" include-coda="+coda);
             return sb.toString();
         }
     }
     
     /* ------------------------------------------------------------ */
     public static class TagLib implements TaglibDescriptor
     {
         private String _uri;
         private String _location;

        
 
         public String getTaglibURI()
         {
            return ;
         }
         
         public void setTaglibURI(String uri)
         {
              = uri;
         }

        
 
         public String getTaglibLocation()
         {
             return ;
         }
         
         public void setTaglibLocation(String location)
         {
              = location;
         }
     
         public String toString()
         {
             return ("TagLibDescriptor: taglib-uri="++" location="+);
         }
     }
     
     
     /* ------------------------------------------------------------ */
     public static class JspConfig implements JspConfigDescriptor
     {
         private List<TaglibDescriptor_taglibs = new ArrayList<TaglibDescriptor>();
         
         public JspConfig() {}

        
 
         public Collection<TaglibDescriptorgetTaglibs()
         {
             return new ArrayList<TaglibDescriptor>();
         }
         
         public void addTaglibDescriptor (TaglibDescriptor d)
         {
             .add(d);
         }

        
 
         {
            return new ArrayList<JspPropertyGroupDescriptor>();
         }
         
         public void addJspPropertyGroup(JspPropertyGroupDescriptor g)
         {
             .add(g);
         }
         
         public String toString()
         {
             StringBuffer sb = new StringBuffer();
             sb.append("JspConfigDescriptor: \n");
             for (TaglibDescriptor taglib:)
                 sb.append(taglib+"\n");
             for (JspPropertyGroupDescriptor jpg:)
                 sb.append(jpg+"\n");
             return sb.toString();
         }
     }
     
     
     /* ------------------------------------------------------------ */
     public class Context extends ContextHandler.Context
     {
         /* ------------------------------------------------------------ */
         /* 
          * @see javax.servlet.ServletContext#getNamedDispatcher(java.lang.String)
          */
         @Override
         public RequestDispatcher getNamedDispatcher(String name)
         {
             ContextHandler context=org.eclipse.jetty.servlet.ServletContextHandler.this;
             if (==null)
                 return null;
             ServletHolder holder = .getServlet(name);
             if (holder==null || !holder.isEnabled())
                 return null;
             return new Dispatcher(contextname);
         }
         
         /* ------------------------------------------------------------ */
        

Since:
servlet-api-3.0
 
         @Override
         public FilterRegistration.Dynamic addFilter(String filterNameClass<? extends FilterfilterClass)
         {
             if (isStarted())
                 throw new IllegalStateException();
             
             if (!)
                 throw new UnsupportedOperationException();
 
             final ServletHandler handler = ServletContextHandler.this.getServletHandler();
             FilterHolder holder = handler.getFilter(filterName);
             if (holder == null)
             {
                 //new filter
                 holder = handler.newFilterHolder(..);
                 holder.setName(filterName);
                 holder.setHeldClass(filterClass);
                 handler.addFilter(holder);
                 return holder.getRegistration();
             }
             if (holder.getClassName()==null && holder.getHeldClass()==null)
             {
                 //preliminary filter registration completion
                 holder.setHeldClass(filterClass);
                 return holder.getRegistration();
             }
             else
                 return null//existing filter
         }
 
         /* ------------------------------------------------------------ */
        

Since:
servlet-api-3.0
 
         @Override
         public FilterRegistration.Dynamic addFilter(String filterNameString className)
         {
             if (isStarted())
                 throw new IllegalStateException();
             
             if (!)
                 throw new UnsupportedOperationException();
 
             final ServletHandler handler = ServletContextHandler.this.getServletHandler();
             FilterHolder holder = handler.getFilter(filterName);
             if (holder == null)
             {
                 //new filter
                 holder = handler.newFilterHolder(..);
                 holder.setName(filterName);
                 holder.setClassName(className);
                 handler.addFilter(holder);
                 return holder.getRegistration();
             }
             if (holder.getClassName()==null && holder.getHeldClass()==null)
             {
                 //preliminary filter registration completion
                 holder.setClassName(className);
                 return holder.getRegistration();
             }
             else
                 return null//existing filter
         }
 
 
         /* ------------------------------------------------------------ */
        

Since:
servlet-api-3.0
 
         @Override
         public FilterRegistration.Dynamic addFilter(String filterNameFilter filter)
         {
             if (isStarted())
                 throw new IllegalStateException();
 
             if (!)
                 throw new UnsupportedOperationException();
             
             final ServletHandler handler = ServletContextHandler.this.getServletHandler();
             FilterHolder holder = handler.getFilter(filterName);
             if (holder == null)
             {
                 //new filter
                 holder = handler.newFilterHolder(..);
                 holder.setName(filterName);
                 holder.setFilter(filter);
                 handler.addFilter(holder);
                 return holder.getRegistration();
             }
             
             if (holder.getClassName()==null && holder.getHeldClass()==null)
             {
                 //preliminary filter registration completion
                 holder.setFilter(filter);
                 return holder.getRegistration();
             }
             else
                 return null//existing filter
         }
         
         /* ------------------------------------------------------------ */
        

Since:
servlet-api-3.0
 
         @Override
         public ServletRegistration.Dynamic addServlet(String servletNameClass<? extends ServletservletClass)
         {
             if (!isStarting())
                 throw new IllegalStateException();
             
             if (!)
                 throw new UnsupportedOperationException();
             
             final ServletHandler handler = ServletContextHandler.this.getServletHandler();
             ServletHolder holder = handler.getServlet(servletName);
             if (holder == null)
             {
                 //new servlet
                 holder = handler.newServletHolder(..);
                 holder.setName(servletName);
                 holder.setHeldClass(servletClass);
                 handler.addServlet(holder);
                 return dynamicHolderAdded(holder);
             }
 
             //complete a partial registration
             if (holder.getClassName()==null && holder.getHeldClass()==null)
             {
                 holder.setHeldClass(servletClass);
                 return holder.getRegistration();
             }
             else
                 return null//existing completed registration for servlet name      
         }
 
         /* ------------------------------------------------------------ */
        

Since:
servlet-api-3.0
 
         @Override
         public ServletRegistration.Dynamic addServlet(String servletNameString className)
         {
             if (!isStarting())
                 throw new IllegalStateException();
             
             if (!)
                 throw new UnsupportedOperationException();
 
 
             final ServletHandler handler = ServletContextHandler.this.getServletHandler();            
             ServletHolder holder = handler.getServlet(servletName);
             if (holder == null)
             {
                 //new servlet
                 holder = handler.newServletHolder(..);
                 holder.setName(servletName);
                 holder.setClassName(className);
                 handler.addServlet(holder);
                 return dynamicHolderAdded(holder);
             }
 
             //complete a partial registration
             if (holder.getClassName()==null && holder.getHeldClass()==null)
             {
                 holder.setClassName(className); 
                 return holder.getRegistration();
             }
             else
                 return null//existing completed registration for servlet name
         }
 
         /* ------------------------------------------------------------ */
        

Since:
servlet-api-3.0
        @Override
        public ServletRegistration.Dynamic addServlet(String servletNameServlet servlet)
        {
            if (!isStarting())
                throw new IllegalStateException();
            if (!)
                throw new UnsupportedOperationException();
            //TODO handle partial registrations
            
            final ServletHandler handler = ServletContextHandler.this.getServletHandler();
            ServletHolder holder = handler.getServlet(servletName);
            if (holder == null)
            {
                holder = handler.newServletHolder(..);
                holder.setName(servletName);
                holder.setServlet(servlet);
                handler.addServlet(holder);
                return dynamicHolderAdded(holder);
            }
            
            //complete a partial registration
            if (holder.getClassName()==null && holder.getHeldClass()==null)
            {
                holder.setServlet(servlet);
                return holder.getRegistration();
            }
            else
                return null//existing completed registration for servlet name
        }
        /* ------------------------------------------------------------ */
        @Override
        public boolean setInitParameter(String nameString value)
        {
            // TODO other started conditions
            if (!isStarting())
                throw new IllegalStateException();
            
            if (!)
                throw new UnsupportedOperationException();
            
            return super.setInitParameter(name,value);
        }
        /* ------------------------------------------------------------ */
        @Override
        public <T extends Filter> T createFilter(Class<T> cthrows ServletException
        {
            try
            {
                T f = c.newInstance();
                for (int i=.size()-1; i>=0; i--)
                {
                    Decorator decorator = .get(i);
                    f=decorator.decorateFilterInstance(f);
                }
                return f;
            }
            catch (InstantiationException e)
            {
                throw new ServletException(e);
            }
            catch (IllegalAccessException e)
            {
                throw new ServletException(e);
            }
        }
        /* ------------------------------------------------------------ */
        @Override
        public <T extends Servlet> T createServlet(Class<T> cthrows ServletException
        {
            try
            {
                T s = c.newInstance();
                for (int i=.size()-1; i>=0; i--)
                {
                    Decorator decorator = .get(i);
                    s=decorator.decorateServletInstance(s);
                }
                return s;
            }
            catch (InstantiationException e)
            {
                throw new ServletException(e);
            }
            catch (IllegalAccessException e)
            {
                throw new ServletException(e);
            }
        }
        @Override
        {
            if (!=null)
                return .getSessionManager().getDefaultSessionTrackingModes();
            return null;
        }
        @Override
        {
            if (!=null)
                return .getSessionManager().getEffectiveSessionTrackingModes();
            return null;
        }
        @Override
        public FilterRegistration getFilterRegistration(String filterName)
        {
            if (!)
                throw new UnsupportedOperationException();
            
            final FilterHolder holder=ServletContextHandler.this.getServletHandler().getFilter(filterName);
            return (holder==null)?null:holder.getRegistration();
        }
        @Override
        public Map<String, ? extends FilterRegistrationgetFilterRegistrations()
        {
            if (!)
                throw new UnsupportedOperationException();
            
            HashMap<StringFilterRegistrationregistrations = new HashMap<StringFilterRegistration>();
            ServletHandler handler=ServletContextHandler.this.getServletHandler();
            FilterHolder[] holders=handler.getFilters();
            if (holders!=null)
            {
                for (FilterHolder holder : holders)
                    registrations.put(holder.getName(),holder.getRegistration());
            }
            return registrations;
        }