use of app.hongs.CoreConfig in project HongsCORE by ihongs.
the class DataCaller method getInstance.
public static DataCaller getInstance() throws HongsException {
String name = DataCaller.class.getName();
DataCaller inst = (DataCaller) Core.GLOBAL_CORE.got(name);
if (inst == null) {
CoreConfig conf = CoreConfig.getInstance("matrix");
inst = new DataCaller(conf.getProperty("core.matrix.data.caller.max.tasks", Integer.MAX_VALUE), conf.getProperty("core.matrix.data.caller.max.servs", 1));
Core.GLOBAL_CORE.put(name, inst);
}
return inst;
}
use of app.hongs.CoreConfig in project HongsCORE by ihongs.
the class ApisAction method init.
@Override
public void init(ServletConfig conf) throws ServletException {
super.init(conf);
CoreConfig cc = CoreConfig.getInstance();
// 请求数据
dataKey = cc.getProperty("core.api.data", ".data");
// 转换策略
convKey = cc.getProperty("core.api.conv", ".conv");
// 包裹数据
wrapKey = cc.getProperty("core.api.wrap", ".wrap");
// 无错误码
scokKey = cc.getProperty("core.api.scok", ".scok");
}
use of app.hongs.CoreConfig in project HongsCORE by ihongs.
the class DB method getInstance.
// ** 构造工厂 **/
/**
* 获取指定数据库对象
* <b>注意:</b>
* <p>
* 会根据当前运行环境自动设置 OBJECT_MODE,TRNSCT_MODE;
* 数据库配置中有指定 dbClass, 请务必添加 getInstance:
* </p>
* <pre>
* public static XxDB getInstance()
* throws HongsException
* {
* return new XxDB();
* }
* </pre>
* @param name
* @return 指定DB对象
* @throws app.hongs.HongsException
*/
public static DB getInstance(String name) throws HongsException {
DB db;
do {
String key = DB.class.getName() + ":" + name;
Core core = Core.THREAD_CORE.get();
if (core.containsKey(key)) {
db = (DB) core.get(key);
break;
}
Core gore = Core.GLOBAL_CORE;
if (gore.containsKey(key)) {
db = (DB) gore.get(key);
break;
}
/**
* 如果存在dbClass描述则调用对应类来获取实例
*/
DBConfig cf = new DBConfig(name);
if (cf.dbClass != null && cf.dbClass.length() != 0) {
db = (DB) Core.getInstance(cf.dbClass);
} else {
db = new DB(cf);
}
/**
* 如有设置dbName的单次加载则将其放入静态映射
*/
CoreConfig conf = Core.getInstance(CoreConfig.class);
if (conf.getProperty("core.load.db." + name + ".once", false)) {
gore.put(key, db);
} else {
core.put(key, db);
}
db.OBJECT_MODE = conf.getProperty("core.in.object.mode", false);
db.TRNSCT_MODE = conf.getProperty("core.in.trnsct.mode", false);
} while (false);
db.OBJECT_MODE = Synt.declare(Core.getInstance().got(Cnst.OBJECT_MODE), db.OBJECT_MODE);
db.TRNSCT_MODE = Synt.declare(Core.getInstance().got(Cnst.TRNSCT_MODE), db.TRNSCT_MODE);
return db;
}
use of app.hongs.CoreConfig in project HongsCORE by ihongs.
the class ActionDriver method init.
/**
* 公共初始化
* @param cont
* @throws ServletException
*/
final synchronized void init(ServletContext cont) throws ServletException {
if (Core.ENVIR != 1) {
Core.ENVIR = 1;
} else {
return;
}
INIT = true;
if (Core.BASE_HREF == null) {
System.setProperty("file.encoding", "UTF-8");
/**
* 核心属性配置 *
*/
Core.DEBUG = Synt.declare(cont.getInitParameter("debug"), (byte) 0);
Core.BASE_HREF = cont.getContextPath();
Core.BASE_PATH = cont.getRealPath("");
Core.BASE_PATH = Core.BASE_PATH.replaceFirst("[/\\\\]$", "");
Core.CORE_PATH = Core.BASE_PATH + File.separator + "WEB-INF";
File cp = new File(Core.CORE_PATH);
if (!cp.exists()) {
Core.CORE_PATH = cp.getParent();
}
Core.CONF_PATH = Core.CORE_PATH + File.separator + "etc";
Core.DATA_PATH = Core.CORE_PATH + File.separator + "var";
// ** 系统属性配置 **/
CoreConfig cnf;
cnf = CoreConfig.getInstance();
Core.SERVER_ID = cnf.getProperty("core.server.id", "0");
Core.ACTION_LANG.set(cnf.getProperty("core.language.default", "zh_CN"));
Core.ACTION_ZONE.set(cnf.getProperty("core.timezone.default", "GMT-8"));
cnf = CoreConfig.getInstance("defines");
// 用于替换下面系统属性中的变量
Map m = new HashMap();
m.put("SERVER_ID", Core.SERVER_ID);
m.put("BASE_PATH", Core.BASE_PATH);
m.put("CORE_PATH", Core.CORE_PATH);
m.put("CONF_PATH", Core.CONF_PATH);
m.put("DATA_PATH", Core.DATA_PATH);
// 启动系统属性
for (Map.Entry et : cnf.entrySet()) {
String k = (String) et.getKey();
String v = (String) et.getValue();
if (k.startsWith("envir.")) {
k = k.substring(6);
v = Tool.inject(v, m);
System.setProperty(k, v);
}
}
if (0 < Core.DEBUG && 8 != (8 & Core.DEBUG)) {
// 调试系统属性
for (Map.Entry et : cnf.entrySet()) {
String k = (String) et.getKey();
String v = (String) et.getValue();
if (k.startsWith("debug.")) {
k = k.substring(6);
v = Tool.inject(v, m);
System.setProperty(k, v);
}
}
}
}
// 调一下 ActionRunner 来加载动作
ActionRunner.getActions();
if (0 < Core.DEBUG && 8 != (8 & Core.DEBUG)) {
CoreLogger.debug(new StringBuilder("...").append("\r\n\tDEBUG : ").append(Core.DEBUG).append("\r\n\tSERVER_ID : ").append(Core.SERVER_ID).append("\r\n\tBASE_HREF : ").append(Core.BASE_HREF).append("\r\n\tBASE_PATH : ").append(Core.BASE_PATH).append("\r\n\tCORE_PATH : ").append(Core.CORE_PATH).append("\r\n\tCONF_PATH : ").append(Core.CONF_PATH).append("\r\n\tDATA_PATH : ").append(Core.DATA_PATH).toString());
}
}
Aggregations