use of app.hongs.HongsException in project HongsCORE by ihongs.
the class JointGate method getForm.
private Map getForm(String mod, String ent) throws HongsException {
String cuf = FormSet.hasConfFile(mod + "/" + ent) ? mod + "/" + ent : mod;
FormSet form = FormSet.getInstance(cuf);
try {
return form.getFormTranslated(ent);
} catch (HongsException ex) {
if (ex.getErrno() == 0x10ea) {
return null;
} else {
throw ex;
}
}
}
use of app.hongs.HongsException in project HongsCORE by ihongs.
the class JoistBean method getSaveTypes.
/**
* 获取字段类型映射
* @return
*/
public Map<String, Set<String>> getSaveTypes() {
if (null != fsavez) {
return fsavez;
}
try {
Map<String, Object> m = FormSet.getInstance().getEnum("__saves__");
fsavez = new HashMap();
for (Map.Entry<String, Object> et : m.entrySet()) {
fsavez.put(et.getKey(), Synt.toSet(et.getValue()));
}
return fsavez;
} catch (HongsException e) {
throw e.toExpedient();
}
}
use of app.hongs.HongsException in project HongsCORE by ihongs.
the class Batch method close.
@Override
public void close() {
if (!servs.isShutdown()) {
servs.shutdownNow();
}
if (back == null) {
if (!tasks.isEmpty()) {
CoreLogger.error("There has " + tasks.size() + " task(s) not run.");
}
return;
}
/**
* 将缓冲区滞留的任务写回 tasks
* 即使重启后 servs 数量改变也没有关系
*/
Collection<T> c = new ArrayList();
for (Collection<T> taskz : cache) {
c.addAll(taskz);
taskz.clear();
}
c.addAll(tasks);
tasks.clear();
tasks.addAll(c);
File file;
file = back;
back = null;
if (!tasks.isEmpty()) {
try {
save(file);
CoreLogger.trace("There has " + tasks.size() + " task(s) not run, save to '" + back.getPath() + "'.");
} catch (HongsException ex) {
CoreLogger.error(ex);
}
} else if (file.exists()) {
file.delete();
}
}
use of app.hongs.HongsException in project HongsCORE by ihongs.
the class ActionRunner method doAction.
/**
* 执行动作方法
* 会执行 action 方法上 annotation 指定的过滤器
* @throws HongsException
*/
public void doAction() throws HongsException {
// 如果超出链长度, 则终止执行
if (idx > annarr.length) {
throw new HongsException(0x110f, "Action annotation out of index: " + idx + ">" + annarr.length);
}
// 如果已到达链尾, 则执行动作
if (idx == annarr.length) {
doInvoke();
return;
}
Filter actw;
Annotation anno = annarr[idx++];
if (anno instanceof Filter) {
actw = (Filter) anno;
} else {
actw = anno.annotationType().getAnnotation(Filter.class);
}
// 如果不是动作链, 则跳过注解
if (actw == null) {
doAction();
return;
}
// 执行注解过滤器
Class<? extends FilterInvoker> classo = actw.value();
FilterInvoker filter = Core.getInstance(classo);
filter.invoke(helper, this, anno);
}
use of app.hongs.HongsException in project HongsCORE by ihongs.
the class FormSet method imports.
@Override
protected void imports() throws HongsException {
InputStream is;
String fn;
try {
fn = Core.CONF_PATH + File.separator + name + Cnst.FORM_EXT + ".xml";
is = new FileInputStream(fn);
} catch (FileNotFoundException ex) {
fn = name.contains(".") || name.contains("/") ? name + Cnst.FORM_EXT + ".xml" : "app/hongs/conf/" + name + Cnst.FORM_EXT + ".xml";
is = this.getClass().getClassLoader().getResourceAsStream(fn);
if (null == is) {
throw new app.hongs.HongsException(0x10e8, "Can not find the config file '" + name + Cnst.FORM_EXT + ".xml'.");
}
}
Element root;
try {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder dbn = dbf.newDocumentBuilder();
Document doc = dbn.parse(is);
root = doc.getDocumentElement();
} catch (IOException ex) {
throw new HongsException(0x10e9, "Read '" + name + Cnst.FORM_EXT + ".xml error'", ex);
} catch (SAXException ex) {
throw new HongsException(0x10e9, "Parse '" + name + Cnst.FORM_EXT + ".xml error'", ex);
} catch (ParserConfigurationException ex) {
throw new HongsException(0x10e9, "Parse '" + name + Cnst.FORM_EXT + ".xml error'", ex);
}
this.forms = new HashMap();
this.enums = new HashMap();
this.parse(root, this.forms, this.enums);
}
Aggregations