Search in sources :

Example 6 with XMLReader

use of org.eweb4j.util.xml.XMLReader in project eweb4j-framework by laiweiwei.

the class ORMConfig method check.

public static synchronized String check() {
    String error = null;
    ConfigBean cb = (ConfigBean) SingleBeanCache.get(ConfigBean.class.getName());
    if (cb == null)
        return null;
    List<String> ormXmlFilePaths = cb.getOrm().getOrmXmlFiles().getPath();
    for (String filePath : ormXmlFilePaths) {
        if (filePath == null || filePath.length() == 0)
            continue;
        File configFile = new File(ConfigConstant.CONFIG_BASE_PATH + filePath);
        try {
            XMLReader reader = BeanXMLUtil.getBeanXMLReader(configFile);
            reader.setBeanName("orm");
            reader.setClass("orm", ORMConfigBean.class);
            List<ORMConfigBean> ormList = reader.read();
            if (ormList == null || ormList.isEmpty()) {
                error = rebuildXmlFile(configFile, ConfigInfoCons.CANNOT_READ_ANY_CONFIG_INFO);
            } else {
                for (ORMConfigBean orm : ormList) {
                    String error1 = CheckConfigBean.checkORM(orm, filePath);
                    if (error1 != null)
                        if (error == null)
                            error = error1;
                        else
                            error += error1;
                    String error2 = CheckConfigBean.checkORMProperty(orm.getProperty(), ormList, orm.getId(), filePath);
                    if (error2 != null)
                        if (error == null)
                            error = error2;
                        else
                            error += error2;
                }
                if (error == null) {
                    for (ORMConfigBean orm : ormList) {
                        if (!"".equals(orm.getClazz()))
                            ORMConfigBeanCache.add(orm.getClazz(), orm);
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            error = rebuildXmlFile(configFile, CommonUtil.getExceptionString(e));
        }
    }
    if (error != null)
        ORMConfigBeanCache.clear();
    else
        log.debug(ConfigInfoCons.READ_CONFIG_INFO_SUCCESS);
    return error;
}
Also used : ORMConfigBean(org.eweb4j.orm.config.bean.ORMConfigBean) CheckConfigBean(org.eweb4j.config.CheckConfigBean) ORMConfigBean(org.eweb4j.orm.config.bean.ORMConfigBean) ConfigBean(org.eweb4j.config.bean.ConfigBean) File(java.io.File) XMLReader(org.eweb4j.util.xml.XMLReader)

Aggregations

File (java.io.File)6 ConfigBean (org.eweb4j.config.bean.ConfigBean)6 XMLReader (org.eweb4j.util.xml.XMLReader)6 CheckConfigBean (org.eweb4j.config.CheckConfigBean)5 DBInfoConfigBean (org.eweb4j.orm.dao.config.bean.DBInfoConfigBean)2 Iterator (java.util.Iterator)1 DBInfoXmlFiles (org.eweb4j.config.bean.DBInfoXmlFiles)1 IOCConfigBean (org.eweb4j.ioc.config.bean.IOCConfigBean)1 ActionConfigBean (org.eweb4j.mvc.config.bean.ActionConfigBean)1 InterConfigBean (org.eweb4j.mvc.config.bean.InterConfigBean)1 ORMConfigBean (org.eweb4j.orm.config.bean.ORMConfigBean)1 DataSourceWrap (org.eweb4j.orm.jdbc.DataSourceWrap)1 XMLWriter (org.eweb4j.util.xml.XMLWriter)1