Class ServletRegistration
- java.lang.Object
-
- org.glassfish.grizzly.servlet.Registration
-
- org.glassfish.grizzly.servlet.ServletRegistration
-
- All Implemented Interfaces:
jakarta.servlet.Registration,jakarta.servlet.Registration.Dynamic,jakarta.servlet.ServletRegistration,jakarta.servlet.ServletRegistration.Dynamic,Comparable<ServletRegistration>
public class ServletRegistration extends Registration implements jakarta.servlet.ServletRegistration.Dynamic, Comparable<ServletRegistration>
Allows customization of aServletregistered with theWebappContext.- Since:
- 2.2
-
-
Field Summary
Fields Modifier and Type Field Description protected ExpectationHandlerexpectationHandlerprotected booleanisAsyncSupportedprotected intloadOnStartupprotected jakarta.servlet.Servletservletprotected Class<? extends jakarta.servlet.Servlet>servletClassprotected org.glassfish.grizzly.utils.ArraySet<String>urlPatterns-
Fields inherited from class org.glassfish.grizzly.servlet.Registration
className, ctx, initParameters, name
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedServletRegistration(WebappContext ctx, String name, jakarta.servlet.Servlet servlet)Creates a new ServletRegistration associated with the specifiedWebappContext.protectedServletRegistration(WebappContext ctx, String name, Class<? extends jakarta.servlet.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
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.intcompareTo(ServletRegistration o)ExpectationHandlergetExpectationHandler()Get theExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").Collection<String>getMappings()Gets the currently available mappings of the Servlet represented by thisServletRegistration.StringgetRunAsRole()voidsetAsyncSupported(boolean isAsyncSupported)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(jakarta.servlet.MultipartConfigElement multipartConfig)voidsetRunAsRole(String roleName)Set<String>setServletSecurity(jakarta.servlet.ServletSecurityElement constraint)StringtoString()-
Methods inherited from class org.glassfish.grizzly.servlet.Registration
equals, getClassName, getInitParameter, getInitParameters, getName, hashCode, setInitParameter, setInitParameters
-
-
-
-
Field Detail
-
servletClass
protected Class<? extends jakarta.servlet.Servlet> servletClass
-
urlPatterns
protected final org.glassfish.grizzly.utils.ArraySet<String> urlPatterns
-
servlet
protected jakarta.servlet.Servlet servlet
-
loadOnStartup
protected int loadOnStartup
-
expectationHandler
protected ExpectationHandler expectationHandler
-
isAsyncSupported
protected boolean isAsyncSupported
-
-
Constructor Detail
-
ServletRegistration
protected ServletRegistration(WebappContext ctx, String name, String servletClassName)
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
protected ServletRegistration(WebappContext ctx, String name, jakarta.servlet.Servlet servlet)
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 jakarta.servlet.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 Detail
-
addMapping
public Set<String> addMapping(String... urlPatterns)
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 interfacejakarta.servlet.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
- Throws:
IllegalArgumentException- if urlPatterns is null or emptyIllegalStateException- if the ServletContext from which this ServletRegistration was obtained has already been initialized
-
getMappings
public Collection<String> 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 interfacejakarta.servlet.ServletRegistration- 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 interfacejakarta.servlet.ServletRegistration.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
public ExpectationHandler 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
public Set<String> setServletSecurity(jakarta.servlet.ServletSecurityElement constraint)
- Specified by:
setServletSecurityin interfacejakarta.servlet.ServletRegistration.Dynamic
-
setMultipartConfig
public void setMultipartConfig(jakarta.servlet.MultipartConfigElement multipartConfig)
- Specified by:
setMultipartConfigin interfacejakarta.servlet.ServletRegistration.Dynamic
-
getRunAsRole
public String getRunAsRole()
- Specified by:
getRunAsRolein interfacejakarta.servlet.ServletRegistration
-
setRunAsRole
public void setRunAsRole(String roleName)
- Specified by:
setRunAsRolein interfacejakarta.servlet.ServletRegistration.Dynamic
-
setAsyncSupported
public void setAsyncSupported(boolean isAsyncSupported)
- Specified by:
setAsyncSupportedin interfacejakarta.servlet.Registration.Dynamic
-
setExpectationHandler
public void setExpectationHandler(ExpectationHandler expectationHandler)
Set theExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").- Parameters:
expectationHandler- theExpectationHandlerresponsible for processing Expect: header (for example "Expect: 100-Continue").
-
compareTo
public int compareTo(ServletRegistration o)
- Specified by:
compareToin interfaceComparable<ServletRegistration>
-
-