anchor.diff:  		        ln -sf $j ${cfg.baseDir}/webapps/`basename $j`
   		    done
   		fi
  -	    done 
  +	    done	    	    
  +	    
  +	    ${toString (map (virtualHost: ''
  +	      # Create webapps directory for the virtual host
  +	      mkdir -p ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps
  +	      
  +	      # Modify ownership
  +	      chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps
  +	      
  +	      # Symlink all the given web applications files or paths into the webapps/ directory
  +	      # of this virtual host
  +	      for i in ${toString virtualHost.webapps}
  +	      do
  +		  if [ -f $i ]
  +		  then
  +		      # If the given web application is a file, symlink it into the webapps/ directory
  +		      ln -sf $i ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps/`basename $i`
  +		  elif [ -d $i ]
  +		  then
  +		      # If the given web application is a directory, then iterate over the files
  +		      # in the special purpose directories and symlink them into the tomcat tree
  +		    
  +		      for j in $i/webapps/*
  +		      do
  +		          ln -sf $j ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps/`basename $j`
  +		      done
  +                  fi	                  
  +	      done
  +	      
  +	      ''
  +	    ) cfg.virtualHosts) }
   	    
   	    # Create a work/ directory
   	    mkdir -p ${cfg.baseDir}/work
  
positive.code: 			ln -sf $j ${cfg.baseDir}/lib/`basename $j`
  		    done
  		fi
  	    done 
  
  	    # Symlink all the given shared libs files or paths into the shared/lib/ directory
  	    for i in ${toString cfg.sharedLibs}
  
negative.code: 	    sed -e 's|''${catalina.home}|''${catalina.base}|g' \
                  -e 's|shared.loader=|shared.loader=''${catalina.base}/shared/lib/*.jar|' \
  		${pkgs.tomcat6}/conf/catalina.properties > ${cfg.baseDir}/conf/catalina.properties
  	    
  	    # Create a modified server.xml which also includes all virtual hosts
  	    sed -e "/<Engine name=\"Catalina\" defaultHost=\"localhost\">/a\  ${toString (map (virtualHost: ''<Host name=\"${virtualHost.name}\" appBase=\"virtualhosts/${virtualHost.name}/webapps\" unpackWARs=\"true\" autoDeploy=\"true\" xmlValidation=\"false\" xmlNamespaceAware=\"false\" />'' ) cfg.virtualHosts)}" \
  	        ${pkgs.tomcat6}/conf/server.xml > ${cfg.baseDir}/conf/server.xml
  	    
  	    # Create a logs/ directory
  	    mkdir -p ${cfg.baseDir}/logs
  	    chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/logs
  