update
This commit is contained in:
parent
fd10f6c81a
commit
c49c4cdc4f
|
|
@ -1,23 +1,27 @@
|
||||||
package com.smallchill.core.constant;
|
package com.smallchill.core.constant;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import com.smallchill.core.listener.ConfigListener;
|
import com.smallchill.core.listener.ConfigListener;
|
||||||
|
|
||||||
public interface ConstConfig {
|
public interface ConstConfig {
|
||||||
|
|
||||||
String DBTYPE = ConfigListener.map.get("master.dbType");
|
Map<String, String> pool = ConfigListener.getConf();
|
||||||
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");
|
|
||||||
|
|
||||||
String DOMAIN = ConfigListener.map.get("config.domain");
|
String DBTYPE = pool.get("master.dbType");
|
||||||
String REMOTE_MODE = ConfigListener.map.get("config.remoteMode");
|
String DRIVER = pool.get("master.driver");
|
||||||
String REMOTE_PATH = ConfigListener.map.get("config.remotePath");
|
String URL = pool.get("master.url");
|
||||||
String UPLOAD_PATH = ConfigListener.map.get("config.uploadPath");
|
String USERNAME = pool.get("master.username");
|
||||||
String DOWNLOAD_PATH = ConfigListener.map.get("config.downloadPath");
|
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 = 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 javax.servlet.ServletContextListener;
|
||||||
|
|
||||||
import com.smallchill.core.constant.Const;
|
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;
|
import com.smallchill.core.toolbox.kit.PropKit;
|
||||||
|
|
||||||
public class ConfigListener implements ServletContextListener {
|
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
|
@Override
|
||||||
public void contextDestroyed(ServletContextEvent arg0) {
|
public void contextDestroyed(ServletContextEvent arg0) {
|
||||||
map.clear();
|
conf.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void contextInitialized(ServletContextEvent evt) {
|
public void contextInitialized(ServletContextEvent evt) {
|
||||||
ServletContext sc = evt.getServletContext();
|
ServletContext sc = evt.getServletContext();
|
||||||
// 项目路径
|
// 项目路径
|
||||||
map.put("realPath", sc.getRealPath("/").replaceFirst("/", ""));
|
conf.put("realPath", sc.getRealPath("/").replaceFirst("/", ""));
|
||||||
map.put("contextPath", sc.getContextPath());
|
conf.put("contextPath", sc.getContextPath());
|
||||||
|
|
||||||
Properties prop = PropKit.use(Const.PROPERTY_FILE).getProperties();
|
Properties prop = PropKit.use(Const.PROPERTY_FILE).getProperties();
|
||||||
for (Object name : prop.keySet()) {
|
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