private void initMapping ( BinaryResourcesHandler binaryRsHandler ) { if ( jawrConfig . getUseBundleMapping ( ) && rsBundleHandler . isExistingMappingFile ( ) ) { // Initialize the binary web resource mapping Iterator < Entry < Object , Object > > mapIterator = bundleMapping . entrySet ( ) . iterator ( ) ; while ( mapIterator . hasNext ( ) ) { Entry < Object , Object > entry = mapIterator . next ( ) ; binaryRsHandler . addMapping ( ( String ) entry . getKey ( ) , entry . getValue ( ) . toString ( ) ) ; } } else { // Create a resource handler to read files from the WAR archive or // exploded dir. String binaryResourcesDefinition = jawrConfig . getBinaryResourcesDefinition ( ) ; if ( binaryResourcesDefinition != null ) { StringTokenizer tokenizer = new StringTokenizer ( binaryResourcesDefinition , "," ) ; while ( tokenizer . hasMoreTokens ( ) ) { String pathMapping = tokenizer . nextToken ( ) ; // path is a generated image and ends with an image // extension if ( generatorRegistry . isGeneratedBinaryResource ( pathMapping ) && hasBinaryFileExtension ( pathMapping ) ) { addBinaryResourcePath ( binaryRsHandler , pathMapping ) ; } // path ends in /, the folder is included without subfolders else if ( pathMapping . endsWith ( "/" ) ) { addItemsFromDir ( binaryRsHandler , pathMapping , false ) ; } // path ends in /, the folder is included with all // subfolders else if ( pathMapping . endsWith ( "/**" ) ) { addItemsFromDir ( binaryRsHandler , pathMapping . substring ( 0 , pathMapping . lastIndexOf ( "**" ) ) , true ) ; } else if ( hasBinaryFileExtension ( pathMapping ) ) { addBinaryResourcePath ( binaryRsHandler , pathMapping ) ; } else LOGGER . warn ( "Wrong mapping [" + pathMapping + "] for image bundle. Please check configuration. " ) ; } } } // Store the bundle mapping if ( jawrConfig . getUseBundleMapping ( ) && ! rsBundleHandler . isExistingMappingFile ( ) ) { rsBundleHandler . storeJawrBundleMapping ( bundleMapping ) ; } if ( LOGGER . isDebugEnabled ( ) ) LOGGER . debug ( "Finish creation of map for image bundle" ) ; }
Initialize the mapping of the binary web resources handler