protected void processJawrServlets ( String destDirPath , List < ServletDefinition > jawrServletDefinitions , boolean keepUrlMapping ) throws Exception { String appRootDir = "" ; String jsServletMapping = "" ; String cssServletMapping = "" ; String binaryServletMapping = "" ; for ( Iterator < ServletDefinition > iterator = jawrServletDefinitions . iterator ( ) ; iterator . hasNext ( ) ; ) { ServletDefinition servletDef = ( ServletDefinition ) iterator . next ( ) ; ServletConfig servletConfig = servletDef . getServletConfig ( ) ; // Force the production mode, and remove config listener parameters Map < ? , ? > initParameters = ( ( MockServletConfig ) servletConfig ) . getInitParameters ( ) ; initParameters . remove ( "jawr.config.reload.interval" ) ; String jawrServletMapping = servletConfig . getInitParameter ( JawrConstant . SERVLET_MAPPING_PROPERTY_NAME ) ; String servletMapping = servletConfig . getInitParameter ( JawrConstant . SPRING_SERVLET_MAPPING_PROPERTY_NAME ) ; if ( servletMapping == null ) { servletMapping = jawrServletMapping ; } ResourceBundlesHandler bundleHandler = null ; BinaryResourcesHandler binaryRsHandler = null ; // Retrieve the bundle Handler ServletContext servletContext = servletConfig . getServletContext ( ) ; String type = servletConfig . getInitParameter ( TYPE_INIT_PARAMETER ) ; if ( type == null || type . equals ( JawrConstant . JS_TYPE ) ) { bundleHandler = ( ResourceBundlesHandler ) servletContext . getAttribute ( JawrConstant . JS_CONTEXT_ATTRIBUTE ) ; String contextPathOverride = bundleHandler . getConfig ( ) . getContextPathOverride ( ) ; if ( StringUtils . isNotEmpty ( contextPathOverride ) ) { int idx = contextPathOverride . indexOf ( "//" ) ; if ( idx != - 1 ) { idx = contextPathOverride . indexOf ( "/" , idx + 2 ) ; if ( idx != - 1 ) { appRootDir = PathNormalizer . asPath ( contextPathOverride . substring ( idx ) ) ; } } } if ( jawrServletMapping != null ) { jsServletMapping = PathNormalizer . asPath ( jawrServletMapping ) ; } } else if ( type . equals ( JawrConstant . CSS_TYPE ) ) { bundleHandler = ( ResourceBundlesHandler ) servletContext . getAttribute ( JawrConstant . CSS_CONTEXT_ATTRIBUTE ) ; if ( jawrServletMapping != null ) { cssServletMapping = PathNormalizer . asPath ( jawrServletMapping ) ; } } else if ( type . equals ( JawrConstant . BINARY_TYPE ) ) { binaryRsHandler = ( BinaryResourcesHandler ) servletContext . getAttribute ( JawrConstant . BINARY_CONTEXT_ATTRIBUTE ) ; if ( jawrServletMapping != null ) { binaryServletMapping = PathNormalizer . asPath ( jawrServletMapping ) ; } } if ( bundleHandler != null ) { createBundles ( servletDef . getServlet ( ) , bundleHandler , destDirPath , servletMapping , keepUrlMapping ) ; } else if ( binaryRsHandler != null ) { createBinaryBundle ( servletDef . getServlet ( ) , binaryRsHandler , destDirPath , servletConfig , keepUrlMapping ) ; } } // Create the apache rewrite config file. createApacheRewriteConfigFile ( destDirPath , appRootDir , jsServletMapping , cssServletMapping , binaryServletMapping ) ; }
Process the Jawr Servlets