Class ServletRegistrationImpl

java.lang.Object
io.undertow.servlet.spec.ServletRegistrationImpl
All Implemented Interfaces:
Registration, Registration.Dynamic, ServletRegistration, ServletRegistration.Dynamic

public class ServletRegistrationImpl extends Object implements ServletRegistration, ServletRegistration.Dynamic
Author:
Stuart Douglas
  • Constructor Details

  • Method Details

    • setLoadOnStartup

      public void setLoadOnStartup(int loadOnStartup)
      Description copied from interface: ServletRegistration.Dynamic
      Sets the loadOnStartup priority on the Servlet represented by this dynamic ServletRegistration.

      A loadOnStartup value of greater than or equal to zero indicates to the container the initialization priority of the Servlet. In this case, the container must instantiate and initialize the Servlet during the initialization phase of the ServletContext, that is, after it has invoked all of the ServletContextListener objects configured for the ServletContext at their ServletContextListener.contextInitialized(jakarta.servlet.ServletContextEvent) method.

      If loadOnStartup is a negative integer, the container is free to instantiate and initialize the Servlet lazily.

      The default value for loadOnStartup is -1.

      A call to this method overrides any previous setting.

      Specified by:
      setLoadOnStartup in interface ServletRegistration.Dynamic
      Parameters:
      loadOnStartup - the initialization priority of the Servlet
    • setServletSecurity

      public Set<String> setServletSecurity(ServletSecurityElement constraint)
      Description copied from interface: ServletRegistration.Dynamic
      Sets the ServletSecurityElement to be applied to the mappings defined for this ServletRegistration.

      This method applies to all mappings added to this ServletRegistration up until the point that the ServletContext from which it was obtained has been initialized.

      If a URL pattern of this ServletRegistration is an exact target of a security-constraint that was established via the portable deployment descriptor, then this method does not change the security-constraint for that pattern, and the pattern will be included in the return value.

      If a URL pattern of this ServletRegistration is an exact target of a security constraint that was established via the ServletSecurity annotation or a previous call to this method, then this method replaces the security constraint for that pattern.

      If a URL pattern of this ServletRegistration is neither the exact target of a security constraint that was established via the ServletSecurity annotation or a previous call to this method, nor the exact target of a security-constraint in the portable deployment descriptor, then this method establishes the security constraint for that pattern from the argument ServletSecurityElement.

      The returned set is not backed by the Dynamic object, so changes in the returned set are not reflected in the Dynamic object, and vice-versa.

      Specified by:
      setServletSecurity in interface ServletRegistration.Dynamic
      Parameters:
      constraint - the ServletSecurityElement to be applied to the patterns mapped to this ServletRegistration
      Returns:
      the (possibly empty) Set of URL patterns that were already the exact target of a security-constraint that was established via the portable deployment descriptor. This method has no effect on the patterns included in the returned set
    • setMultipartConfig

      public void setMultipartConfig(MultipartConfigElement multipartConfig)
      Description copied from interface: ServletRegistration.Dynamic
      Sets the MultipartConfigElement to be applied to the mappings defined for this ServletRegistration. If this method is called multiple times, each successive call overrides the effects of the former.
      Specified by:
      setMultipartConfig in interface ServletRegistration.Dynamic
      Parameters:
      multipartConfig - the MultipartConfigElement to be applied to the patterns mapped to the registration
    • setRunAsRole

      public void setRunAsRole(String roleName)
      Description copied from interface: ServletRegistration.Dynamic
      Sets the name of the runAs role for this ServletRegistration.
      Specified by:
      setRunAsRole in interface ServletRegistration.Dynamic
      Parameters:
      roleName - the name of the runAs role
    • setAsyncSupported

      public void setAsyncSupported(boolean isAsyncSupported)
      Description copied from interface: Registration.Dynamic
      Configures the Servlet or Filter represented by this dynamic Registration as supporting asynchronous operations or not.

      By default, servlet and filters do not support asynchronous operations.

      A call to this method overrides any previous setting.

      Specified by:
      setAsyncSupported in interface Registration.Dynamic
      Parameters:
      isAsyncSupported - true if the Servlet or Filter represented by this dynamic Registration supports asynchronous operations, false otherwise
    • addMapping

      public Set<String> addMapping(String... urlPatterns)
      Description copied from interface: ServletRegistration
      Adds a servlet mapping with the given URL patterns for the Servlet represented by this ServletRegistration.

      If any of the specified URL patterns are already mapped to a different Servlet, no updates will be performed.

      If this method is called multiple times, each successive call adds to the effects of the former.

      The returned set is not backed by the ServletRegistration object, so changes in the returned set are not reflected in the ServletRegistration object, and vice-versa.

      Specified by:
      addMapping in interface ServletRegistration
      Parameters:
      urlPatterns - the URL patterns of the servlet mapping
      Returns:
      the (possibly empty) Set of URL patterns that are already mapped to a different Servlet
    • getMappings

      public Collection<String> getMappings()
      Description copied from interface: ServletRegistration
      Gets the currently available mappings of the Servlet represented by this ServletRegistration.

      If permitted, any changes to the returned Collection must not affect this ServletRegistration.

      Specified by:
      getMappings in interface ServletRegistration
      Returns:
      a (possibly empty) Collection of the currently available mappings of the Servlet represented by this ServletRegistration
    • getRunAsRole

      public String getRunAsRole()
      Description copied from interface: ServletRegistration
      Gets the name of the runAs role of the Servlet represented by this ServletRegistration.
      Specified by:
      getRunAsRole in interface ServletRegistration
      Returns:
      the name of the runAs role, or null if the Servlet is configured to run as its caller
    • getName

      public String getName()
      Description copied from interface: Registration
      Gets the name of the Servlet or Filter that is represented by this Registration.
      Specified by:
      getName in interface Registration
      Returns:
      the name of the Servlet or Filter that is represented by this Registration
    • getClassName

      public String getClassName()
      Description copied from interface: Registration
      Gets the fully qualified class name of the Servlet or Filter that is represented by this Registration.
      Specified by:
      getClassName in interface Registration
      Returns:
      the fully qualified class name of the Servlet or Filter that is represented by this Registration, or null if this Registration is preliminary
    • setInitParameter

      public boolean setInitParameter(String name, String value)
      Description copied from interface: Registration
      Sets the initialization parameter with the given name and value on the Servlet or Filter that is represented by this Registration.
      Specified by:
      setInitParameter in interface Registration
      Parameters:
      name - the initialization parameter name
      value - the initialization parameter value
      Returns:
      true if the update was successful, i.e., an initialization parameter with the given name did not already exist for the Servlet or Filter represented by this Registration, and false otherwise
    • getInitParameter

      public String getInitParameter(String name)
      Description copied from interface: Registration
      Gets the value of the initialization parameter with the given name that will be used to initialize the Servlet or Filter represented by this Registration object.
      Specified by:
      getInitParameter in interface Registration
      Parameters:
      name - the name of the initialization parameter whose value is requested
      Returns:
      the value of the initialization parameter with the given name, or null if no initialization parameter with the given name exists
    • setInitParameters

      public Set<String> setInitParameters(Map<String,String> initParameters)
      Description copied from interface: Registration
      Sets the given initialization parameters on the Servlet or Filter that is represented by this Registration.

      The given map of initialization parameters is processed by-value, i.e., for each initialization parameter contained in the map, this method calls Registration.setInitParameter(String,String). If that method would return false for any of the initialization parameters in the given map, no updates will be performed, and false will be returned. Likewise, if the map contains an initialization parameter with a null name or value, no updates will be performed, and an IllegalArgumentException will be thrown.

      The returned set is not backed by the Registration object, so changes in the returned set are not reflected in the Registration object, and vice-versa.

      Specified by:
      setInitParameters in interface Registration
      Parameters:
      initParameters - the initialization parameters
      Returns:
      the (possibly empty) Set of initialization parameter names that are in conflict
    • getInitParameters

      public Map<String,String> getInitParameters()
      Description copied from interface: Registration
      Gets an immutable (and possibly empty) Map containing the currently available initialization parameters that will be used to initialize the Servlet or Filter represented by this Registration object.
      Specified by:
      getInitParameters in interface Registration
      Returns:
      Map containing the currently available initialization parameters that will be used to initialize the Servlet or Filter represented by this Registration object