package com.platform.utils; import java.util.Properties; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import com.platform.http.gfs.HttpClientConstant; /** web容器初始化 * @author chen * */ public class ConfigsLoader implements ServletContextListener { private static ConfigPropertyReader cReader = null; @Override public void contextDestroyed(ServletContextEvent sEvent) { // TODO Auto-generated method stub Configs.CONSOLE_LOGGER.info("系统停止.."); } @SuppressWarnings("static-access") @Override public void contextInitialized(ServletContextEvent sEvent) { // TODO Auto-generated method stub Configs.CONSOLE_LOGGER.info("系统初始化.."); String contextPath = sEvent.getServletContext().getRealPath("/") + "WEB-INF/config/config.properties"; this.cReader = ConfigPropertyReader.Builder(contextPath); init(); new ThreadVolume("ThreadVolume-in-ConfigsLoader").start(); } public static void init() { Properties properties = cReader.getProperties(); Configs.KUBE_MASTER_URL = properties.getProperty("kubeMasterUrl"); Configs.COLLECT_USER_NAME = properties.getProperty("collect-user-name"); Configs.COLLECT_PASSWORD = properties.getProperty("collect-password"); Configs.COLLECT_SERVICE_NAME = properties .getProperty("collect-service-name"); Configs.GATHER_USER_NAME = properties.getProperty("gather-user-name"); Configs.GATHER_USER_PASSWORD = properties .getProperty("gather-user-password"); Configs.GATHER_STANDARD_USER_NAME = properties .getProperty("gather-standard-user-name"); Configs.GATHER_STANDARD_EXEC_TABLE_NAME = properties .getProperty("gather-standard-exec-table-name"); Configs.GATHER_STANDARD_PAY_TABLE_NAME = properties .getProperty("gather-standard-pay-table-name"); Configs.GATHER_PORT = properties.getProperty("gather-port"); Configs.GATHER_SERVICE_NAME = properties .getProperty("gather-service-name"); Configs.TABLE_SUFFIX = properties.getProperty("table-suffix"); Configs.EXTRACT_LOG_LOCALTION = properties .getProperty("extract-log-localtion"); Configs.EXTRACT_STANDARD_LOG_LOCALTION = properties .getProperty("extract-standard-log-localtion"); Configs.GATHER_TABLESPACE_NAME = properties .getProperty("gather-tablespace-name"); Configs.GATHER_TABLESPACE_PATH = properties .getProperty("gather-tablespace-path"); Configs.GATHER_TABLE_PASSWORD=properties.getProperty("gather-table-user-password"); Configs.FILE_UPLOAD_PATH = properties.getProperty("file_upload_path"); Configs.FILE_DOWNLOAD_PATH = properties.getProperty("file_download_path"); Configs.PACKAGE_DOWNLOAD_PATH = properties.getProperty("package_download_path"); Configs.PACKAGE_NAME = properties.getProperty("package_name"); Configs.SQL_SCRIPT_PATH_LAST = properties.getProperty("sql_script_path_last"); Configs.SQL_SCRIPT_PATH_STANDARD = properties.getProperty("sql_script_path_standard"); Configs.dataBefore = Integer.valueOf(properties.getProperty("dataBefore")); Configs.NUM_ONE_IMPORT_EXCEL = Integer.valueOf(properties.getProperty("numOneImportExcel")); Configs.ORACLE_ORCL = properties.getProperty("oracle-orcl"); Configs.ORACLE_USER = properties.getProperty("oracle-user"); Configs.ORACLE_PSW = properties.getProperty("oracle-psw"); Configs.COLLECT_STANDARD_TABLE_USER= properties.getProperty("collect-user-table"); Configs.COLLECT_EXEC_TABLE = properties.getProperty("collect-exec-table"); Configs.COLLECT_PAY_TABLE = properties.getProperty("collect-pay-table"); HttpClientConstant.URL_IP_PORT = properties.getProperty("HttpClientConstant_URL_IP_PORT").trim(); Constant.hostIp=properties.getProperty("gfs_control_ip").trim(); Constant.rootPasswd=properties.getProperty("gfs_control_rootPassWd").trim(); Constant.ganymedSSH = new GanymedSSH(Constant.hostIp, Constant.rootUser, Constant.rootPasswd, Constant.port); } public ConfigPropertyReader getcReader() { return cReader; } @SuppressWarnings("static-access") public void setcReader(ConfigPropertyReader cReader) { this.cReader = cReader; } }