package com.tandbergtv.watchpoint.pmm.util;

import static java.io.File.separator;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

/**
 * Reads conf/pmm/pmm.properties file as {@link Properties} object.
 * 
 * @author rprakash
 *
 */
public class PMMProperties extends Properties {
	private static final long serialVersionUID = -8189933609849022702L;

	private static final String PRODUCT_DIR = "com.tandbergtv.cms.product.dir";
	private static final String PMM_CONFIG_DIR = "pmm";
	private static final String CONFIG_FILE = "pmm.properties";

	private static PMMProperties _instance;
	
	private PMMProperties() {}
	
	public static synchronized PMMProperties getInstance() throws FileNotFoundException, IOException {
		if(_instance == null) {
			_instance = new PMMProperties();
			String confDir = System.getProperty(PRODUCT_DIR) + separator + "conf";
			String fileName = confDir + separator + PMM_CONFIG_DIR + separator + CONFIG_FILE;
			_instance.load(new FileInputStream(new File(fileName)));
		}
		return _instance;
	}
}
