package com.platform.utils; import java.util.Properties; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; 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("").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_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.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"); 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; } }