jawr-bundle-processor/src/main/java/net/jawr/web/bundle/processor/BundleProcessor.java
/**
	 * Create the apache rewrite configuration file
	 * 
	 * @param cdnDestDirPath
	 *            the CDN destination directory
	 * @param appRootDir
	 *            the application root dir path in the CDN
	 * @param jsServletMapping
	 *            the JS servlet mapping
	 * @param cssServletMapping
	 *            the CSS servlet mapping
	 * @param imgServletMapping
	 *            the image servlet mapping
	 * @throws IOException
	 *             if an IOException occurs.
	 */
Create the apache rewrite configuration file


Create the apache rewrite configuration file
protected void createApacheRewriteConfigFile(String cdnDestDirPath,
			String appRootDir, String jsServletMapping,
			String cssServletMapping, String imgServletMapping)
			throws IOException {
		BufferedReader templateFileReader = null;
		FileWriter fileWriter = null;
		try {
			templateFileReader = new BufferedReader(new InputStreamReader(this
					.getClass().getResourceAsStream(
							TEMPLATE_JAWR_APACHE_HTTPD_CONF_PATH)));
			fileWriter = new FileWriter(cdnDestDirPath + File.separator
					+ JAWR_APACHE_HTTPD_CONF_FILE);
			String line = null;
			boolean processNextString = true;
			while ((line = templateFileReader.readLine()) != null) {
				if (line.startsWith(CHECKS_JAWR_JS_SERVLET_MAPPING_EXISTS)) {
					if (StringUtils.isEmpty(jsServletMapping)) {
						processNextString = false;
					}
				} else if (line
						.startsWith(CHECK_JAWR_CSS_SERVLET_MAPPING_EXISTS)) {
					if (StringUtils.isEmpty(cssServletMapping)) {
						processNextString = false;
					}
				} else if (processNextString == false) {
					processNextString = true;
				} else {
					line = line.replaceAll(APP_ROOT_DIR_PATTERN, appRootDir);
					line = line.replaceAll(JAWR_JS_SERVLET_MAPPING_PATTERN,
							jsServletMapping);
					line = line.replaceAll(JAWR_CSS_SERVLET_MAPPING_PATTERN,
							cssServletMapping);
					line = line.replaceAll(JAWR_IMG_SERVLET_MAPPING_PATTERN,
							imgServletMapping);
					fileWriter.write(line + "\n");
				}
			}
		} finally {
			IOUtils.close(templateFileReader);
			IOUtils.close(fileWriter);
		}
	}
protected void createApacheRewriteConfigFile ( String cdnDestDirPath , String appRootDir , String jsServletMapping , String cssServletMapping , String imgServletMapping ) throws IOException { BufferedReader templateFileReader = null ; FileWriter fileWriter = null ; try { templateFileReader = new BufferedReader ( new InputStreamReader ( this . getClass ( ) . getResourceAsStream ( TEMPLATE_JAWR_APACHE_HTTPD_CONF_PATH ) ) ) ; fileWriter = new FileWriter ( cdnDestDirPath + File . separator + JAWR_APACHE_HTTPD_CONF_FILE ) ; String line = null ; boolean processNextString = true ; while ( ( line = templateFileReader . readLine ( ) ) != null ) { if ( line . startsWith ( CHECKS_JAWR_JS_SERVLET_MAPPING_EXISTS ) ) { if ( StringUtils . isEmpty ( jsServletMapping ) ) { processNextString = false ; } } else if ( line . startsWith ( CHECK_JAWR_CSS_SERVLET_MAPPING_EXISTS ) ) { if ( StringUtils . isEmpty ( cssServletMapping ) ) { processNextString = false ; } } else if ( processNextString == false ) { processNextString = true ; } else { line = line . replaceAll ( APP_ROOT_DIR_PATTERN , appRootDir ) ; line = line . replaceAll ( JAWR_JS_SERVLET_MAPPING_PATTERN , jsServletMapping ) ; line = line . replaceAll ( JAWR_CSS_SERVLET_MAPPING_PATTERN , cssServletMapping ) ; line = line . replaceAll ( JAWR_IMG_SERVLET_MAPPING_PATTERN , imgServletMapping ) ; fileWriter . write ( line + "\n" ) ; } } } finally { IOUtils . close ( templateFileReader ) ; IOUtils . close ( fileWriter ) ; } }
Create the apache rewrite configuration file
Create the apache rewrite configuration file
// If the line starts with the condition to check the existence // of the JS servlet mapping, // sets the processNextString flag accordingly // If the line starts with the condition to check the // existence of the servlet mapping, // sets the processNextString flag accordingly // If the processNextString flag is set to false, skip the // current line, and process the next one // Make the replacement