package ve.gob.cnti.receiver.utils;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.Properties;
import java.util.logging.Logger;


public class PropertiesReader implements IPropertiesReader {
	

	
	Properties props = new Properties(); 
	private static final Logger log = Logger.getLogger(PropertiesReader.class.getName());
	public PropertiesReader(){
		log.info("Ubicacion del Archivo de configuracion="+System.getProperty("jboss.server.config.dir")+"/"+"receiverEJB.properties");	
		FileInputStream inputStream = null;
		String path=System.getProperty("jboss.server.config.dir")+"/"+"receiverEJB.properties";
		try {	 
			inputStream = new FileInputStream(path);
			props.load(inputStream);		
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public PropertiesReader(String processName){
		log.info("Ubicacion del Archivo de configuracion="+System.getProperty("jboss.server.config.dir")+"/"+processName);	
		InputStream inputStream = null;
		String path=System.getProperty("jboss.server.config.dir")+"/"+processName+".properties";
		try {	 
			inputStream = new FileInputStream(path);
			Reader reader = new InputStreamReader(inputStream, "UTF-8");
			props.load(reader);		
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	

	public String getProperty(String key){		
		//System.out.println("clave="+key+"resultado"+props.getProperty(key));
		return props.getProperty(key);
		
	} 
	
	public PropertiesReader(String pathtest,String test){
		//log.info("Ubicacion del Archivo de configuracion="+System.getProperty("jboss.server.config.dir")+"/"+processName);	
		FileInputStream inputStream = null;
		String path=pathtest+".properties";
		try {	 
			inputStream = new FileInputStream(path);
			props.load(inputStream);		
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	
		

}
