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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface jakarta.servlet.Registration
Registration.Dynamic
-
Nested classes/interfaces inherited from interface jakarta.servlet.ServletRegistration
ServletRegistration.Dynamic
-
-
Constructor Summary
Constructors Constructor Description ServletRegistrationImpl(ServletInfo servletInfo, ManagedServlet managedServlet, Deployment deployment)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<String>addMapping(String... urlPatterns)Adds a servlet mapping with the given URL patterns for the Servlet represented by this ServletRegistration.StringgetClassName()Gets the fully qualified class name of the Servlet or Filter that is represented by this Registration.StringgetInitParameter(String name)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.Map<String,String>getInitParameters()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.Collection<String>getMappings()Gets the currently available mappings of the Servlet represented by thisServletRegistration.StringgetName()Gets the name of the Servlet or Filter that is represented by this Registration.StringgetRunAsRole()Gets the name of the runAs role of the Servlet represented by thisServletRegistration.voidsetAsyncSupported(boolean isAsyncSupported)Configures the Servlet or Filter represented by this dynamic Registration as supporting asynchronous operations or not.booleansetInitParameter(String name, String value)Sets the initialization parameter with the given name and value on the Servlet or Filter that is represented by this Registration.Set<String>setInitParameters(Map<String,String> initParameters)Sets the given initialization parameters on the Servlet or Filter that is represented by this Registration.voidsetLoadOnStartup(int loadOnStartup)Sets theloadOnStartuppriority on the Servlet represented by this dynamic ServletRegistration.voidsetMultipartConfig(MultipartConfigElement multipartConfig)Sets theMultipartConfigElementto be applied to the mappings defined for thisServletRegistration.voidsetRunAsRole(String roleName)Sets the name of therunAsrole for thisServletRegistration.Set<String>setServletSecurity(ServletSecurityElement constraint)Sets theServletSecurityElementto be applied to the mappings defined for thisServletRegistration.
-
-
-
Constructor Detail
-
ServletRegistrationImpl
public ServletRegistrationImpl(ServletInfo servletInfo, ManagedServlet managedServlet, Deployment deployment)
-
-
Method Detail
-
setLoadOnStartup
public void setLoadOnStartup(int loadOnStartup)
Description copied from interface:ServletRegistration.DynamicSets theloadOnStartuppriority 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:
setLoadOnStartupin interfaceServletRegistration.Dynamic- Parameters:
loadOnStartup- the initialization priority of the Servlet
-
setServletSecurity
public Set<String> setServletSecurity(ServletSecurityElement constraint)
Description copied from interface:ServletRegistration.DynamicSets theServletSecurityElementto be applied to the mappings defined for thisServletRegistration.This method applies to all mappings added to this
ServletRegistrationup until the point that theServletContextfrom which it was obtained has been initialized.If a URL pattern of this ServletRegistration is an exact target of a
security-constraintthat was established via the portable deployment descriptor, then this method does not change thesecurity-constraintfor 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
ServletSecurityannotation 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
ServletSecurityannotation or a previous call to this method, nor the exact target of asecurity-constraintin the portable deployment descriptor, then this method establishes the security constraint for that pattern from the argumentServletSecurityElement.The returned set is not backed by the
Dynamicobject, so changes in the returned set are not reflected in theDynamicobject, and vice-versa.- Specified by:
setServletSecurityin interfaceServletRegistration.Dynamic- Parameters:
constraint- theServletSecurityElementto 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-constraintthat 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.DynamicSets theMultipartConfigElementto be applied to the mappings defined for thisServletRegistration. If this method is called multiple times, each successive call overrides the effects of the former.- Specified by:
setMultipartConfigin interfaceServletRegistration.Dynamic- Parameters:
multipartConfig- theMultipartConfigElementto be applied to the patterns mapped to the registration
-
setRunAsRole
public void setRunAsRole(String roleName)
Description copied from interface:ServletRegistration.DynamicSets the name of therunAsrole for thisServletRegistration.- Specified by:
setRunAsRolein interfaceServletRegistration.Dynamic- Parameters:
roleName- the name of therunAsrole
-
setAsyncSupported
public void setAsyncSupported(boolean isAsyncSupported)
Description copied from interface:Registration.DynamicConfigures 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:
setAsyncSupportedin interfaceRegistration.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:ServletRegistrationAdds 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
ServletRegistrationobject, so changes in the returned set are not reflected in theServletRegistrationobject, and vice-versa.- Specified by:
addMappingin interfaceServletRegistration- 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:ServletRegistrationGets the currently available mappings of the Servlet represented by thisServletRegistration.If permitted, any changes to the returned
Collectionmust not affect thisServletRegistration.- Specified by:
getMappingsin interfaceServletRegistration- Returns:
- a (possibly empty)
Collectionof the currently available mappings of the Servlet represented by thisServletRegistration
-
getRunAsRole
public String getRunAsRole()
Description copied from interface:ServletRegistrationGets the name of the runAs role of the Servlet represented by thisServletRegistration.- Specified by:
getRunAsRolein interfaceServletRegistration- 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:RegistrationGets the name of the Servlet or Filter that is represented by this Registration.- Specified by:
getNamein interfaceRegistration- Returns:
- the name of the Servlet or Filter that is represented by this Registration
-
getClassName
public String getClassName()
Description copied from interface:RegistrationGets the fully qualified class name of the Servlet or Filter that is represented by this Registration.- Specified by:
getClassNamein interfaceRegistration- 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:RegistrationSets the initialization parameter with the given name and value on the Servlet or Filter that is represented by this Registration.- Specified by:
setInitParameterin interfaceRegistration- Parameters:
name- the initialization parameter namevalue- 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:RegistrationGets 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:
getInitParameterin interfaceRegistration- 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:RegistrationSets 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
Registrationobject, so changes in the returned set are not reflected in theRegistrationobject, and vice-versa.- Specified by:
setInitParametersin interfaceRegistration- 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:RegistrationGets 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:
getInitParametersin interfaceRegistration- Returns:
- Map containing the currently available initialization parameters that will be used to initialize the Servlet or Filter represented by this Registration object
-
-