src/org/ohmage/jee/listener/ConfigurationFileImport.java
@Override
	public void contextInitialized(ServletContextEvent event) {
		// An empty Properties object that will be populated with the default
		// configuration.
		Properties defaultProperties = new Properties();
		File defaultConfiguration = 
			new File(
				event.getServletContext().getRealPath("/") + 
					CONFIG_FILE_DEFAULT);
		try {
			defaultProperties.load(new FileReader(defaultConfiguration));
		}
		// The default properties file didn't exist, which is alarming.
		catch(FileNotFoundException e) {
			LOGGER
				.log(
					Level.WARNING, 
					"The default properties file is missing: " +
						defaultConfiguration.getAbsolutePath(),
					e);
		}
		// There was an error reading the default properties file.
		catch(IOException e) {
			LOGGER
				.log(
					Level.WARNING, 
					"There was an error reading the default properties " +
						"file: " +
						defaultConfiguration.getAbsolutePath(),
					e);
		}
		
		// Get a handler for the properties file based on the operating system.
		File propertiesFile;
		if(System.getProperty("ohmage.config") != null) {
			propertiesFile = new File(System.getProperty("ohmage.config"));
		}
		else if(System.getProperty("os.name").contains("Windows")) {
			propertiesFile = new File(CONFIG_FILE_DEFAULT_WINDOWS);
		}
		else {
			propertiesFile = new File(CONFIG_FILE_DEFAULT_POSIX);
		}
		
		// Attempts to retrieve the custom configuration file and store it.
		Properties customProperties = new Properties();
		try {
			customProperties.load(new FileReader(propertiesFile));
			LOGGER
				.log(
					Level.INFO,
					"The properties file was imported: " +
						propertiesFile.getAbsolutePath());
		}
		// The properties file didn't exist, which is fine.
		catch(FileNotFoundException e) {
			LOGGER
				.log(
					Level.INFO,
					"The properties file does not exist: " +
						propertiesFile.getAbsolutePath());
		}
		// There was a problem reading the properties.
		catch(IOException e) {
			LOGGER
				.log(
					Level.WARNING, 
					"There was an error reading the properties file: " +
						propertiesFile.getAbsolutePath(),
					e);
		}
		
		// Set the properties files.
		PROPERTIES_ARRAY[0] = defaultProperties;
		PROPERTIES_ARRAY[1] = customProperties;
		
		// Create a merged properties and save it.
		for(Object key : defaultProperties.keySet()) {
			PROPERTIES.put(key, defaultProperties.get(key));
		}
		for(Object key : customProperties.keySet()) {
			PROPERTIES.put(key, customProperties.get(key));
		}
	}
/**
	 * Find the log file, if it exists, and add its properties to the system
	 * properties.
	 */
Find the log file, if it exists, and add its properties to the system
properties.
Find the log file if it exists and add its properties to the system properties .
@Override
	public void contextInitialized(ServletContextEvent event) {
		Properties defaultProperties = new Properties();
		File defaultConfiguration = 
			new File(
				event.getServletContext().getRealPath("/") + 
					CONFIG_FILE_DEFAULT);
		try {
			defaultProperties.load(new FileReader(defaultConfiguration));
		}
		catch(FileNotFoundException e) {
			LOGGER
				.log(
					Level.WARNING, 
					"The default properties file is missing: " +
						defaultConfiguration.getAbsolutePath(),
					e);
		}
		catch(IOException e) {
			LOGGER
				.log(
					Level.WARNING, 
					"There was an error reading the default properties " +
						"file: " +
						defaultConfiguration.getAbsolutePath(),
					e);
		}
		File propertiesFile;
		if(System.getProperty("ohmage.config") != null) {
			propertiesFile = new File(System.getProperty("ohmage.config"));
		}
		else if(System.getProperty("os.name").contains("Windows")) {
			propertiesFile = new File(CONFIG_FILE_DEFAULT_WINDOWS);
		}
		else {
			propertiesFile = new File(CONFIG_FILE_DEFAULT_POSIX);
		}
		Properties customProperties = new Properties();
		try {
			customProperties.load(new FileReader(propertiesFile));
			LOGGER
				.log(
					Level.INFO,
					"The properties file was imported: " +
						propertiesFile.getAbsolutePath());
		}
		catch(FileNotFoundException e) {
			LOGGER
				.log(
					Level.INFO,
					"The properties file does not exist: " +
						propertiesFile.getAbsolutePath());
		}
		catch(IOException e) {
			LOGGER
				.log(
					Level.WARNING, 
					"There was an error reading the properties file: " +
						propertiesFile.getAbsolutePath(),
					e);
		}
		PROPERTIES_ARRAY[0] = defaultProperties;
		PROPERTIES_ARRAY[1] = customProperties;
		for(Object key : defaultProperties.keySet()) {
			PROPERTIES.put(key, defaultProperties.get(key));
		}
		for(Object key : customProperties.keySet()) {
			PROPERTIES.put(key, customProperties.get(key));
		}
	}
@ Override public void contextInitialized ( ServletContextEvent event ) { Properties defaultProperties = new Properties ( ) ; File defaultConfiguration = new File ( event . getServletContext ( ) . getRealPath ( "/" ) + CONFIG_FILE_DEFAULT ) ; try { defaultProperties . load ( new FileReader ( defaultConfiguration ) ) ; } catch ( FileNotFoundException e ) { LOGGER . log ( Level . WARNING , "The default properties file is missing: " + defaultConfiguration . getAbsolutePath ( ) , e ) ; } catch ( IOException e ) { LOGGER . log ( Level . WARNING , "There was an error reading the default properties " + "file: " + defaultConfiguration . getAbsolutePath ( ) , e ) ; } File propertiesFile ; if ( System . getProperty ( "ohmage.config" ) != null ) { propertiesFile = new File ( System . getProperty ( "ohmage.config" ) ) ; } else if ( System . getProperty ( "os.name" ) . contains ( "Windows" ) ) { propertiesFile = new File ( CONFIG_FILE_DEFAULT_WINDOWS ) ; } else { propertiesFile = new File ( CONFIG_FILE_DEFAULT_POSIX ) ; } Properties customProperties = new Properties ( ) ; try { customProperties . load ( new FileReader ( propertiesFile ) ) ; LOGGER . log ( Level . INFO , "The properties file was imported: " + propertiesFile . getAbsolutePath ( ) ) ; } catch ( FileNotFoundException e ) { LOGGER . log ( Level . INFO , "The properties file does not exist: " + propertiesFile . getAbsolutePath ( ) ) ; } catch ( IOException e ) { LOGGER . log ( Level . WARNING , "There was an error reading the properties file: " + propertiesFile . getAbsolutePath ( ) , e ) ; } PROPERTIES_ARRAY [ 0 ] = defaultProperties ; PROPERTIES_ARRAY [ 1 ] = customProperties ; for ( Object key : defaultProperties . keySet ( ) ) { PROPERTIES . put ( key , defaultProperties . get ( key ) ) ; } for ( Object key : customProperties . keySet ( ) ) { PROPERTIES . put ( key , customProperties . get ( key ) ) ; } }
Find the log file, if it exists, and add its properties to the system
 properties.
Find the log file if it exists and add its properties to the system properties .
// An empty Properties object that will be populated with the default // configuration. // The default properties file didn't exist, which is alarming. // There was an error reading the default properties file. // Get a handler for the properties file based on the operating system. // Attempts to retrieve the custom configuration file and store it. // The properties file didn't exist, which is fine. // There was a problem reading the properties. // Set the properties files. // Create a merged properties and save it.