Package io.undertow.servlet
Class Servlets
java.lang.Object
io.undertow.servlet.Servlets
Utility class for building servlet deployments.
- Author:
- Stuart Douglas
-
Method Summary
Modifier and TypeMethodDescriptionstatic ServletContainer
Returns the default servlet container.static DeploymentInfo
Creates a new servlet deployment info structurestatic ErrorPage
Create an ErrorPage that corresponds to the default error pagestatic ErrorPage
Create an ErrorPage instance for a given response codestatic ErrorPage
Create an ErrorPage instance for a given exception typestatic FilterInfo
Creates a new filter description with the given class.static FilterInfo
Creates a new filter description with the given name and classstatic FilterInfo
filter
(String name, Class<? extends javax.servlet.Filter> filterClass, InstanceFactory<? extends javax.servlet.Filter> filter) Creates a new filter description with the given name and classstatic ListenerInfo
listener
(Class<? extends EventListener> listenerClass) static ListenerInfo
listener
(Class<? extends EventListener> listenerClass, InstanceFactory<? extends EventListener> instanceFactory) static LoginConfig
loginConfig
(String realmName) static LoginConfig
loginConfig
(String mechanismName, String realmName) static LoginConfig
loginConfig
(String realmName, String loginPage, String errorPage) static LoginConfig
loginConfig
(String mechanismName, String realmName, String loginPage, String errorPage) static javax.servlet.MultipartConfigElement
multipartConfig
(String location, long maxFileSize, long maxRequestSize, int fileSizeThreshold) Creates a new multipart config elementstatic ServletContainer
Creates a new servlet container.static SecurityConstraint
static ServletInfo
Creates a new servlet description with the given class.static ServletInfo
Creates a new servlet description with the given name and classstatic ServletInfo
servlet
(String name, Class<? extends javax.servlet.Servlet> servletClass, InstanceFactory<? extends javax.servlet.Servlet> servlet) Creates a new servlet description with the given name and classstatic WebResourceCollection
-
Method Details
-
defaultContainer
Returns the default servlet container. For most embedded use cases this will be sufficient.- Returns:
- The default servlet container
-
newContainer
Creates a new servlet container.- Returns:
- A new servlet container
-
deployment
Creates a new servlet deployment info structure- Returns:
- A new deployment info structure
-
servlet
Creates a new servlet description with the given class. The servlet name is inferred from the simple name of the class.- Parameters:
servletClass
- The servlet class- Returns:
- A new servlet description
-
servlet
Creates a new servlet description with the given name and class- Parameters:
name
- The servlet nameservletClass
- The servlet class- Returns:
- A new servlet description
-
servlet
public static ServletInfo servlet(String name, Class<? extends javax.servlet.Servlet> servletClass, InstanceFactory<? extends javax.servlet.Servlet> servlet) Creates a new servlet description with the given name and class- Parameters:
name
- The servlet nameservletClass
- The servlet class- Returns:
- A new servlet description
-
filter
Creates a new filter description with the given class. The filter name is inferred from the simple name of the class.- Parameters:
filterClass
- The filter class- Returns:
- A new filter description
-
filter
Creates a new filter description with the given name and class- Parameters:
name
- The filter namefilterClass
- The filter class- Returns:
- A new filter description
-
filter
public static FilterInfo filter(String name, Class<? extends javax.servlet.Filter> filterClass, InstanceFactory<? extends javax.servlet.Filter> filter) Creates a new filter description with the given name and class- Parameters:
name
- The filter namefilterClass
- The filter class- Returns:
- A new filter description
-
multipartConfig
public static javax.servlet.MultipartConfigElement multipartConfig(String location, long maxFileSize, long maxRequestSize, int fileSizeThreshold) Creates a new multipart config element- Parameters:
location
- the directory location where files will be storedmaxFileSize
- the maximum size allowed for uploaded filesmaxRequestSize
- the maximum size allowed for multipart/form-data requestsfileSizeThreshold
- the size threshold after which files will be written to disk
-
listener
public static ListenerInfo listener(Class<? extends EventListener> listenerClass, InstanceFactory<? extends EventListener> instanceFactory) -
listener
-
securityConstraint
-
webResourceCollection
-
loginConfig
-
loginConfig
-
loginConfig
public static LoginConfig loginConfig(String mechanismName, String realmName, String loginPage, String errorPage) -
loginConfig
-
errorPage
Create an ErrorPage instance for a given exception type- Parameters:
location
- The location to redirect toexceptionType
- The exception type- Returns:
- The error page definition
-
errorPage
Create an ErrorPage instance for a given response code- Parameters:
location
- The location to redirect tostatusCode
- The status code- Returns:
- The error page definition
-
errorPage
Create an ErrorPage that corresponds to the default error page- Parameters:
location
- The error page location- Returns:
- The error page instance
-