Search in sources :

Example 6 with XMLWriter

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;
}
Also used : File(java.io.File) XMLWriter(org.eweb4j.util.xml.XMLWriter)

Example 7 with XMLWriter

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;
}
Also used : File(java.io.File) XMLWriter(org.eweb4j.util.xml.XMLWriter)

Example 8 with XMLWriter

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();
}
Also used : XMLWriter(org.eweb4j.util.xml.XMLWriter) File(java.io.File)

Example 9 with XMLWriter

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();
}
Also used : XMLWriter(org.eweb4j.util.xml.XMLWriter) File(java.io.File)

Example 10 with XMLWriter

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) {
    }
}
Also used : XMLWriter(org.eweb4j.util.xml.XMLWriter) IOException(java.io.IOException)

Aggregations

XMLWriter (org.eweb4j.util.xml.XMLWriter)11 File (java.io.File)10 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 ZipEntry (java.util.zip.ZipEntry)1 ZipOutputStream (java.util.zip.ZipOutputStream)1 ServletOutputStream (javax.servlet.ServletOutputStream)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 ConfigBean (org.eweb4j.config.bean.ConfigBean)1 CookieProxy (org.eweb4j.mvc.CookieProxy)1 HttpSessionProxy (org.eweb4j.mvc.HttpSessionProxy)1 ServletContextProxy (org.eweb4j.mvc.ServletContextProxy)1 ResultConfigBean (org.eweb4j.mvc.config.bean.ResultConfigBean)1 UploadFile (org.eweb4j.mvc.upload.UploadFile)1 JSPRendererImpl (org.eweb4j.mvc.view.JSPRendererImpl)1