package com.siginfo.controller;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class TWebPingConfig {
    private String _sPingUrl;
    private String _sDbDriver;
    private String _sDbUrl;
    private String _sDbUser;
    private String _sDbPswd;
    
    public String getPingUrl() { return this._sPingUrl; }
    public String getDbDriver(){ return this._sDbDriver; }
    public String getDbUrl()   { return this._sDbUrl; }
    public String getDbUser()  { return this._sDbUser; }
    public String getDbPswd()  { return this._sDbPswd; }
    
    public String jdbcPath  = "/conf/jdbc.properties";
    public String _pingUrl  = "web.PING_URL";
    public String _driver   = "sigopen.Driver";
    public String _url      = "sigopen.Url";
    public String _username = "sigopen.Username";
    public String _password = "sigopen.Password";
    
    public void TWebPingConfg() {
    	this._sPingUrl = "http://61.108.209.27/";
    	this._sDbDriver= "oracle.jdbc.driver.OracleDriver";
    	this._sDbUrl   = "jdbc:oracle:thin:@192.168.10.14:1521:DWDB";
    	this._sDbUser  = "sigopen";
    	this._sDbPswd  = "sigopen";
    }
    
    public boolean loadConfig() throws IOException {
		InputStream in = null;

		in = TWebPingConfig.class.getResourceAsStream(jdbcPath);
		
        Properties properties = new Properties();
        if(in != null)
        {
        	properties.load(in);
	        in.close();
        }
        
        this._sPingUrl  = properties.getProperty(_pingUrl);
        this._sDbDriver = properties.getProperty(_driver);
        this._sDbUrl    = properties.getProperty(_url);
        this._sDbUser   = properties.getProperty(_username);
        this._sDbPswd   = properties.getProperty(_password);
        
		return true;
    }
}
