File file = (File) customFilesByFileName.get("custom-libraries.xml");
File file = (File) customFilesByFileName.get("custom-apis.xml");
	public DeviceDatabase( Map properties, File polishHome, File projectHome, File apisHome, 			PolishProject polishProject, Map inputStreamsByFileName, Map customFilesByFileName ) 	{		super();		try {			String wtkHomePath = (String) properties.get( "wtk.home" );			if (wtkHomePath == null) {				throw new BuildException("Unable to initialise device database - found no wtk.home property.");			}			File wtkHome = new File( wtkHomePath );						// load capability-definitions:			InputStream is = getInputStream( "capabilities.xml", polishHome, inputStreamsByFileName ); 			this.capabilityManager = new CapabilityManager( properties, is );						// load libraries:			is = getInputStream( "apis.xml", polishHome, inputStreamsByFileName );			this.libraryManager = new LibraryManager( properties, apisHome, wtkHome, is );			File file = (File) customFilesByFileName.get("custom-libraries.xml");			if ( file != null ) {				this.libraryManager.loadCustomLibraries( file );			} else {				// use default libraries:				file = new File( polishHome, "custom-libraries.xml");				if (file.exists()) {					this.libraryManager.loadCustomLibraries( file );				}				file = new File( projectHome, "custom-libraries.xml");				if (file.exists()) {					this.libraryManager.loadCustomLibraries( file );				}			}						// load configurations:			is = getInputStream("configurations.xml", polishHome, inputStreamsByFileName);			this.configurationManager = new ConfigurationManager( this.capabilityManager, is );			/*			file = (File) customFilesByFileName.get("custom-configurations.xml");			if ( file != null ) {				this.configurationManager.loadCustomConfigurations( file );			} else {				// use default libraries:				file = new File( polishHome, "custom-libraries.xml");				if (file.exists()) {					this.libraryManager.loadCustomLibraries( file );				}				file = new File( projectHome, "custom-libraries.xml");				if (file.exists()) {					this.libraryManager.loadCustomLibraries( file );				}			}			*/			// load platforms:			is = getInputStream("platforms.xml", polishHome, inputStreamsByFileName);			this.platformManager = new PlatformManager( this.capabilityManager, is );									// load vendors:			is = getInputStream("vendors.xml", polishHome, inputStreamsByFileName);			this.vendorManager = new VendorManager( polishProject,  is, this.capabilityManager);			file = (File) customFilesByFileName.get("custom-vendors.xml");			if ( file != null ) {				this.vendorManager.loadCustomVendors( file, polishProject, this.capabilityManager );			} else {				// use default vendors:				file = new File( polishHome, "custom-vendors.xml");				if (file.exists()) {					this.vendorManager.loadCustomVendors( file, polishProject, this.capabilityManager );				}				file = new File( projectHome, "custom-vendors.xml");				if (file.exists()) {					this.vendorManager.loadCustomVendors( file, polishProject, this.capabilityManager );				}			}						// load device groups:			is = getInputStream("groups.xml", polishHome, inputStreamsByFileName);			this.groupManager = new DeviceGroupManager( is, this.capabilityManager );			file = (File) customFilesByFileName.get("custom-groups.xml");			if ( file != null ) {				this.groupManager.loadCustomGroups( file, this.capabilityManager );			} else {				// use default vendors:				file = new File( polishHome, "custom-groups.xml");				if (file.exists()) {					this.groupManager.loadCustomGroups( file, this.capabilityManager );				}				file = new File( projectHome, "custom-groups.xml");				if (file.exists()) {					this.groupManager.loadCustomGroups( file, this.capabilityManager );				}			}						// load devices:			is = getInputStream("devices.xml", polishHome, inputStreamsByFileName);			this.deviceManager = new DeviceManager( this.configurationManager, this.platformManager, this.vendorManager, this.groupManager, this.libraryManager, this.capabilityManager, is );			file = (File) customFilesByFileName.get("custom-devices.xml");			if ( file != null ) {				this.deviceManager.loadCustomDevices( this.configurationManager, this.platformManager, this.vendorManager, this.groupManager, this.libraryManager, this.capabilityManager, file );			} else {				// use default vendors:				file = new File( polishHome, "custom-devices.xml");				if (file.exists()) {					this.deviceManager.loadCustomDevices( this.configurationManager, this.platformManager, this.vendorManager, this.groupManager, this.libraryManager, this.capabilityManager, file );				}				file = new File( projectHome, "custom-devices.xml");				if (file.exists()) {					this.deviceManager.loadCustomDevices( this.configurationManager, this.platformManager, this.vendorManager, this.groupManager, this.libraryManager, this.capabilityManager, file );				}			}					} catch (JDOMException e) {			throw new BuildException("unable to create device database: " + e.getMessage(), e );		} catch (IOException e) {			throw new BuildException("unable to create device database: " + e.getMessage(), e );		} catch (InvalidComponentException e) {			throw new BuildException("unable to create device database: " + e.getMessage(), e );		}	}