Interface ServletRegistration.Dynamic
-
- All Superinterfaces:
Registration,Registration.Dynamic,ServletRegistration
- Enclosing interface:
- ServletRegistration
public static interface ServletRegistration.Dynamic extends ServletRegistration, Registration.Dynamic
Interface through which aServletregistered via one of the addServlet methods onServletContextmay be further configured.
-
-
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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.-
Methods inherited from interface jakarta.servlet.Registration
getClassName, getInitParameter, getInitParameters, getName, setInitParameter, setInitParameters
-
Methods inherited from interface jakarta.servlet.Registration.Dynamic
setAsyncSupported
-
Methods inherited from interface jakarta.servlet.ServletRegistration
addMapping, getMappings, getRunAsRole
-
-
-
-
Method Detail
-
setLoadOnStartup
void setLoadOnStartup(int loadOnStartup)
Sets 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.
- Parameters:
loadOnStartup- the initialization priority of the Servlet- Throws:
IllegalStateException- if the ServletContext from which this ServletRegistration was obtained has already been initialized
-
setServletSecurity
Set<String> setServletSecurity(ServletSecurityElement constraint)
Sets 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.- 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 - Throws:
IllegalArgumentException- if constraint is nullIllegalStateException- if theServletContextfrom which thisServletRegistrationwas obtained has already been initialized
-
setMultipartConfig
void setMultipartConfig(MultipartConfigElement multipartConfig)
Sets 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.- Parameters:
multipartConfig- theMultipartConfigElementto be applied to the patterns mapped to the registration- Throws:
IllegalArgumentException- if multipartConfig is nullIllegalStateException- if theServletContextfrom which this ServletRegistration was obtained has already been initialized
-
setRunAsRole
void setRunAsRole(String roleName)
Sets the name of therunAsrole for thisServletRegistration.- Parameters:
roleName- the name of therunAsrole- Throws:
IllegalArgumentException- if roleName is nullIllegalStateException- if theServletContextfrom which this ServletRegistration was obtained has already been initialized
-
-