use of org.eweb4j.util.xml.XMLWriter in project eweb4j-framework by laiweiwei.
the class DAOConfig method rebuildXmlFile.
private static String rebuildXmlFile(File configFile, String err) {
String error = null;
try {
// 保存为备份文件
File tf = new File(configFile.getAbsolutePath() + ".back" + CommonUtil.getNowTime("_MMddHHmmss"));
FileUtil.copy(configFile, tf);
log.debug("backup file->" + tf.getAbsolutePath());
XMLWriter writer = BeanXMLUtil.getBeanXMLWriter(configFile, DAOConfigBeanCreator.getDAOBean());
writer.setBeanName("dataSource");
writer.setClass("dataSource", DBInfoConfigBean.class);
writer.write();
StringBuilder tsb = new StringBuilder(ConfigInfoCons.REPAIR_CONFIG_FILE);
tsb.append(err);
error = tsb.toString();
log.error(error);
} catch (Exception e1) {
e1.printStackTrace();
StringBuilder sb2 = new StringBuilder(ConfigInfoCons.CANNOT_REPAIR_FILE);
sb2.append(CommonUtil.getExceptionString(e1));
error = sb2.toString();
log.error(error, e1);
}
return error;
}
use of org.eweb4j.util.xml.XMLWriter in project eweb4j-framework by laiweiwei.
the class ORMConfig method rebuildXmlFile.
private static String rebuildXmlFile(File configFile, String err) {
String error;
try {
// 保存为备份文件
File tf = new File(configFile.getAbsolutePath() + ".back" + CommonUtil.getNowTime("_MMddHHmmss"));
FileUtil.copy(configFile, tf);
log.debug("backup file ->" + tf.getAbsolutePath());
XMLWriter writer = BeanXMLUtil.getBeanXMLWriter(configFile, ORMConfigBeanCreator.getORMBean());
writer.setBeanName("orm");
writer.setClass("orm", ORMConfigBean.class);
writer.write();
StringBuilder sb = new StringBuilder(ConfigInfoCons.REPAIR_INFO);
sb.append(err);
error = sb.toString();
log.error(error);
} catch (Throwable e1) {
e1.printStackTrace();
StringBuilder sb3 = new StringBuilder(CommonUtil.getExceptionString(e1));
sb3.append(ConfigInfoCons.CANNOT_REPAIR_CONFIG_FILE);
error = sb3.toString();
log.error(error, e1);
}
return error;
}
use of org.eweb4j.util.xml.XMLWriter in project eweb4j-framework by laiweiwei.
the class DAOConfig method createDBXml.
public static void createDBXml(String path, DBInfoConfigBean db) throws Exception {
XMLWriter writer = BeanXMLUtil.getBeanXMLWriter(new File(ConfigConstant.CONFIG_BASE_PATH() + path), db);
writer.setBeanName("dataSource");
writer.setClass("dataSource", DBInfoConfigBean.class);
writer.write();
}
use of org.eweb4j.util.xml.XMLWriter in project eweb4j-framework by laiweiwei.
the class IOCConfig method createIOCXml.
public static void createIOCXml(String path, List<IOCConfigBean> icbs) throws Exception {
XMLWriter writer = BeanXMLUtil.getBeanXMLWriter(new File(ConfigConstant.CONFIG_BASE_PATH() + path), icbs);
writer.setBeanName("ioc");
writer.setClass("ioc", IOCConfigBean.class);
writer.write();
}
use of org.eweb4j.util.xml.XMLWriter in project eweb4j-framework by laiweiwei.
the class Controller method renderXML.
protected void renderXML(Object obj) {
try {
Class<?> cls = obj.getClass();
XMLWriter writer = BeanXMLUtil.getBeanXMLWriter(obj);
writer.setSubNameAuto(true);
writer.setClass(cls);
writer.setRootElementName(null);
this.context.getResponse().setContentType(MIMEType.XML);
this.context.getWriter().print(writer.toXml());
this.context.getWriter().flush();
} catch (Exception e) {
}
}
Aggregations