Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   /*
    * Licensed to the Apache Software Foundation (ASF) under one or more
    * contributor license agreements.  See the NOTICE file distributed with
    * this work for additional information regarding copyright ownership.
    * The ASF licenses this file to You under the Apache License, Version 2.0
    * (the "License"); you may not use this file except in compliance with
    * the License.  You may obtain a copy of the License at
    * 
    *      http://www.apache.org/licenses/LICENSE-2.0
   * 
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  
  package org.apache.catalina.core;
  
  import static org.jboss.web.CatalinaMessages.MESSAGES;
  
  import java.util.HashMap;
  import java.util.HashSet;
  import java.util.Set;
  import java.util.Stack;
  
  
Standard implementation of the Wrapper interface that represents an individual servlet definition. No child Containers are allowed, and the parent Container must be a Context.

Author(s):
Craig R. McClanahan
Remy Maucherat
Version:
$Revision: 1729 $ $Date: 2011-05-31 12:00:57 +0200 (Tue, 31 May 2011) $
  
  public class StandardWrapper
      extends ContainerBase
      implements ServletConfigWrapperNotificationEmitter {
  
      protected static final String[] DEFAULT_SERVLET_METHODS = new String[] {
                                                      "GET""HEAD""POST" };
  
      // ----------------------------------------------------------- Constructors
  

    
Create a new StandardWrapper component with the default basic Valve.
  
      public StandardWrapper() {
  
          super();
          =new StandardWrapperValve();
          .setBasic();
           = new NotificationBroadcasterSupport();
  
      }
 
 
     // ----------------------------------------------------- Instance Variables
 
    
    
Async supported flag.
 
     protected boolean asyncSupported = false;
    
    
    
Dynamic flag.
 
     protected boolean dynamic = false;
    
    
    
Enabled flag.
 
     protected boolean enabled = true;
    
    
    
The date and time at which this servlet will become available (in milliseconds since the epoch), or zero if the servlet is available. If this value equals Long.MAX_VALUE, the unavailability of this servlet is considered permanent.
 
     protected long available = 0L;
    
    
The broadcaster that sends j2ee notifications.
 
     protected NotificationBroadcasterSupport broadcaster = null;
    
    
The count of allocations that are currently active for STM servlets.
 
     protected int countAllocated = 0;

    
    
Description.
 
     protected String description = null;
    

    
The facade associated with this wrapper.
 
     protected StandardWrapperFacade facade =
         new StandardWrapperFacade(this);


    
The descriptive information string for this implementation.
 
     protected static final String info =
         "org.apache.catalina.core.StandardWrapper/1.0";


    
The (single) initialized instance of this servlet.
 
     protected Servlet instance = null;


    
The (single) initialized instance of this servlet.
 
     protected Servlet servletInstance = null;


    
The support object for our instance listeners.
 
     protected InstanceSupport instanceSupport = new InstanceSupport(this);


    
The context-relative URI of the JSP file for this servlet.
 
     protected String jspFile = null;


    
The load-on-startup order value (negative value means load on first call) for this servlet.
 
     protected int loadOnStartup = -1;


    
The multipart config annotation configured on this servlet.
 
     protected Multipart multipartConfig = null;


    
Mappings associated with the wrapper.
 
     protected ArrayList mappings = new ArrayList();


    
The initialization parameters for this servlet, keyed by parameter name.
 
     protected HashMap parameters = new HashMap();


    
The security role references for this servlet, keyed by role name used in the servlet. The corresponding value is the role name of the web application itself.
 
     protected HashMap references = new HashMap();


    
The run-as identity for this servlet.
 
     protected String runAs = null;
    
    
    
Associated ServletSecurity.
 
     protected ServletSecurityElement servletSecurity = null;
    
    
    
The notification sequence number.
 
     protected long sequenceNumber = 0;

    
The fully qualified servlet class name for this servlet.
 
     protected String servletClass = null;


    
Does this servlet implement the SingleThreadModel interface?
 
     protected boolean singleThreadModel = false;


    
Are we unloading our servlet instance at the moment?
 
     protected boolean unloading = false;


    
Maximum number of STM instances.
 
     protected int maxInstances = 20;


    
Number of instances currently loaded for a STM servlet.
 
     protected int nInstances = 0;


    
Stack containing the STM instances.
 
     protected Stack instancePool = null;

    
    
Wait time for servlet unload in ms.
 
     protected long unloadDelay = 2000;
    

    
True if this StandardWrapper is for the JspServlet
 
     protected boolean isJspServlet;


    
The ObjectName of the JSP monitoring mbean
 
     protected ObjectName jspMonitorON;
 
 
     // To support jmx attributes
     protected StandardWrapperValve swValve;
     protected long loadTime=0;
     protected int classLoadTime=0;
    
    
Static class array used when the SecurityManager is turned on and Servlet.init is invoked.
 
     protected static Class[] classType = new Class[]{ServletConfig.class};
    
    
    
Static class array used when the SecurityManager is turned on and Servlet.service is invoked.
                                                  
     protected static Class[] classTypeUsedInService = new Class[]{
                                                          ServletRequest.class,
                                                          ServletResponse.class};
     
 
     // ------------------------------------------------------------- Properties
 

    
Return the async supported value.
 
     public boolean getAsyncSupported() {
         return ;
     }


    
Set the async supported value.

Parameters:
value New async supported value
 
     public void setAsyncSupported(boolean value) {
         boolean oldAsyncSupported = this.;
         this. = value;
         .firePropertyChange("asyncSupported"oldAsyncSupported);
     }


    
Return the Servlet description.
 
     public String getDescription() {
         return ;
     }


    
Set the description.
 
     public void setDescription(String description) {
         String oldDescription = this.;
         this. = description;
         .firePropertyChange("description"oldDescriptiondescription);
     }
 
 
     public boolean isDynamic() {
         return ;
     }
 
 
     public void setDynamic(boolean dynamic) {
         this. = dynamic;
         if (dynamic) {
             // Change the facade (normally, this happens when the Wrapper is created)
              = new StandardWrapperFacade.Dynamic(this);
         }
     }


    
Return the enabled value.
 
     public boolean getEnabled() {
         return ;
     }


    
Set the enabled value.

Parameters:
value New enabled value
 
     public void setEnabled(boolean value) {
         boolean oldEnabled = this.;
         this. = value;
         .firePropertyChange("enabled"oldEnabled);
     }


    
Return the available date/time for this servlet, in milliseconds since the epoch. If this date/time is Long.MAX_VALUE, it is considered to mean that unavailability is permanent and any request for this servlet will return an SC_NOT_FOUND error. If this date/time is in the future, any request for this servlet will return an SC_SERVICE_UNAVAILABLE error. If it is zero, the servlet is currently available.
 
     public long getAvailable() {
 
         return (this.);
 
     }


    
Set the available date/time for this servlet, in milliseconds since the epoch. If this date/time is Long.MAX_VALUE, it is considered to mean that unavailability is permanent and any request for this servlet will return an SC_NOT_FOUND error. If this date/time is in the future, any request for this servlet will return an SC_SERVICE_UNAVAILABLE error.

Parameters:
available The new available date/time
 
     public void setAvailable(long available) {
 
         long oldAvailable = this.;
         if (available > System.currentTimeMillis())
             this. = available;
         else
             this. = 0L;
         .firePropertyChange("available"new Long(oldAvailable),
                                    new Long(this.));
 
     }


    
Return the number of active allocations of this servlet.
 
     public int getCountAllocated() {
 
         return (this.);
 
     }
 
 
     public String getEngineName() {
         return ((StandardContext)getParent()).getEngineName();
     }


    
Return descriptive information about this Container implementation and the corresponding version number, in the format <description>/<version>.
 
     public String getInfo() {
 
         return ();
 
     }


    
Return the InstanceSupport object for this Wrapper instance.
 
     public InstanceSupport getInstanceSupport() {
 
         return (this.);
 
     }


    
Return the context-relative URI of the JSP file for this servlet.
 
     public String getJspFile() {
 
         return (this.);
 
     }


    
Set the context-relative URI of the JSP file for this servlet.

Parameters:
jspFile JSP file URI
 
     public void setJspFile(String jspFile) {
 
         String oldJspFile = this.;
         this. = jspFile;
         .firePropertyChange("jspFile"oldJspFilethis.);
 
         // Each jsp-file needs to be represented by its own JspServlet and
         // corresponding JspMonitoring mbean, because it may be initialized
         // with its own init params
          = true;
 
     }


    
Return the load-on-startup order value (negative value means load on first call).
 
     public int getLoadOnStartup() {
 
         if ( &&  < 0) {
             /*
              * JspServlet must always be preloaded, because its instance is
              * used during registerJMX (when registering the JSP
              * monitoring mbean)
              */
              return .;
         } else {
             return (this.);
         }
     }


    
Set the load-on-startup order value (negative value means load on first call).

Parameters:
value New load-on-startup value
 
     public void setLoadOnStartup(int value) {
 
         int oldLoadOnStartup = this.;
         this. = value;
         .firePropertyChange("loadOnStartup",
                                    new Integer(oldLoadOnStartup),
                                    new Integer(this.));
 
     }



    
Set the load-on-startup order value from a (possibly null) string. Per the specification, any missing or non-numeric value is converted to a zero, so that this servlet will still be loaded at startup time, but in an arbitrary order.

Parameters:
value New load-on-startup value
 
     public void setLoadOnStartupString(String value) {
 
         try {
             setLoadOnStartup(Integer.parseInt(value));
         } catch (NumberFormatException e) {
             setLoadOnStartup(0);
         }
     }
 
     public String getLoadOnStartupString() {
         return Integer.toStringgetLoadOnStartup());
     }


    
Multipart configuration for this Servlet.
 
     public Multipart getMultipartConfig() {
         return ;
     }
    

    
Set the multipart configuration for this Servlet.
 
     public void setMultipartConfig(Multipart multipartConfig) {
         this. = multipartConfig;
     }
    

    
Return maximum number of instances that will be allocated when a single thread model servlet is used.
 
     public int getMaxInstances() {
 
         return (this.);
 
     }


    
Set the maximum number of instances that will be allocated when a single thread model servlet is used.

Parameters:
maxInstances New value of maxInstances
 
     public void setMaxInstances(int maxInstances) {
 
         int oldMaxInstances = this.;
         this. = maxInstances;
         .firePropertyChange("maxInstances"oldMaxInstances,
                                    this.);
 
     }


    
Set the parent Container of this Wrapper, but only if it is a Context.

Parameters:
container Proposed parent Container
 
     public void setParent(Container container) {
 
         if ((container != null) &&
             !(container instanceof Context))
             throw .wrapperParentMustBeContext();
         if (container instanceof StandardContext) {
              = ((StandardContext)container).getUnloadDelay();
         }
         super.setParent(container);
 
     }


    
Return the run-as identity for this servlet.
 
     public String getRunAs() {
 
         return (this.);
 
     }


    
Set the run-as identity for this servlet.

Parameters:
runAs New run-as identity value
 
     public void setRunAs(String runAs) {
 
         String oldRunAs = this.;
         this. = runAs;
         .firePropertyChange("runAs"oldRunAsthis.);
 
     }

    
    
Get an associated ServletSecurity, if any.
 
         return ;
     }
    

    
Set an associated ServletSecurity on mappings which are currently associated with the Servlet. This will not set security on patters which are currently defined in a security constraint.

Returns:
the set of patterns for which the servlet security will not be defined
 
     public Set<StringsetServletSecurity(ServletSecurityElement servletSecurity) {
         ServletSecurityElement oldServletSecurity = this.;
         this. = servletSecurity;
         .firePropertyChange("servletSecurity"oldServletSecuritythis.);
         // Now find to which mappings this servlet security will apply, and return the list
         // for which is will not apply
         Set<StringignoredPatterns = new HashSet<String>();
         HashSet<StringcurrentMappings = new HashSet<String>();
         for (String mapping : findMappings()) {
             currentMappings.add(mapping);
         }
         SecurityConstraint[] constraints = ((ContextgetParent()).findConstraints();
         for (SecurityConstraint constraint : constraints) {
             for (SecurityCollection collection : constraint.findCollections()) {
                 for (String pattern : collection.findPatterns()) {
                     if (currentMappings.contains(pattern)) {
                         ignoredPatterns.add(pattern);
                     }
                 }
             }
         }
         return ignoredPatterns;
     }
    
    
    
Return the fully qualified servlet class name for this servlet.
 
     public String getServletClass() {
 
         return (this.);
 
     }


    
Set the fully qualified servlet class name for this servlet.

Parameters:
servletClass Servlet class name
 
     public void setServletClass(String servletClass) {
 
         String oldServletClass = this.;
         this. = servletClass;
         .firePropertyChange("servletClass"oldServletClass,
                                    this.);
         if (..equals(servletClass)) {
              = true;
         }
     }



    
Set the name of this servlet. This is an alias for the normal Container.setName() method, and complements the getServletName() method required by the ServletConfig interface.

Parameters:
name The new name of this servlet
 
     public void setServletName(String name) {
 
         setName(name);
 
     }


    
Return true if the servlet class represented by this component implements the SingleThreadModel interface.
 
     public boolean isSingleThreadModel() {
 
         try {
             loadServlet();
         } catch (Throwable t) {
             ;
         }
         return ();
 
     }


    
Is this servlet currently unavailable?
 
     public boolean isUnavailable() {
 
         if ( == 0L)
             return (false);
         else if ( <= System.currentTimeMillis()) {
              = 0L;
             return (false);
         } else
             return (true);
 
     }

    
    
Get the facade ServletRegistration.
 
     public ServletRegistration getFacade() {
         return ;
     }
    

    
Gets the names of the methods supported by the underlying servlet. This is the same set of methods included in the Allow response header in response to an OPTIONS request method processed by the underlying servlet.

Returns:
Array of names of the methods supported by the underlying servlet
 
     public String[] getServletMethods() throws ServletException {
 
         Class servletClazz = loadServlet().getClass();
         if (!javax.servlet.http.HttpServlet.class.isAssignableFrom(
                                                         servletClazz)) {
             return ;
         }
 
         HashSet allow = new HashSet();
         allow.add("TRACE");
         allow.add("OPTIONS");
 	
         Method[] methods = getAllDeclaredMethods(servletClazz);
         for (int i=0; methods != null && i<methods.lengthi++) {
             Method m = methods[i];
 	    
             if (m.getName().equals("doGet")) {
                 allow.add("GET");
                 allow.add("HEAD");
             } else if (m.getName().equals("doPost")) {
                 allow.add("POST");
             } else if (m.getName().equals("doPut")) {
                 allow.add("PUT");
             } else if (m.getName().equals("doDelete")) {
                 allow.add("DELETE");
             }
         }
 
         String[] methodNames = new String[allow.size()];
         return (String[]) allow.toArray(methodNames);
 
     }
 
 
     // --------------------------------------------------------- Public Methods
 

    
Execute a periodic task, such as reloading, etc. This method will be invoked inside the classloading context of this container. Unexpected throwables will be caught and logged.
 
     public void backgroundProcess() {
         super.backgroundProcess();
         
         if (!)
             return;
         
         if (getServlet() != null && (getServlet() instanceof PeriodicEventListener)) {
             ((PeriodicEventListenergetServlet()).periodicEvent();
         }
     }
    
    
    
Extract the root cause from a servlet exception.

Parameters:
e The servlet exception
 
     public static Throwable getRootCause(ServletException e) {
         Throwable rootCause = e;
         Throwable rootCauseCheck = null;
         // Extra aggressive rootCause finding
         int loops = 0;
         do {
             loops++;
             rootCauseCheck = rootCause.getCause();
             if (rootCauseCheck != null)
                 rootCause = rootCauseCheck;
         } while (rootCauseCheck != null && (loops < 20));
         return rootCause;
     }


    
Refuse to add a child Container, because Wrappers are the lowest level of the Container hierarchy.

Parameters:
child Child container to be added
 
     public void addChild(Container child) {
 
         throw .wrapperHasNoChild();
 
     }


    
Add a new servlet initialization parameter for this servlet.

Parameters:
name Name of this initialization parameter to add
value Value of this initialization parameter to add
 
     public void addInitParameter(String nameString value) {
 
         if (!.containsKey(name))
             .put(namevalue);
         fireContainerEvent("addInitParameter"name);
 
     }


    
Add a new listener interested in InstanceEvents.

Parameters:
listener The new listener
 
     public void addInstanceListener(InstanceListener listener) {
 
         .addInstanceListener(listener);
 
     }


    
Add a mapping associated with the Wrapper.

Parameters:
mapping The new wrapper mapping
 
     public void addMapping(String mapping) {
 
         synchronized () {
             .add(mapping);
         }
         fireContainerEvent("addMapping"mapping);
 
     }


    
Add a new security role reference record to the set of records for this servlet.

Parameters:
name Role name used within this servlet
link Role name used within the web application
 
     public void addSecurityReference(String nameString link) {
         .put(namelink);
         fireContainerEvent("addSecurityReference"name);
     }


    
Return the associated servlet instance.
 
     public Servlet getServlet() {
         return ( != null) ?  : ;
     }
    
    
    
Set the associated servlet instance.
 
     public void setServlet(Servlet servlet) {
          = servlet;
     }
    
    
    
Allocate an initialized instance of this Servlet that is ready to have its service() method called. If the servlet class does not implement SingleThreadModel, the (only) initialized instance may be returned immediately. If the servlet class implements SingleThreadModel, the Wrapper implementation must ensure that this instance is not allocated again until it is deallocated by a call to deallocate().

Throws:
javax.servlet.ServletException if the servlet init() method threw an exception
javax.servlet.ServletException if a loading error occurs
 
     public Servlet allocate() throws ServletException {
 
         // If we are currently unloading this servlet, throw an exception
         if ()
             throw new ServletException
               (.cannotAllocateServletWhileUnloading(getName()));
 
         // Load and initialize our instance if necessary
         if ( == null) {
             synchronized (this) {
                 if ( == null) {
                     try {
                          = loadServlet();
                     } catch (ServletException e) {
                         throw e;
                     } catch (Throwable e) {
                         throw new ServletException(.cannotAllocateServletInstance(), e);
                     }
                 }
             }
         }
 
         if (!) {
             return ();
         }
 
         synchronized () {
 
             while ( >= ) {
                 // Allocate a new instance if possible, or else wait
                 if ( < ) {
                     try {
                         .push(loadServlet());
                         ++;
                     } catch (ServletException e) {
                         throw e;
                     } catch (Throwable e) {
                         throw new ServletException
                             (.cannotAllocateServletInstance(), e);
                     }
                 } else {
                     try {
                         .wait();
                     } catch (InterruptedException e) {
                         ;
                     }
                 }
             }
             ++;
             return (Servlet.pop();
 
         }
 
     }


    
Return this previously allocated servlet to the pool of available instances. If this servlet class does not implement SingleThreadModel, no action is actually required.

Parameters:
servlet The servlet to be returned
Throws:
javax.servlet.ServletException if a deallocation error occurs
    public void deallocate(Servlet servletthrows ServletException {
        // If not SingleThreadModel, no action is required
        if (!) {
            return;
        }
        // Unlock and free this instance
        synchronized () {
            --;
            .push(servlet);
            .notify();
        }
    }


    
Return the value for the specified initialization parameter name, if any; otherwise return null.

Parameters:
name Name of the requested initialization parameter
    public String findInitParameter(String name) {
        return ((String.get(name));
    }


    
Return the names of all defined initialization parameters for this servlet.
    public String[] findInitParameters() {
        String results[] = new String[.size()];
        return ((String[]) .keySet().toArray(results));
    }


    
Return the mappings associated with this wrapper.
    public String[] findMappings() {
        synchronized () {
            return (String[]) .toArray(new String[.size()]);
        }
    }


    
Return the security role link for the specified security role reference name, if any; otherwise return null.

Parameters:
name Security role reference used within this servlet
    public String findSecurityReference(String name) {
        return ((String.get(name));
    }


    
Return the set of security role reference names associated with this servlet, if any; otherwise return a zero-length array.
    public String[] findSecurityReferences() {
        String results[] = new String[.size()];
        return ((String[]) .keySet().toArray(results));
    }


    
FIXME: Fooling introspection ...
    public Wrapper findMappingObject() {
        return (WrappergetMappingObject();
    }


    
Load and initialize an instance of this servlet, if there is not already at least one initialized instance. This can be used, for example, to load servlets that are marked in the deployment descriptor to be loaded at server startup time.

IMPLEMENTATION NOTE: Servlets whose classnames begin with org.apache.catalina. (so-called "container" servlets) are loaded by the same classloader that loaded this class, rather than the classloader for the current web application. This gives such classes access to Catalina internals, which are prevented for classes loaded for web applications.

Throws:
javax.servlet.ServletException if the servlet init() method threw an exception
javax.servlet.ServletException if some other loading problem occurs
    public synchronized void load() throws ServletException {
         = loadServlet();
    }


    
Load and initialize an instance of this servlet, if there is not already at least one initialized instance. This can be used, for example, to load servlets that are marked in the deployment descriptor to be loaded at server startup time.
    public synchronized Servlet loadServlet() throws ServletException {
        // Nothing to do if we already have an instance or an instance pool
        if (! && ( != null))
            return ;
        Throwable throwable = null;
        Servlet servlet;
            long t1=System.currentTimeMillis();
            // If this "servlet" is really a JSP file, get the right class.
            // HOLD YOUR NOSE - this is a kludge that avoids having to do special
            // case Catalina-specific code in Jasper - it also requires that the
            // servlet path be replaced by the <jsp-file> element content in
            // order to be completely effective
            String actualClass = ;
            if ((actualClass == null) && ( != null)) {
                Wrapper jspWrapper = (Wrapper)
                    ((ContextgetParent()).findChild(.);
                if (jspWrapper != null) {
                    actualClass = jspWrapper.getServletClass();
                    // Merge init parameters
                    String paramNames[] = jspWrapper.findInitParameters();
                    for (int i = 0; i < paramNames.lengthi++) {
                        if (.get(paramNames[i]) == null) {
                            .put
                                (paramNames[i], 
                                 jspWrapper.findInitParameter(paramNames[i]));
                        }
                    }
                }
            }
            // Complain if no servlet class has been specified
            if (actualClass == null) {
                unavailable(null);
                throw new ServletException
                    (.noClassSpecifiedForServlet(getName()));
            }
            if ( == null) {
                InstanceManager instanceManager = ((ContextgetParent()).getInstanceManager();
                try {
                    servlet = (ServletinstanceManager.newInstance(actualClass);
                } catch (ClassCastException e) {
                    unavailable(null);
                    // Restore the context ClassLoader
                    throw new ServletException
                        (.specifiedClassIsNotServlet(actualClass), e);
                } catch (Throwable e) {
                    unavailable(null);
                    ..errorInstantiatingServletClass(actualClasse);
                    // Restore the context ClassLoader
                    throw new ServletException
                        (.errorInstantiatingServletClass(actualClass), e);
                }
            } else {
                servlet = ;
                 = null;
            }
            // Special handling for ContainerServlet instances
            if ((servlet instanceof ContainerServlet) &&
                  (isContainerProvidedServlet(actualClass) ||
                    ((Context)getParent()).getPrivileged() )) {
                ((ContainerServletservlet).setWrapper(this);
            }
            =(int) (System.currentTimeMillis() -t1);
            // Call the initialization method of this servlet
            try {
                                                  servlet);
                if.) {
                    Object[] args = new Object[]{((ServletConfig))};
                    SecurityUtil.doAsPrivilege("init",
                                               servlet,
                                               ,
                                               args);
                    args = null;
                } else {
                    servlet.init();
                }
                // Invoke jspInit on JSP pages
                if (( >= 0) && ( != null)) {
                    // Invoking jspInit
                    DummyRequest req = new DummyRequest();
                    req.setServletPath();
                    req.setQueryString("jsp_precompile=true");
                    DummyResponse res = new DummyResponse();
                    if.) {
                        Object[] args = new Object[]{reqres};
                        SecurityUtil.doAsPrivilege("service",
                                                   servlet,
                                                   ,
                                                   args);
                        args = null;
                    } else {
                        servlet.service(reqres);
                    }
                }
            } catch (UnavailableException f) {
                throwable = f;
                unavailable(f);
                throw f;
            } catch (ServletException f) {
                throwable = f;
                // If the servlet wanted to be unavailable it would have
                // said so, so do not call unavailable(null).
                throw f;
            } catch (Throwable f) {
                throwable = f;
                // If the servlet wanted to be unavailable it would have
                // said so, so do not call unavailable(null).
                throw new ServletException
                    (.errorInitializingServlet(getName()), f);
            } finally {
                        servletthrowable);
            }
            // Register our newly initialized instance
             = servlet instanceof SingleThreadModel;
            if () {
                if ( == null)
                     = new Stack();
            }
            fireContainerEvent("load"this);
            =System.currentTimeMillis() -t1;
        return servlet;
    }


    
Remove the specified initialization parameter from this servlet.

Parameters:
name Name of the initialization parameter to remove
    public void removeInitParameter(String name) {
        .remove(name);
        fireContainerEvent("removeInitParameter"name);
    }


    
Remove a listener no longer interested in InstanceEvents.

Parameters:
listener The listener to remove
    public void removeInstanceListener(InstanceListener listener) {
        .removeInstanceListener(listener);
    }


    
Remove a mapping associated with the wrapper.

Parameters:
mapping The pattern to remove
    public void removeMapping(String mapping) {
        synchronized () {
            .remove(mapping);
        }
        fireContainerEvent("removeMapping"mapping);
    }


    
Remove any security role reference for the specified role name.

Parameters:
name Security role used within this servlet to be removed
    public void removeSecurityReference(String name) {
        .remove(name);
        fireContainerEvent("removeSecurityReference"name);
    }


    
Return a String representation of this component.
    public String toString() {
        StringBuilder sb = new StringBuilder();
        if (getParent() != null) {
            sb.append(getParent().toString());
            sb.append(".");
        }
        sb.append("StandardWrapper[");
        sb.append(getName());
        sb.append("]");
        return (sb.toString());
    }


    
Process an UnavailableException, marking this servlet as unavailable for the specified amount of time.

Parameters:
unavailable The exception that occurred, or null to mark this servlet as permanently unavailable
    public void unavailable(UnavailableException unavailable) {
        if (unavailable == null)
            setAvailable(.);
        else if (unavailable.isPermanent())
            setAvailable(.);
        else {
            int unavailableSeconds = unavailable.getUnavailableSeconds();
            if (unavailableSeconds <= 0)
                unavailableSeconds = 60;        // Arbitrary default
            setAvailable(System.currentTimeMillis() +
                         (unavailableSeconds * 1000L));
        }
    }


    
Unload all initialized instances of this servlet, after calling the destroy() method for each instance. This can be used, for example, prior to shutting down the entire servlet engine, or prior to reloading all of the classes from the Loader associated with our Loader's repository.

Throws:
javax.servlet.ServletException if an exception is thrown by the destroy() method
    public synchronized void unload() throws ServletException {
        // Nothing to do if we have never loaded the instance
        if (! && ( == null))
            return;
         = true;
        PrintStream out = .;
        // Call the servlet destroy() method
        try {
            .fireInstanceEvent
              (.);
            if.) {
                SecurityUtil.doAsPrivilege("destroy",
                                           );
                SecurityUtil.remove();                           
            } else {
                .destroy();
            }
            
            .fireInstanceEvent
              (.);
            // Annotation processing
        } catch (Throwable t) {
            .fireInstanceEvent
              (.t);
             = null;
             = null;
             = 0;
            fireContainerEvent("unload"this);
             = false;
            throw new ServletException(.errorDestroyingServlet(getName()), t);
        }
        // Deregister the destroyed instance
         = null;
        if ( && ( != null)) {
            try {
                while (!.isEmpty()) {
                    Servlet s = (Servlet.pop();
                    if (.) {
                        SecurityUtil.doAsPrivilege("destroy"s);
                        SecurityUtil.remove();                           
                    } else {
                        s.destroy();
                    }
                    // Annotation processing
                    ((ContextgetParent()).getInstanceManager().destroyInstance(s);
                }
            } catch (Throwable t) {
                 = null;
                 = 0;
                 = false;
                fireContainerEvent("unload"this);
                throw new ServletException(.errorDestroyingServlet(getName()), t);
            }
             = null;
             = 0;
        }
         = false;
         = false;
        fireContainerEvent("unload"this);
    }
    // -------------------------------------------------- ServletConfig Methods


    
Return the initialization parameter value for the specified name, if any; otherwise return null.

Parameters:
name Name of the initialization parameter to retrieve
    public String getInitParameter(String name) {
        return (findInitParameter(name));
    }


    
Return the set of initialization parameter names defined for this servlet. If none are defined, an empty Enumeration is returned.
        return (new Enumerator(.keySet()));
    }


    
Return the servlet context with which this servlet is associated.
        if ( == null)
            return (null);
        else if (!( instanceof Context))
            return (null);
        else
            return (((Context).getServletContext());
    }


    
Return the name of this servlet.
    public String getServletName() {
        return (getName());
    }
    public long getProcessingTime() {
        return .getProcessingTime();
    }
    public void setProcessingTime(long processingTime) {
        .setProcessingTime(processingTime);
    }
    public long getMaxTime() {
        return .getMaxTime();
    }
    public void setMaxTime(long maxTime) {
        .setMaxTime(maxTime);
    }
    public long getMinTime() {
        return .getMinTime();
    }
    public void setMinTime(long minTime) {
        .setMinTime(minTime);
    }
    public int getRequestCount() {
        return .getRequestCount();
    }
    public void setRequestCount(int requestCount) {
        .setRequestCount(requestCount);
    }
    public int getErrorCount() {
        return .getErrorCount();
    }
    public void setErrorCount(int errorCount) {
           .setErrorCount(errorCount);
    }

    
Increment the error count used for monitoring.
    public void incrementErrorCount(){
    }
    public long getLoadTime() {
        return ;
    }
    public void setLoadTime(long loadTime) {
        this. = loadTime;
    }
    public int getClassLoadTime() {
        return ;
    }
    // -------------------------------------------------------- Package Methods
    // -------------------------------------------------------- protected Methods


    
Add a default Mapper implementation if none have been configured explicitly.

Parameters:
mapperClass Java class name of the default Mapper