Top Description Fields Constructors Methods
org.glassfish.grizzly.servlet

public Class ServletRegistration

extends Registration
implements Dynamic, Comparable<ServletRegistration>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable, jakarta.servlet.ServletRegistration.Dynamic, jakarta.servlet.Registration.Dynamic, jakarta.servlet.Registration, jakarta.servlet.ServletRegistration
Imports
java.util.Arrays, .Collection, .Collections, .Set, org.glassfish.grizzly.utils.ArraySet, jakarta.servlet.MultipartConfigElement, .Servlet, .ServletSecurityElement

Allows customization of a jakarta.servlet.Servlet registered with the WebappContext.
Since
2.2

Field Summary

Modifier and TypeField and Description
protected ExpectationHandler
protected boolean
protected int
private String
runAs

The run-as identity for this servlet.

protected Servlet
protected Class<? extends Servlet>
protected final ArraySet<String>
Inherited from org.glassfish.grizzly.servlet.Registration:
classNamectxinitParametersname

Constructor Summary

AccessConstructor and Description
protected
ServletRegistration(final WebappContext
the owning WebappContext.
ctx
,
final String
the name of the Filter.
name
,
final String
the fully qualified class name of the Servlet implementation.
servletClassName
)

Creates a new ServletRegistration associated with the specified WebappContext.

protected
ServletRegistration(final WebappContext
the owning WebappContext.
ctx
,
final String
the name of the Filter.
name
,
final Servlet
the Servlet instance.
servlet
)

Creates a new ServletRegistration associated with the specified WebappContext.

protected
ServletRegistration(final WebappContext
the owning WebappContext.
ctx
,
final String
the name of the Filter.
name
,
final Class<? extends Servlet>
the class of the Servlet implementation.
servletClass
)

Creates a new ServletRegistration associated with the specified WebappContext.

Method Summary

Modifier and TypeMethod and Description
public Set<String>

Returns:

the (possibly empty) Set of URL patterns that are already mapped to a different Servlet
addMapping
(String...
the URL patterns of the servlet mapping
urlPatterns
)

Implements jakarta.servlet.ServletRegistration.addMapping.

Adds a servlet mapping with the given URL patterns for the Servlet represented by this ServletRegistration.

public int
compareTo(ServletRegistration o)

Implements java.lang.Comparable.compareTo.

Compares this object with the specified object for order.

public ExpectationHandler

Returns:

the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").
getExpectationHandler
()

Get the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

public Collection<String>

Returns:

a (possibly empty) Collection of the currently available mappings of the Servlet represented by this ServletRegistration
getMappings
()

Implements jakarta.servlet.ServletRegistration.getMappings.

Gets the currently available mappings of the Servlet represented by this ServletRegistration.

public String
getRunAsRole()

Implements jakarta.servlet.ServletRegistration.getRunAsRole.

Gets the name of the runAs role of the Servlet represented by this ServletRegistration.

public void
setAsyncSupported(boolean isAsyncSupported)

Implements jakarta.servlet.Registration.Dynamic.setAsyncSupported.

Configures the Servlet or Filter represented by this dynamic Registration as supporting asynchronous operations or not.

public void
setExpectationHandler(ExpectationHandler
the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").
expectationHandler
)

Set the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

public void
setLoadOnStartup(int
the initialization priority of the Servlet
loadOnStartup
)

Implements jakarta.servlet.ServletRegistration.Dynamic.setLoadOnStartup.

Sets the loadOnStartup priority on the Servlet represented by this dynamic ServletRegistration.

public void
setMultipartConfig(MultipartConfigElement multipartConfig)

Implements jakarta.servlet.ServletRegistration.Dynamic.setMultipartConfig.

Sets the MultipartConfigElement to be applied to the mappings defined for this ServletRegistration.

public void
setRunAsRole(String roleName)

Implements jakarta.servlet.ServletRegistration.Dynamic.setRunAsRole.

Sets the name of the runAs role for this ServletRegistration.

public Set<String>
setServletSecurity(ServletSecurityElement constraint)

Implements jakarta.servlet.ServletRegistration.Dynamic.setServletSecurity.

Sets the ServletSecurityElement to be applied to the mappings defined for this ServletRegistration.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from org.glassfish.grizzly.servlet.Registration:
equalsgetClassNamegetInitParametergetInitParametersgetNamehashCodesetInitParametersetInitParameters

Field Detail

expectationHandlerback to summary
protected ExpectationHandler expectationHandler
isAsyncSupportedback to summary
protected boolean isAsyncSupported
loadOnStartupback to summary
protected int loadOnStartup
runAsback to summary
private String runAs

The run-as identity for this servlet.

servletback to summary
protected Servlet servlet
servletClassback to summary
protected Class<? extends Servlet> servletClass
urlPatternsback to summary
protected final ArraySet<String> urlPatterns

Constructor Detail

ServletRegistrationback to summary
protected ServletRegistration(final WebappContext ctx, final String name, final String servletClassName)

Creates a new ServletRegistration associated with the specified WebappContext.

Parameters
ctx:WebappContext

the owning WebappContext.

name:String

the name of the Filter.

servletClassName:String

the fully qualified class name of the Servlet implementation.

ServletRegistrationback to summary
protected ServletRegistration(final WebappContext ctx, final String name, final Servlet servlet)

Creates a new ServletRegistration associated with the specified WebappContext.

Parameters
ctx:WebappContext

the owning WebappContext.

name:String

the name of the Filter.

servlet:Servlet

the Servlet instance.

ServletRegistrationback to summary
protected ServletRegistration(final WebappContext ctx, final String name, final Class<? extends Servlet> servletClass)

Creates a new ServletRegistration associated with the specified WebappContext.

Parameters
ctx:WebappContext

the owning WebappContext.

name:String

the name of the Filter.

servletClass:Class<? extends Servlet>

the class of the Servlet implementation.

Method Detail

addMappingback to summary
public Set<String> addMapping(String... urlPatterns)

Implements jakarta.servlet.ServletRegistration.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.

Parameters
urlPatterns:String[]

the URL patterns of the servlet mapping

Returns:Set<String>

the (possibly empty) Set of URL patterns that are already mapped to a different Servlet

Annotations
@Override
Exceptions
IllegalArgumentException:
if urlPatterns is null or empty
IllegalStateException:
if the ServletContext from which this ServletRegistration was obtained has already been initialized
compareToback to summary
public int compareTo(ServletRegistration o)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Annotations
@Override
getExpectationHandlerback to summary
public ExpectationHandler getExpectationHandler()

Get the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

Returns:ExpectationHandler

the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

getMappingsback to summary
public Collection<String> getMappings()

Implements jakarta.servlet.ServletRegistration.getMappings.

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.

Returns:Collection<String>

a (possibly empty) Collection of the currently available mappings of the Servlet represented by this ServletRegistration

Annotations
@Override
getRunAsRoleback to summary
public String getRunAsRole()

Implements jakarta.servlet.ServletRegistration.getRunAsRole.

Doc from jakarta.servlet.ServletRegistration.getRunAsRole.

Gets the name of the runAs role of the Servlet represented by this ServletRegistration.

Annotations
@Override
setAsyncSupportedback to summary
public void setAsyncSupported(boolean isAsyncSupported)

Implements jakarta.servlet.Registration.Dynamic.setAsyncSupported.

Doc from jakarta.servlet.Registration.Dynamic.setAsyncSupported.

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.

Annotations
@Override
setExpectationHandlerback to summary
public void setExpectationHandler(ExpectationHandler expectationHandler)

Set the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

Parameters
expectationHandler:ExpectationHandler

the ExpectationHandler responsible for processing Expect: header (for example "Expect: 100-Continue").

setLoadOnStartupback to summary
public void setLoadOnStartup(int loadOnStartup)

Implements jakarta.servlet.ServletRegistration.Dynamic.setLoadOnStartup.

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 WebappContext, that is, after it has invoked all of the ServletContextListener objects configured for the WebappContext at their jakarta.servlet.ServletContextListener#contextInitialized 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:int

the initialization priority of the Servlet

Annotations
@Override
Exceptions
IllegalStateException:
if the ServletContext from which this ServletRegistration was obtained has already been initialized
setMultipartConfigback to summary
public void setMultipartConfig(MultipartConfigElement multipartConfig)

Implements jakarta.servlet.ServletRegistration.Dynamic.setMultipartConfig.

Doc from jakarta.servlet.ServletRegistration.Dynamic.setMultipartConfig.

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.

Annotations
@Override
setRunAsRoleback to summary
public void setRunAsRole(String roleName)

Implements jakarta.servlet.ServletRegistration.Dynamic.setRunAsRole.

Doc from jakarta.servlet.ServletRegistration.Dynamic.setRunAsRole.

Sets the name of the runAs role for this ServletRegistration.

Annotations
@Override
setServletSecurityback to summary
public Set<String> setServletSecurity(ServletSecurityElement constraint)

Implements jakarta.servlet.ServletRegistration.Dynamic.setServletSecurity.

Doc from jakarta.servlet.ServletRegistration.Dynamic.setServletSecurity.

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 jakarta.servlet.annotation.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 jakarta.servlet.annotation.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.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override