Top Description Fields Constructors Methods
io.undertow.servlet

public Class Servlets

extends Object
Class Inheritance
Imports
jakarta.servlet.Filter, .MultipartConfigElement, .Servlet, io.undertow.servlet.api.DeploymentInfo, .ErrorPage, .FilterInfo, .InstanceFactory, .ListenerInfo, .LoginConfig, .SecurityConstraint, .ServletContainer, .ServletInfo, .WebResourceCollection, io.undertow.servlet.core.ServletContainerImpl, java.util.EventListener

Utility class for building servlet deployments.
Author
Stuart Douglas

Field Summary

Modifier and TypeField and Description
private static volatile ServletContainer

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ServletContainer

Returns:

The default servlet container
defaultContainer
()

Returns the default servlet container.

public static DeploymentInfo

Returns:

A new deployment info structure
deployment
()

Creates a new servlet deployment info structure

public static ErrorPage

Returns:

The error page definition
errorPage
(String
The location to redirect to
location
,
Class<? extends Throwable>
The exception type
exceptionType
)

Create an ErrorPage instance for a given exception type

public static ErrorPage

Returns:

The error page definition
errorPage
(String
The location to redirect to
location
,
int
The status code
statusCode
)

Create an ErrorPage instance for a given response code

public static ErrorPage

Returns:

The error page instance
errorPage
(String
The error page location
location
)

Create an ErrorPage that corresponds to the default error page

public static FilterInfo

Returns:

A new filter description
filter
(final Class<? extends Filter>
The filter class
filterClass
)

Creates a new filter description with the given class.

public static FilterInfo

Returns:

A new filter description
filter
(final String
The filter name
name
,
final Class<? extends Filter>
The filter class
filterClass
)

Creates a new filter description with the given name and class

public static FilterInfo

Returns:

A new filter description
filter
(final String
The filter name
name
,
final Class<? extends Filter>
The filter class
filterClass
,
final InstanceFactory<? extends Filter> filter)

Creates a new filter description with the given name and class

public static ListenerInfo
listener(final Class<? extends EventListener> listenerClass, final InstanceFactory<? extends EventListener> instanceFactory)

public static ListenerInfo
listener(final Class<? extends EventListener> listenerClass)

public static LoginConfig
loginConfig(String realmName, String loginPage, String errorPage)

public static LoginConfig
loginConfig(final String realmName)

public static LoginConfig
loginConfig(String mechanismName, String realmName, String loginPage, String errorPage)

public static LoginConfig
loginConfig(String mechanismName, final String realmName)

public static MultipartConfigElement
multipartConfig(String
the directory location where files will be stored
location
,
long
the maximum size allowed for uploaded files
maxFileSize
,
long
the maximum size allowed for multipart/form-data requests
maxRequestSize
,
int
the size threshold after which files will be written to disk
fileSizeThreshold
)

Creates a new multipart config element

public static ServletContainer

Returns:

A new servlet container
newContainer
()

Creates a new servlet container.

public static SecurityConstraint
public static ServletInfo

Returns:

A new servlet description
servlet
(final Class<? extends Servlet>
The servlet class
servletClass
)

Creates a new servlet description with the given class.

public static ServletInfo

Returns:

A new servlet description
servlet
(final String
The servlet name
name
,
final Class<? extends Servlet>
The servlet class
servletClass
)

Creates a new servlet description with the given name and class

public static ServletInfo

Returns:

A new servlet description
servlet
(final String
The servlet name
name
,
final Class<? extends Servlet>
The servlet class
servletClass
,
final InstanceFactory<? extends Servlet> servlet)

Creates a new servlet description with the given name and class

public static WebResourceCollection
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

containerback to summary
private static volatile ServletContainer container

Constructor Detail

Servletsback to summary
private Servlets()

Method Detail

defaultContainerback to summary
public static ServletContainer defaultContainer()

Returns the default servlet container. For most embedded use cases this will be sufficient.

Returns:ServletContainer

The default servlet container

deploymentback to summary
public static DeploymentInfo deployment()

Creates a new servlet deployment info structure

Returns:DeploymentInfo

A new deployment info structure

errorPageback to summary
public static ErrorPage errorPage(String location, Class<? extends Throwable> exceptionType)

Create an ErrorPage instance for a given exception type

Parameters
location:String

The location to redirect to

exceptionType:Class<? extends Throwable>

The exception type

Returns:ErrorPage

The error page definition

errorPageback to summary
public static ErrorPage errorPage(String location, int statusCode)

Create an ErrorPage instance for a given response code

Parameters
location:String

The location to redirect to

statusCode:int

The status code

Returns:ErrorPage

The error page definition

errorPageback to summary
public static ErrorPage errorPage(String location)

Create an ErrorPage that corresponds to the default error page

Parameters
location:String

The error page location

Returns:ErrorPage

The error page instance

filterback to summary
public static FilterInfo filter(final Class<? extends Filter> filterClass)

Creates a new filter description with the given class. The filter name is inferred from the simple name of the class.

Parameters
filterClass:Class<? extends Filter>

The filter class

Returns:FilterInfo

A new filter description

filterback to summary
public static FilterInfo filter(final String name, final Class<? extends Filter> filterClass)

Creates a new filter description with the given name and class

Parameters
name:String

The filter name

filterClass:Class<? extends Filter>

The filter class

Returns:FilterInfo

A new filter description

filterback to summary
public static FilterInfo filter(final String name, final Class<? extends Filter> filterClass, final InstanceFactory<? extends Filter> filter)

Creates a new filter description with the given name and class

Parameters
name:String

The filter name

filterClass:Class<? extends Filter>

The filter class

Returns:FilterInfo

A new filter description

listenerback to summary
public static ListenerInfo listener(final Class<? extends EventListener> listenerClass, final InstanceFactory<? extends EventListener> instanceFactory)
listenerback to summary
public static ListenerInfo listener(final Class<? extends EventListener> listenerClass)
loginConfigback to summary
public static LoginConfig loginConfig(String realmName, String loginPage, String errorPage)
loginConfigback to summary
public static LoginConfig loginConfig(final String realmName)
loginConfigback to summary
public static LoginConfig loginConfig(String mechanismName, String realmName, String loginPage, String errorPage)
loginConfigback to summary
public static LoginConfig loginConfig(String mechanismName, final String realmName)
multipartConfigback to summary
public static MultipartConfigElement multipartConfig(String location, long maxFileSize, long maxRequestSize, int fileSizeThreshold)

Creates a new multipart config element

Parameters
location:String

the directory location where files will be stored

maxFileSize:long

the maximum size allowed for uploaded files

maxRequestSize:long

the maximum size allowed for multipart/form-data requests

fileSizeThreshold:int

the size threshold after which files will be written to disk

newContainerback to summary
public static ServletContainer newContainer()

Creates a new servlet container.

Returns:ServletContainer

A new servlet container

securityConstraintback to summary
public static SecurityConstraint securityConstraint()
servletback to summary
public static ServletInfo servlet(final Class<? extends Servlet> servletClass)

Creates a new servlet description with the given class. The servlet name is inferred from the simple name of the class.

Parameters
servletClass:Class<? extends Servlet>

The servlet class

Returns:ServletInfo

A new servlet description

servletback to summary
public static ServletInfo servlet(final String name, final Class<? extends Servlet> servletClass)

Creates a new servlet description with the given name and class

Parameters
name:String

The servlet name

servletClass:Class<? extends Servlet>

The servlet class

Returns:ServletInfo

A new servlet description

servletback to summary
public static ServletInfo servlet(final String name, final Class<? extends Servlet> servletClass, final InstanceFactory<? extends Servlet> servlet)

Creates a new servlet description with the given name and class

Parameters
name:String

The servlet name

servletClass:Class<? extends Servlet>

The servlet class

Returns:ServletInfo

A new servlet description

webResourceCollectionback to summary
public static WebResourceCollection webResourceCollection()