Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * JBoss, Home of Professional Open Source.
   * Copyright 2014 Red Hat, Inc., and individual contributors
   * as indicated by the @author tags.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  *  Unless required by applicable law or agreed to in writing, software
  *  distributed under the License is distributed on an "AS IS" BASIS,
  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
 
 package io.undertow.servlet;
 
 
 
Utility class for building servlet deployments.

Author(s):
Stuart Douglas
 
 public class Servlets {
 
     private static volatile ServletContainer container;

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

Returns:
The default servlet container
 
     public static ServletContainer defaultContainer() {
         if ( != null) {
             return ;
         }
         synchronized (Servlets.class) {
             if ( != null) {
                 return ;
             }
             return  = ServletContainer.Factory.newInstance();
         }
     }

    
Creates a new servlet container.

Returns:
A new servlet container
 
     public static ServletContainer newContainer() {
         return new ServletContainerImpl();
     }

    
Creates a new servlet deployment info structure

Returns:
A new deployment info structure
 
     public static DeploymentInfo deployment() {
         return new DeploymentInfo();
     }

    
Creates a new servlet description with the given name and class

Parameters:
name The servlet name
servletClass The servlet class
Returns:
A new servlet description
 
     public static ServletInfo servlet(final String namefinal Class<? extends ServletservletClass) {
         return new ServletInfo(nameservletClass);
     }

    
Creates a new servlet description with the given name and class

Parameters:
name The servlet name
servletClass The servlet class
Returns:
A new servlet description
    public static ServletInfo servlet(final String namefinal Class<? extends ServletservletClassfinal InstanceFactory<? extends Servletservlet) {
        return new ServletInfo(nameservletClassservlet);
    }


    
Creates a new servlet description with the given name and class

Parameters:
name The filter name
filterClass The filter class
Returns:
A new servlet description
    public static FilterInfo filter(final String namefinal Class<? extends FilterfilterClass) {
        return new FilterInfo(namefilterClass);
    }

    
Creates a new servlet description with the given name and class

Parameters:
name The filter name
filterClass The filter class
Returns:
A new filter description
    public static FilterInfo filter(final String namefinal Class<? extends FilterfilterClassfinal InstanceFactory<? extends Filterfilter) {
        return new FilterInfo(namefilterClassfilter);
    }

    
Creates a new multipart config element

Parameters:
location the directory location where files will be stored
maxFileSize the maximum size allowed for uploaded files
maxRequestSize the maximum size allowed for multipart/form-data requests
fileSizeThreshold the size threshold after which files will be written to disk
    public static MultipartConfigElement multipartConfig(String locationlong maxFileSizelong maxRequestSizeint fileSizeThreshold) {
        return new MultipartConfigElement(locationmaxFileSizemaxRequestSizefileSizeThreshold);
    }
    public static ListenerInfo listener(final Class<? extends EventListenerlistenerClassfinal InstanceFactory<? extends EventListenerinstanceFactory) {
        return new ListenerInfo(listenerClassinstanceFactory);
    }
    public static ListenerInfo listener(final Class<? extends EventListenerlistenerClass) {
        return new ListenerInfo(listenerClass);
    }
    public static SecurityConstraint securityConstraint() {
        return new SecurityConstraint();
    }
    public static WebResourceCollection webResourceCollection() {
        return new WebResourceCollection();
    }
    private Servlets() {
    }
    public static LoginConfig loginConfig(String realmNameString loginPageString errorPage) {
        return new LoginConfig(realmNameloginPageerrorPage);
    }
    public static LoginConfig loginConfig(final String realmName) {
        return new LoginConfig(realmName);
    }
    public static LoginConfig loginConfig(String mechanismNameString realmNameString loginPageString errorPage) {
        return new LoginConfig(mechanismNamerealmNameloginPageerrorPage);
    }
    public static LoginConfig loginConfig(String mechanismNamefinal String realmName) {
        return new LoginConfig(mechanismNamerealmName);
    }

    
Create an ErrorPage instance for a given exception type

Parameters:
location The location to redirect to
exceptionType The exception type
Returns:
The error page definition
    public static ErrorPage errorPage(String locationClass<? extends ThrowableexceptionType) {
        return new ErrorPage(locationexceptionType);
    }

    
Create an ErrorPage instance for a given response code

Parameters:
location The location to redirect to
statusCode The status code
Returns:
The error page definition
    public static ErrorPage errorPage(String locationint statusCode) {
        return new ErrorPage(locationstatusCode);
    }

    
Create an ErrorPage that corresponds to the default error page

Parameters:
location The error page location
Returns:
The error page instance
    public static ErrorPage errorPage(String location) {
        return new ErrorPage(location);
    }
New to GrepCode? Check out our FAQ X