Package io.undertow.servlet
Class Servlets
- java.lang.Object
-
- io.undertow.servlet.Servlets
-
public class Servlets extends Object
Utility class for building servlet deployments.- Author:
- Stuart Douglas
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ServletContainerdefaultContainer()Returns the default servlet container.static DeploymentInfodeployment()Creates a new servlet deployment info structurestatic ErrorPageerrorPage(String location)Create an ErrorPage that corresponds to the default error pagestatic ErrorPageerrorPage(String location, int statusCode)Create an ErrorPage instance for a given response codestatic ErrorPageerrorPage(String location, Class<? extends Throwable> exceptionType)Create an ErrorPage instance for a given exception typestatic FilterInfofilter(Class<? extends jakarta.servlet.Filter> filterClass)Creates a new filter description with the given class.static FilterInfofilter(String name, Class<? extends jakarta.servlet.Filter> filterClass)Creates a new filter description with the given name and classstatic FilterInfofilter(String name, Class<? extends jakarta.servlet.Filter> filterClass, InstanceFactory<? extends jakarta.servlet.Filter> filter)Creates a new filter description with the given name and classstatic ListenerInfolistener(Class<? extends EventListener> listenerClass)static ListenerInfolistener(Class<? extends EventListener> listenerClass, InstanceFactory<? extends EventListener> instanceFactory)static LoginConfigloginConfig(String realmName)static LoginConfigloginConfig(String mechanismName, String realmName)static LoginConfigloginConfig(String realmName, String loginPage, String errorPage)static LoginConfigloginConfig(String mechanismName, String realmName, String loginPage, String errorPage)static jakarta.servlet.MultipartConfigElementmultipartConfig(String location, long maxFileSize, long maxRequestSize, int fileSizeThreshold)Creates a new multipart config elementstatic ServletContainernewContainer()Creates a new servlet container.static SecurityConstraintsecurityConstraint()static ServletInfoservlet(Class<? extends jakarta.servlet.Servlet> servletClass)Creates a new servlet description with the given class.static ServletInfoservlet(String name, Class<? extends jakarta.servlet.Servlet> servletClass)Creates a new servlet description with the given name and classstatic ServletInfoservlet(String name, Class<? extends jakarta.servlet.Servlet> servletClass, InstanceFactory<? extends jakarta.servlet.Servlet> servlet)Creates a new servlet description with the given name and classstatic WebResourceCollectionwebResourceCollection()
-
-
-
Method Detail
-
defaultContainer
public static ServletContainer defaultContainer()
Returns the default servlet container. For most embedded use cases this will be sufficient.- Returns:
- The default servlet container
-
newContainer
public static ServletContainer newContainer()
Creates a new servlet container.- Returns:
- A new servlet container
-
deployment
public static DeploymentInfo deployment()
Creates a new servlet deployment info structure- Returns:
- A new deployment info structure
-
servlet
public static ServletInfo servlet(Class<? extends jakarta.servlet.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- The servlet class- Returns:
- A new servlet description
-
servlet
public static ServletInfo servlet(String name, Class<? extends jakarta.servlet.Servlet> servletClass)
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 jakarta.servlet.Servlet> servletClass, InstanceFactory<? extends jakarta.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
public static FilterInfo filter(Class<? extends jakarta.servlet.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- The filter class- Returns:
- A new filter description
-
filter
public static FilterInfo filter(String name, Class<? extends jakarta.servlet.Filter> filterClass)
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 jakarta.servlet.Filter> filterClass, InstanceFactory<? extends jakarta.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 jakarta.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
public static ListenerInfo listener(Class<? extends EventListener> listenerClass)
-
securityConstraint
public static SecurityConstraint securityConstraint()
-
webResourceCollection
public static WebResourceCollection webResourceCollection()
-
loginConfig
public static LoginConfig loginConfig(String realmName, String loginPage, String errorPage)
-
loginConfig
public static LoginConfig loginConfig(String realmName)
-
loginConfig
public static LoginConfig loginConfig(String mechanismName, String realmName, String loginPage, String errorPage)
-
loginConfig
public static LoginConfig loginConfig(String mechanismName, String realmName)
-
errorPage
public static ErrorPage errorPage(String location, Class<? extends Throwable> exceptionType)
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
public static ErrorPage errorPage(String location, int statusCode)
Create an ErrorPage instance for a given response code- Parameters:
location- The location to redirect tostatusCode- The status code- Returns:
- The error page definition
-
-