Class StandardWrapper

  • All Implemented Interfaces:
    jakarta.servlet.ServletConfig, Container, Lifecycle, Pipeline, Wrapper

    public class StandardWrapper
    extends ContainerBase
    implements jakarta.servlet.ServletConfig, Wrapper
    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.
    Version:
    $Revision: 1.12.2.1 $ $Date: 2008/04/17 18:37:09 $
    Author:
    Craig R. McClanahan, Remy Maucherat
    • Field Detail

      • instanceInitialized

        protected volatile boolean instanceInitialized
        Flag that indicates if this instance has been initialized
      • unloadDelay

        protected long unloadDelay
        Wait time for servlet unload in ms.
    • Constructor Detail

      • StandardWrapper

        public StandardWrapper()
        Create a new StandardWrapper component with the default basic Valve.
    • Method Detail

      • getAvailable

        public long getAvailable()
        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.
        Specified by:
        getAvailable in interface Wrapper
        Returns:
      • setAvailable

        public void setAvailable​(long available)
        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.
        Specified by:
        setAvailable in interface Wrapper
        Parameters:
        available - The new available date/time
      • getCountAllocated

        public int getCountAllocated()
        Return the number of active allocations of this servlet, even if they are all for the same instance (as will be true for servlets that do not implement SingleThreadModel.
        Returns:
      • getDebug

        public int getDebug()
        Return the debugging detail level for this component.
        Overrides:
        getDebug in class ContainerBase
        Returns:
      • setDebug

        public void setDebug​(int debug)
        Set the debugging detail level for this component.
        Overrides:
        setDebug in class ContainerBase
        Parameters:
        debug - The new debugging detail level
      • getEngineName

        public String getEngineName()
      • getInfo

        public String getInfo()
        Return descriptive information about this Container implementation and the corresponding version number, in the format <description>/<version>.
        Specified by:
        getInfo in interface Container
        Overrides:
        getInfo in class ContainerBase
        Returns:
      • getInstanceSupport

        public InstanceSupport getInstanceSupport()
        Return the InstanceSupport object for this Wrapper instance.
        Returns:
      • getJspFile

        public String getJspFile()
        Return the context-relative URI of the JSP file for this servlet.
        Specified by:
        getJspFile in interface Wrapper
        Returns:
      • setJspFile

        public void setJspFile​(String jspFile)
        Set the context-relative URI of the JSP file for this servlet.
        Specified by:
        setJspFile in interface Wrapper
        Parameters:
        jspFile - JSP file URI
      • getLoadOnStartup

        public int getLoadOnStartup()
        Return the load-on-startup order value (negative value means load on first call).
        Specified by:
        getLoadOnStartup in interface Wrapper
        Returns:
      • setLoadOnStartup

        public void setLoadOnStartup​(int value)
        Set the load-on-startup order value (negative value means load on first call).
        Specified by:
        setLoadOnStartup in interface Wrapper
        Parameters:
        value - New load-on-startup value
      • setLoadOnStartupString

        public void setLoadOnStartupString​(String value)
        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
      • getLoadOnStartupString

        public String getLoadOnStartupString()
      • setDescription

        public void setDescription​(String description)
        Sets the description of this servlet.
        Specified by:
        setDescription in interface Wrapper
        Parameters:
        description -
      • getDescription

        public String getDescription()
        Gets the description of this servlet.
        Specified by:
        getDescription in interface Wrapper
        Returns:
      • getMaxInstances

        public int getMaxInstances()
        Return maximum number of instances that will be allocated when a single thread model servlet is used.
      • setMaxInstances

        public void setMaxInstances​(int maxInstances)
        Set the maximum number of instances that will be allocated when a single thread model servlet is used.
        Parameters:
        maxInstances - New value of maxInstances
      • setParent

        public void setParent​(Container container)
        Set the parent Container of this Wrapper, but only if it is a Context.
        Specified by:
        setParent in interface Container
        Overrides:
        setParent in class ContainerBase
        Parameters:
        container - Proposed parent Container
      • getRunAs

        public String getRunAs()
        Return the run-as identity for this servlet.
        Specified by:
        getRunAs in interface Wrapper
        Returns:
      • setRunAs

        public void setRunAs​(String runAs)
        Set the run-as identity for this servlet.
        Specified by:
        setRunAs in interface Wrapper
        Parameters:
        runAs - New run-as identity value
      • setIsAsyncSupported

        public void setIsAsyncSupported​(boolean isAsyncSupported)
        Marks the wrapped servlet as supporting async operations or not.
        Specified by:
        setIsAsyncSupported in interface Wrapper
        Parameters:
        isAsyncSupported - true if the wrapped servlet supports async mode, false otherwise
      • isAsyncSupported

        public boolean isAsyncSupported()
        Checks if the wrapped servlet has been annotated or flagged in the deployment descriptor as being able to support asynchronous operations.
        Specified by:
        isAsyncSupported in interface Wrapper
        Returns:
        true if the wrapped servlet supports async operations, and false otherwise
      • getServletClassName

        public String getServletClassName()
        Return the fully qualified servlet class name for this servlet.
        Specified by:
        getServletClassName in interface Wrapper
        Returns:
      • setServletClassName

        public void setServletClassName​(String className)
        Set the fully qualified servlet class name for this servlet.
        Specified by:
        setServletClassName in interface Wrapper
        Parameters:
        className - Servlet class name
      • getServletClass

        public Class<? extends jakarta.servlet.Servlet> getServletClass()
        Returns:
        the servlet class, or null if the servlet class has not been loaded yet
      • setServletClass

        public void setServletClass​(Class<? extends jakarta.servlet.Servlet> clazz)
        Sets the class object from which this servlet will be instantiated.
        Specified by:
        setServletClass in interface Wrapper
        Parameters:
        clazz - The class object from which this servlet will be instantiated
      • getServlet

        public jakarta.servlet.Servlet getServlet()
        Returns:
        the servlet instance, or null if the servlet has not yet been instantiated
      • setServlet

        public void setServlet​(jakarta.servlet.Servlet instance)
        Sets the servlet instance for this wrapper.
        Parameters:
        instance - the servlet instance
      • setServletName

        public void setServletName​(String name)
        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
      • isUnavailable

        public boolean isUnavailable()
        Is this servlet currently unavailable?
        Specified by:
        isUnavailable in interface Wrapper
        Returns:
      • getServletMethods

        public String[] getServletMethods()
                                   throws jakarta.servlet.ServletException
        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.
        Specified by:
        getServletMethods in interface Wrapper
        Returns:
        Array of names of the methods supported by the underlying servlet
        Throws:
        jakarta.servlet.ServletException
      • isMultipartConfigured

        public boolean isMultipartConfigured()
      • setMultipartLocation

        public void setMultipartLocation​(String location)
        Sets the multipart location
        Specified by:
        setMultipartLocation in interface Wrapper
        Parameters:
        location -
      • setMultipartMaxFileSize

        public void setMultipartMaxFileSize​(long maxFileSize)
        Sets the multipart max-file-size
        Specified by:
        setMultipartMaxFileSize in interface Wrapper
        Parameters:
        maxFileSize -
      • getMultipartMaxFileSize

        public long getMultipartMaxFileSize()
        Gets the multipart max-file-size
        Specified by:
        getMultipartMaxFileSize in interface Wrapper
        Returns:
      • setMultipartMaxRequestSize

        public void setMultipartMaxRequestSize​(long maxRequestSize)
        Sets the multipart max-request-size
        Specified by:
        setMultipartMaxRequestSize in interface Wrapper
        Parameters:
        maxRequestSize -
      • getMultipartMaxRequestSize

        public long getMultipartMaxRequestSize()
        Gets the multipart max-request-Size
        Specified by:
        getMultipartMaxRequestSize in interface Wrapper
        Returns:
      • setMultipartFileSizeThreshold

        public void setMultipartFileSizeThreshold​(int fileSizeThreshold)
        Sets the multipart file-size-threshold
        Specified by:
        setMultipartFileSizeThreshold in interface Wrapper
        Parameters:
        fileSizeThreshold -
      • getMultipartFileSizeThreshold

        public int getMultipartFileSizeThreshold()
        Gets the multipart file-size-threshol
        Specified by:
        getMultipartFileSizeThreshold in interface Wrapper
        Returns:
      • isOSGi

        protected boolean isOSGi()
        Returns whether this is running in an OSGi context
        Returns:
      • setOSGi

        protected void setOSGi​(boolean osgi)
        Set whether this is being used in an OSGi context
        Parameters:
        osgi -
      • addValve

        public void addValve​(GlassFishValve valve)
        Description copied from class: ContainerBase
        Add a new Valve to the end of the pipeline associated with this Container. Prior to adding the Valve, the Valve's setContainer method must be called, with this Container as an argument. The method may throw an IllegalArgumentException if this Valve chooses not to be associated with this Container, or IllegalStateException if it is already associated with a different Container.
        Specified by:
        addValve in interface Pipeline
        Overrides:
        addValve in class ContainerBase
        Parameters:
        valve - Valve to be added
      • getRootCause

        public static Throwable getRootCause​(jakarta.servlet.ServletException e)
        Extract the root cause from a servlet exception.
        Parameters:
        e - The servlet exception
      • addChild

        public void addChild​(Container child)
        Refuse to add a child Container, because Wrappers are the lowest level of the Container hierarchy.
        Specified by:
        addChild in interface Container
        Overrides:
        addChild in class ContainerBase
        Parameters:
        child - Child container to be added
      • addInitParameter

        public void addInitParameter​(String name,
                                     String value)
        Adds the initialization parameter with the given name and value to this servlet.
        Specified by:
        addInitParameter in interface Wrapper
        Parameters:
        name - the name of the init parameter
        value - the value of the init parameter
      • setInitParameter

        public boolean setInitParameter​(String name,
                                        String value,
                                        boolean override)
        Sets the init parameter with the given name and value on this servlet.
        Parameters:
        name - the init parameter name
        value - the init parameter value
        override - true if the given init param is supposed to override an existing init param with the same name, and false otherwise
        Returns:
        true if the init parameter with the given name and value was set, false otherwise
      • setInitParameters

        public Set<String> setInitParameters​(Map<String,​String> initParameters)
        Sets the initialization parameters contained in the given map on this servlet.
        Parameters:
        initParameters - the map with the init params to set
        Returns:
        the (possibly empty) Set of initialization parameter names that are in conflict
      • addInstanceListener

        public void addInstanceListener​(InstanceListener listener)
        Add a new listener interested in InstanceEvents.
        Specified by:
        addInstanceListener in interface Wrapper
        Parameters:
        listener - The new listener
      • addMapping

        public void addMapping​(String mapping)
        Add a mapping associated with the Wrapper.
        Specified by:
        addMapping in interface Wrapper
        Parameters:
        mapping - The new wrapper mapping
      • getMappings

        public Collection<String> getMappings()
        Gets all the mapping associated with the Wrapper.
        Returns:
        an unmodifiable list
      • addSecurityReference

        public void addSecurityReference​(String name,
                                         String link)
        Add a new security role reference record to the set of records for this servlet.
        Specified by:
        addSecurityReference in interface Wrapper
        Parameters:
        name - Role name used within this servlet
        link - Role name used within the web application
      • allocate

        public jakarta.servlet.Servlet allocate()
                                         throws jakarta.servlet.ServletException
        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().
        Specified by:
        allocate in interface Wrapper
        Returns:
        Throws:
        jakarta.servlet.ServletException - if the servlet init() method threw an exception
        jakarta.servlet.ServletException - if a loading error occurs
      • deallocate

        public void deallocate​(jakarta.servlet.Servlet servlet)
                        throws jakarta.servlet.ServletException
        Return this previously allocated servlet to the pool of available instances. If this servlet class does not implement SingleThreadModel, no action is actually required.
        Specified by:
        deallocate in interface Wrapper
        Parameters:
        servlet - The servlet to be returned
        Throws:
        jakarta.servlet.ServletException - if a deallocation error occurs
      • findInitParameter

        public String findInitParameter​(String name)
        Return the value for the specified initialization parameter name, if any; otherwise return null.
        Specified by:
        findInitParameter in interface Wrapper
        Parameters:
        name - Name of the requested initialization parameter
        Returns:
      • findInitParameters

        public String[] findInitParameters()
        Return the names of all defined initialization parameters for this servlet.
        Specified by:
        findInitParameters in interface Wrapper
        Returns:
      • findMappings

        public String[] findMappings()
        Return the mappings associated with this wrapper.
        Specified by:
        findMappings in interface Wrapper
        Returns:
      • findSecurityReference

        public String findSecurityReference​(String name)
        Return the security role link for the specified security role reference name, if any; otherwise return null.
        Specified by:
        findSecurityReference in interface Wrapper
        Parameters:
        name - Security role reference used within this servlet
        Returns:
      • findSecurityReferences

        public String[] findSecurityReferences()
        Return the set of security role reference names associated with this servlet, if any; otherwise return a zero-length array.
        Specified by:
        findSecurityReferences in interface Wrapper
        Returns:
      • findMappingObject

        public Wrapper findMappingObject()
        FIXME: Fooling introspection ...
        Returns:
      • load

        public void load()
                  throws jakarta.servlet.ServletException
        Loads and initializes an instance of the 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.

        Specified by:
        load in interface Wrapper
        Throws:
        jakarta.servlet.ServletException - if the servlet init() method threw an exception or if some other loading problem occurs
      • removeInitParameter

        public void removeInitParameter​(String name)
        Remove the specified initialization parameter from this servlet.
        Specified by:
        removeInitParameter in interface Wrapper
        Parameters:
        name - Name of the initialization parameter to remove
      • removeInstanceListener

        public void removeInstanceListener​(InstanceListener listener)
        Remove a listener no longer interested in InstanceEvents.
        Specified by:
        removeInstanceListener in interface Wrapper
        Parameters:
        listener - The listener to remove
      • removeMapping

        public void removeMapping​(String mapping)
        Remove a mapping associated with the wrapper.
        Specified by:
        removeMapping in interface Wrapper
        Parameters:
        mapping - The pattern to remove
      • removeSecurityReference

        public void removeSecurityReference​(String name)
        Remove any security role reference for the specified role name.
        Specified by:
        removeSecurityReference in interface Wrapper
        Parameters:
        name - Security role used within this servlet to be removed
      • toString

        public String toString()
        Return a String representation of this component.
        Overrides:
        toString in class Object
      • unavailable

        public void unavailable​(jakarta.servlet.UnavailableException unavailable)
        Process an UnavailableException, marking this servlet as unavailable for the specified amount of time.
        Specified by:
        unavailable in interface Wrapper
        Parameters:
        unavailable - The exception that occurred, or null to mark this servlet as permanently unavailable
      • unload

        public void unload()
                    throws jakarta.servlet.ServletException
        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.
        Specified by:
        unload in interface Wrapper
        Throws:
        jakarta.servlet.ServletException - if an exception is thrown by the destroy() method
      • getInitParameter

        public String getInitParameter​(String name)
        Return the initialization parameter value for the specified name, if any; otherwise return null.
        Specified by:
        getInitParameter in interface jakarta.servlet.ServletConfig
        Parameters:
        name - Name of the initialization parameter to retrieve
      • getInitParameterNames

        public Enumeration<String> getInitParameterNames()
        Return the set of initialization parameter names defined for this servlet. If none are defined, an empty Enumeration is returned.
        Specified by:
        getInitParameterNames in interface jakarta.servlet.ServletConfig
      • getServletContext

        public jakarta.servlet.ServletContext getServletContext()
        Return the servlet context with which this servlet is associated.
        Specified by:
        getServletContext in interface jakarta.servlet.ServletConfig
      • getServletName

        public String getServletName()
        Return the name of this servlet.
        Specified by:
        getServletName in interface jakarta.servlet.ServletConfig
        Specified by:
        getServletName in interface Wrapper
      • getLoadTime

        public long getLoadTime()
        Gets how long it took for the servlet to be loaded.
        Returns:
        length in milliseconds
      • setLoadTime

        public void setLoadTime​(long loadTime)
      • getClassLoadTime

        public int getClassLoadTime()
        Gets how long it took for the servlet class to be loaded.
        Returns:
        length in milliseconds
      • addDefaultMapper

        protected void addDefaultMapper​(String mapperClass)
        Add a default Mapper implementation if none have been configured explicitly.
        Parameters:
        mapperClass - Java class name of the default Mapper
      • logName

        protected String logName()
        Log the abbreviated name of this Container for logging messages.
        Overrides:
        logName in class ContainerBase
        Returns:
        StandardWrapper[<parentName | null> : nameOfContainer]
      • sendNotification

        public void sendNotification​(Notification notification)
        Sends a notification to anything listening via JMX.

        This function does not have anything to do with the notification service in Payara.

        Parameters:
        notification -
        See Also:
        NotificationBroadcasterSupport, NotificationService
      • isEventProvider

        public boolean isEventProvider()
        Returns:
        false
      • isStateManageable

        public boolean isStateManageable()
        Returns:
        false
      • isStatisticsProvider

        public boolean isStatisticsProvider()
        Returns:
        false