update
This commit is contained in:
parent
fd10f6c81a
commit
c49c4cdc4f
|
|
@ -1,23 +1,27 @@
|
|||
package com.smallchill.core.constant;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.smallchill.core.listener.ConfigListener;
|
||||
|
||||
public interface ConstConfig {
|
||||
|
||||
String DBTYPE = ConfigListener.map.get("master.dbType");
|
||||
String DRIVER = ConfigListener.map.get("master.driver");
|
||||
String URL = ConfigListener.map.get("master.url");
|
||||
String USERNAME = ConfigListener.map.get("master.username");
|
||||
String PASSWORD = ConfigListener.map.get("master.password");
|
||||
String INITIALSIZE = ConfigListener.map.get("druid.initialSize");
|
||||
String MAXACTIVE = ConfigListener.map.get("druid.maxActive");
|
||||
String MINIDLE = ConfigListener.map.get("druid.minIdle");
|
||||
String MAXWAIT = ConfigListener.map.get("druid.maxWait");
|
||||
Map<String, String> pool = ConfigListener.getConf();
|
||||
|
||||
String DBTYPE = pool.get("master.dbType");
|
||||
String DRIVER = pool.get("master.driver");
|
||||
String URL = pool.get("master.url");
|
||||
String USERNAME = pool.get("master.username");
|
||||
String PASSWORD = pool.get("master.password");
|
||||
String INITIALSIZE = pool.get("druid.initialSize");
|
||||
String MAXACTIVE = pool.get("druid.maxActive");
|
||||
String MINIDLE = pool.get("druid.minIdle");
|
||||
String MAXWAIT = pool.get("druid.maxWait");
|
||||
|
||||
String DOMAIN = ConfigListener.map.get("config.domain");
|
||||
String REMOTE_MODE = ConfigListener.map.get("config.remoteMode");
|
||||
String REMOTE_PATH = ConfigListener.map.get("config.remotePath");
|
||||
String UPLOAD_PATH = ConfigListener.map.get("config.uploadPath");
|
||||
String DOWNLOAD_PATH = ConfigListener.map.get("config.downloadPath");
|
||||
String DOMAIN = pool.get("config.domain");
|
||||
String REMOTE_MODE = pool.get("config.remoteMode");
|
||||
String REMOTE_PATH = pool.get("config.remotePath");
|
||||
String UPLOAD_PATH = pool.get("config.uploadPath");
|
||||
String DOWNLOAD_PATH = pool.get("config.downloadPath");
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,12 +71,12 @@ public class Cst {
|
|||
/**
|
||||
* 项目物理路径
|
||||
*/
|
||||
private String realPath = ConfigListener.map.get("realPath");
|
||||
private String realPath = ConfigListener.getConf().get("realPath");
|
||||
|
||||
/**
|
||||
* 项目相对路径
|
||||
*/
|
||||
private String contextPath = ConfigListener.map.get("contextPath");
|
||||
private String contextPath = ConfigListener.getConf().get("contextPath");
|
||||
|
||||
/**
|
||||
* 密码允许错误次数
|
||||
|
|
|
|||
|
|
@ -24,27 +24,33 @@ import javax.servlet.ServletContextEvent;
|
|||
import javax.servlet.ServletContextListener;
|
||||
|
||||
import com.smallchill.core.constant.Const;
|
||||
import com.smallchill.core.toolbox.Func;
|
||||
import com.smallchill.core.toolbox.kit.ObjectKit;
|
||||
import com.smallchill.core.toolbox.kit.PropKit;
|
||||
|
||||
public class ConfigListener implements ServletContextListener {
|
||||
|
||||
public static final Map<String, String> map = new HashMap<String, String>();
|
||||
private static Map<String, String> conf = new HashMap<String, String>();
|
||||
|
||||
public static Map<String, String> getConf() {
|
||||
return ObjectKit.clone(conf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent arg0) {
|
||||
map.clear();
|
||||
conf.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent evt) {
|
||||
ServletContext sc = evt.getServletContext();
|
||||
// 项目路径
|
||||
map.put("realPath", sc.getRealPath("/").replaceFirst("/", ""));
|
||||
map.put("contextPath", sc.getContextPath());
|
||||
conf.put("realPath", sc.getRealPath("/").replaceFirst("/", ""));
|
||||
conf.put("contextPath", sc.getContextPath());
|
||||
|
||||
Properties prop = PropKit.use(Const.PROPERTY_FILE).getProperties();
|
||||
for (Object name : prop.keySet()) {
|
||||
map.put(name.toString(), prop.get(name).toString());
|
||||
conf.put(name.toString(), Func.toStr(prop.get(name)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user