SoapParam.java 3.33 KB
package com.sitech.ismp.coll.tivoli.linux;

import java.net.InetAddress;
import java.util.ResourceBundle;

/**
 * 该类负责的读取tivoli.properties配置文件
 * 得到相关配置信息
 * 
 * @author winnerbao
 *
 */

public class SoapParam
{
/*
            public static final String RMIPORT = "RMIPORT";
            public static final String HTMLROOTDIR = "HTMLROOTDIR";
            public static final String HTMLPORT = "HTMLPORT";
            public static final String HTTPADAPTORPORT = "HTTPADAPTORPORT"; 
            public static final String HOSTADDRESS = "HOSTADDRESS"; 
            public static final String JMXSERVICEURLADDRESSPORT = "JMXSERVICEURLADDRESSPORT"; 
*/		
        static ResourceBundle MASTERAGENTINFO = null;

        static {
            try{
                        MASTERAGENTINFO = ResourceBundle.getBundle("tivoli");
                        
/*                        
                        String rmiport = LogfileInfo.getString(RMIPORT);
                        
                        String syslogFile = LogfileInfo.getString(HTMLROOTDIR);
                        String syslogFile = LogfileInfo.getString(HTMLPORT);
                        String syslogFile = LogfileInfo.getString(JMXSERVICEURLADDRESSPORT);
                        String syslogFile = LogfileInfo.getString(HTTPADAPTORPORT);

//                        String syslogFile = LogfileInfo.getString(HOSTADDRESS);
                        String hostaddress = InetAddress.getLocalHost().toString();                                                                           
*/                                                
            }
            catch(Exception e){
                System.out.println("Bundle MASTERAGENT.properties error.");
                e.printStackTrace();
            }
        }

        public static int getInt(String paramname) {
//                ResourceBundle MASTERAGENTINFO =   ResourceBundle.getBundle("MASTERAGENT");
                int paramvalue = 0;
                try{
                    String cParamvalue = (String)MASTERAGENTINFO.getString(paramname);
                    paramvalue = Integer.parseInt(cParamvalue);
                }
                catch(Exception e){
                    System.out.println("get param " + paramname + "error.");
                    e.printStackTrace();
                }
                return paramvalue;
        }

        public static String getString(String paramname) {
//                ResourceBundle MASTERAGENTINFO =   ResourceBundle.getBundle("MASTERAGENT");
                if(paramname!=null && paramname.equals("HOSTADDR")){
                    return getHOSTADDR();
                }
                Object value = MASTERAGENTINFO.getString(paramname);
                
                String paramvalue = null;
                if(value==null)
                	paramvalue="";
                else
                    paramvalue = (String)value;
                
                return paramvalue;
                
        }

        
        public static String getHOSTADDR() {
                String paramvalue = "127.0.0.1";
                try{
                    paramvalue = InetAddress.getLocalHost().toString();              
                }
                catch(Exception e){
                    e.printStackTrace();
                }
                return paramvalue;
        }

}