private static void parseServlets ( final ServletType servletType , final WebApp webApp ) { final WebAppServlet servlet = new WebAppServlet ( ) ; servlet . setServletName ( servletType . getServletName ( ) . getValue ( ) ) ; if ( servletType . getServletClass ( ) != null ) { servlet . setServletClassName ( servletType . getServletClass ( ) . getValue ( ) ) ; webApp . addServlet ( servlet ) ; } else { String jspFile = servletType . getJspFile ( ) . getValue ( ) ; if ( jspFile != null ) { WebAppJspServlet jspServlet = new WebAppJspServlet ( ) ; jspServlet . setServletName ( servletType . getServletName ( ) . getValue ( ) ) ; jspServlet . setJspPath ( jspFile ) ; webApp . addServlet ( jspServlet ) ; } } servlet . setLoadOnStartup ( servletType . getLoadOnStartup ( ) ) ; if ( servletType . getAsyncSupported ( ) != null ) { servlet . setAsyncSupported ( servletType . getAsyncSupported ( ) . isValue ( ) ) ; } MultipartConfigType multipartConfig = servletType . getMultipartConfig ( ) ; if ( multipartConfig != null ) { String location ; if ( multipartConfig . getLocation ( ) == null ) { location = null ; } else { location = multipartConfig . getLocation ( ) . getValue ( ) ; } long maxFileSize ; if ( multipartConfig . getMaxFileSize ( ) == null ) { maxFileSize = - 1L ; } else { maxFileSize = multipartConfig . getMaxFileSize ( ) ; } long maxRequestSize ; if ( multipartConfig . getMaxRequestSize ( ) == null ) { maxRequestSize = - 1L ; } else { maxRequestSize = multipartConfig . getMaxRequestSize ( ) ; } int fileSizeThreshold ; if ( multipartConfig . getFileSizeThreshold ( ) == null ) { fileSizeThreshold = 0 ; } else { fileSizeThreshold = multipartConfig . getFileSizeThreshold ( ) . intValue ( ) ; } MultipartConfigElement multipartConfigElement = new MultipartConfigElement ( location , maxFileSize , maxRequestSize , fileSizeThreshold ) ; servlet . setMultipartConfig ( multipartConfigElement ) ; } List < ParamValueType > servletInitParams = servletType . getInitParam ( ) ; for ( ParamValueType initParamElement : servletInitParams ) { final WebAppInitParam initParam = new WebAppInitParam ( ) ; initParam . setParamName ( initParamElement . getParamName ( ) . getValue ( ) ) ; initParam . setParamValue ( initParamElement . getParamValue ( ) . getValue ( ) ) ; servlet . addInitParam ( initParam ) ; } }
Parses servlets and servlet mappings out of web . xml .