private FileHandler htaccess_resolveFileHandler( URI requestURI,
						     File requestedFile,
						     String fileExtension,
						     HypertextAccessFile htaccess ) 
	throws ConfigurationException {

	// Use this order:
	//  (i)    The 'AddHandler' settings (extension-specific; overrides directory-wide 'SetHandler' directive).
	//  (ii)   The 'SetHandler' setting (overrides the global default handler)

	if( htaccess != null ) {

	    this.getHTTPHandler().getLogger().log( Level.INFO,
						   getClass().getName() + ".resolveFileHandler(...)",
						   "Looking up fileExtension='"+ fileExtension + "' in htaccess file (checking for 'AddHandler' directive)." );

	    if( fileExtension != null ) {
	    	    
		Map<String,List<String>> htaccess_addedHandlers = htaccess.getAddedHandlers();
		Iterator<Map.Entry<String,List<String>>> iter = htaccess_addedHandlers.entrySet().iterator();
		while( iter.hasNext() ) {

		    Map.Entry<String,List<String>> entry = iter.next();
		    String handlerName                   = entry.getKey();
		    List<String> handlerExtensions       = entry.getValue();

		    // Check if the file's extension is inside the current handler's extension list.
		    for( int i = 0; i < handlerExtensions.size(); i++ ) {

			// Note from the apache specs: 
			//   "The extension argument is case-insensitive and can be specified with or without a leading dot"
			String handlerExt                    = handlerExtensions.get(i);
			boolean equalFileExtensions          = CustomUtil.equalFileExtensions( fileExtension,
											       handlerExt,
											       false,      // not case sensitive
											       false       // not dot sensitive
											       );
			
			if( equalFileExtensions ) {
			    
			    // The extensions are equal. 
			    // Resolve associated handler from the global config.
			    FileHandler fileHandler = this.getHTTPHandler().getFileHandlerByName( handlerName );

			    if( fileHandler == null ) {

				this.getHTTPHandler().getLogger().log( Level.SEVERE,
								       getClass().getName() + ".resolveFileHandler(...)",
								       "The htaccess file contains an 'AddHandler' directive for the file extension '" + fileExtension + "' but the retrieved file handler name '"+ handlerName +"' was not found in the global configuration! requestedURI=" + requestURI.getPath() );
				throw new ConfigurationException( "A requested file handler was not found [0].", null );

			    } else {

				return fileHandler;

			    }
			}
		    }

		}

	    } // END if [fileExtension != null]
	    
	    
	    // Obviously no FileHandler was found by the use of 'AddHandler' here.	    
	    // Continue with 'SetHandler'. 
	    String handlerName = htaccess.getSetHandler();
	    if( handlerName != null ) {
		
		FileHandler fileHandler = this.getHTTPHandler().getFileHandlerByName( handlerName );

		if( fileHandler == null ) {

		    this.getHTTPHandler().getLogger().log( Level.SEVERE,
							   getClass().getName() + ".resolveFileHandler(...)",
							   "The htaccess file contains an 'SetHandler' directive for the file extension '" + fileExtension + "' but the retrieved file handler name '" + handlerName + "' was not found in the global configuration! requestedURI=" + requestURI.getPath() );
		    throw new ConfigurationException( "A requested file handler was not found [0].", null );

		} else {

		    return fileHandler;

		}

	    }
	} // END if [htaccess != null]

	// System.out.println( "File extension: " + fileExtension );

	// It seems there is no 'AddHandler' and no 'SetHandler' directive in the htaccess file.
	// Use default global setting (if available).
	return this.getHTTPHandler().getFileHandlerByExtension( fileExtension );
    }