Class ServletRegistration
- All Implemented Interfaces:
Registration,Registration.Dynamic,ServletRegistration,ServletRegistration.Dynamic,Comparable<ServletRegistration>
Servlet registered with the WebappContext.- Since:
- 2.2
-
Nested Class Summary
Nested classes/interfaces inherited from interface jakarta.servlet.Registration
Registration.DynamicNested classes/interfaces inherited from interface jakarta.servlet.ServletRegistration
ServletRegistration.Dynamic -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ExpectationHandlerprotected booleanprotected intprotected ServletFields inherited from class org.glassfish.grizzly.servlet.Registration
className, ctx, initParameters, name -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedServletRegistration(WebappContext ctx, String name, Servlet servlet) Creates a new ServletRegistration associated with the specifiedWebappContext.protectedServletRegistration(WebappContext ctx, String name, Class<? extends Servlet> servletClass) Creates a new ServletRegistration associated with the specifiedWebappContext.protectedServletRegistration(WebappContext ctx, String name, String servletClassName) Creates a new ServletRegistration associated with the specifiedWebappContext. -
Method Summary
Modifier and TypeMethodDescriptionaddMapping(String... urlPatterns) Adds a servlet mapping with the given URL patterns for the Servlet represented by this ServletRegistration.intGet theExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").Gets the currently available mappings of the Servlet represented by thisServletRegistration.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.voidsetExpectationHandler(ExpectationHandler expectationHandler) Set theExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").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.setServletSecurity(ServletSecurityElement constraint) Sets theServletSecurityElementto be applied to the mappings defined for thisServletRegistration.toString()Methods inherited from class org.glassfish.grizzly.servlet.Registration
equals, getClassName, getInitParameter, getInitParameters, getName, hashCode, setInitParameter, setInitParametersMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface jakarta.servlet.Registration
getClassName, getInitParameter, getInitParameters, getName, setInitParameter, setInitParameters
-
Field Details
-
servletClass
-
urlPatterns
-
servlet
-
loadOnStartup
protected int loadOnStartup -
expectationHandler
-
isAsyncSupported
protected boolean isAsyncSupported
-
-
Constructor Details
-
ServletRegistration
Creates a new ServletRegistration associated with the specifiedWebappContext.- Parameters:
ctx- the owningWebappContext.name- the name of the Filter.servletClassName- the fully qualified class name of theServletimplementation.
-
ServletRegistration
Creates a new ServletRegistration associated with the specifiedWebappContext.- Parameters:
ctx- the owningWebappContext.name- the name of the Filter.servlet- theServletinstance.
-
ServletRegistration
protected ServletRegistration(WebappContext ctx, String name, Class<? extends Servlet> servletClass) Creates a new ServletRegistration associated with the specifiedWebappContext.- Parameters:
ctx- the owningWebappContext.name- the name of the Filter.servletClass- the class of theServletimplementation.
-
-
Method Details
-
addMapping
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.
- 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
- Throws:
IllegalArgumentException- if urlPatterns is null or emptyIllegalStateException- if the ServletContext from which this ServletRegistration was obtained has already been initialized
-
getMappings
Gets 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
-
setLoadOnStartup
public 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 WebappContext, that is, after it has invoked all of the ServletContextListener objects configured for the WebappContext 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- Throws:
IllegalStateException- if the ServletContext from which this ServletRegistration was obtained has already been initialized
-
getExpectationHandler
Get theExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").- Returns:
- the
ExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").
-
setServletSecurity
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.- 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
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.- Specified by:
setMultipartConfigin interfaceServletRegistration.Dynamic- Parameters:
multipartConfig- theMultipartConfigElementto be applied to the patterns mapped to the registration
-
getRunAsRole
Gets 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
-
setRunAsRole
Sets the name of therunAsrole for thisServletRegistration.- Specified by:
setRunAsRolein interfaceServletRegistration.Dynamic- Parameters:
roleName- the name of therunAsrole
-
setAsyncSupported
public void setAsyncSupported(boolean isAsyncSupported) 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:
setAsyncSupportedin interfaceRegistration.Dynamic- Parameters:
isAsyncSupported- true if the Servlet or Filter represented by this dynamic Registration supports asynchronous operations, false otherwise
-
setExpectationHandler
Set theExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").- Parameters:
expectationHandler- theExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").
-
toString
-
compareTo
- Specified by:
compareToin interfaceComparable<ServletRegistration>
-