Package org.eweb4j.config.bean

Examples of org.eweb4j.config.bean.ConfigBean


    return new LogImpl(logs, "ORM", clazz);
  }

  public static Log getConfigLogger(Class<?> clazz) {
    ConfigBean cb = (ConfigBean) SingleBeanCache.get(ConfigConstant.CONFIGBEAN_ID);

    LogConfigBean log = new LogConfigBean();
    log.setLevel("debug");
    log.setFile(null);
    log.setSize("0");
    LogsConfigBean logs = new LogsConfigBean();
    logs.getLog().add(log);
    if (cb == null)
      return new LogImpl(logs, "CONFIG", clazz);

    String debug = cb.getDebug();
    if ("true".equals(debug) || "1".equals(debug)) {
      return new LogImpl(logs, "CONFIG", clazz);
    } else {
      log.setConsole("0");
      return new LogImpl(logs, "CONFIG", clazz);
View Full Code Here


   
    return this;
  }
 
  public static ConfigBean getConfigBean() {
    ConfigBean configBean = new ConfigBean();
   
    I18N i18n = new I18N();
    Locale locale = new Locale();
    locale.setLanguage(java.util.Locale.CHINA.getLanguage());
    locale.setCountry(java.util.Locale.CHINA.getCountry());
    i18n.getLocale().add(locale);
    configBean.setLocales(i18n);
   
    Properties props = new Properties();
    Prop file = new Prop();
    props.getFile().add(file);
    configBean.setProperties(props);
   
    ConfigIOC ioc = new ConfigIOC();
    IOCXmlFiles iocXmlFiles = new IOCXmlFiles();
    iocXmlFiles.setPath(new ArrayList<String>());
    ioc.setIocXmlFiles(iocXmlFiles);
    configBean.setIoc(ioc);

    ConfigORM orm = new ConfigORM();
    ORMXmlFiles ormXmlFiles = new ORMXmlFiles();
    orm.setOrmXmlFiles(ormXmlFiles);
    ScanPojoPackage spp = new ScanPojoPackage();
    orm.setScanPojoPackage(spp);

    DBInfoXmlFiles dbInfoXmlFiles = new DBInfoXmlFiles();
    dbInfoXmlFiles.setPath(new ArrayList<String>());
    orm.setDbInfoXmlFiles(dbInfoXmlFiles);

    configBean.setOrm(orm);

    ConfigMVC mvc = new ConfigMVC();
    UploadConfigBean upload = new UploadConfigBean();
    mvc.setUpload(upload);
   
    ActionXmlFile actionFiles = new ActionXmlFile();
    actionFiles.setPath(new ArrayList<String>());
    mvc.setActionXmlFiles(actionFiles);
   
    InterXmlFile intFiles = new InterXmlFile();
    intFiles.setPath(new ArrayList<String>());
    mvc.setInterXmlFiles(intFiles);
   
    ScanActionPackage sap = new ScanActionPackage();
    sap.setPath(new ArrayList<String>());
    mvc.setScanActionPackage(sap);
   
    configBean.setMvc(mvc);

    return configBean;
  }
View Full Code Here

    String error = null;
    File file = null;
    boolean readXml = true;
    if (ConfigConstant.SUCCESS_START.equals(String.valueOf(SingleBeanCache
        .get(ConfigConstant.SUCCESS_START)))) {
      ConfigBean cb = (ConfigBean) SingleBeanCache
          .get(ConfigConstant.CONFIGBEAN_ID);

      String debug = (cb == null ? "true" : cb.getReload());
      if ("true".equals(debug) || "1".equals(debug)) {
        // 如果开了DEBUG,清空缓存,重新读取配置文件
        SingleBeanCache.clear();
        ORMConfigBeanCache.clear();
        IOCConfigBeanCache.clear();
        ActionConfigBeanCache.clear();
        System.out.println("EWeb4J清空缓存");
        readXml = true;
      } else {
        // 否则,不需要读取配置文件
        readXml = false;
      }
    }

    if (readXml) {
      // 1.读取配置文件
      try {
        file = new File(startXmlPath);
        XMLReader reader = BeanXMLUtil.getBeanXMLReader(file);
        reader.setBeanName("eweb4j");
        reader.setClass("eweb4j", ConfigBean.class);
        ConfigBean cb = reader.readOne();
        if (cb == null) {
          error = "EWeb4JConfig.class : 读取不了任何配置文件信息!已经重写了配置文件,请重新填写完整,然后启动框架。";
        } else {

          StringBuilder infos = new StringBuilder(
              "EWeb4JConfig.start \n");
          infos.append("start-config-xml-path --> ")
              .append(ConfigConstant.START_FILE_PATH())
              .append("\n");
          infos.append("${RootPath} --> ")
              .append(ConfigConstant.ROOT_PATH).append("\n");
          infos.append(cb).append("\n");

          LogFactory.getConfigLogger("INFO").write(infos.toString());

          // 检查配置信息格式是否填写正确
          String error1 = CheckConfigBean.checkEWeb4JConfigBean(cb);
          if (error1 != null)
            error = error1;

          String error2 = CheckConfigBean.checkEWeb4JIOCPart(cb
              .getIoc());
          if (error2 != null)
            if (error == null)
              error = error2;
            else
              error += error2;

          String error3 = CheckConfigBean.checkIOCXml(cb.getIoc()
              .getIocXmlFiles());
          if (error3 != null)
            if (error == null)
              error = error3;
            else
              error += error3;

          String error4 = CheckConfigBean.checkEWeb4JORMPart(cb
              .getOrm());
          if (error4 != null)
            if (error == null)
              error = error4;
            else
              error += error4;

          String error5 = CheckConfigBean.checkORMXml(cb.getOrm()
              .getOrmXmlFiles());
          if (error5 != null)
            if (error == null)
              error = error5;
            else
              error += error5;

          String error6 = CheckConfigBean.checkEWeb4JMVCPart(cb
              .getMvc());
          if (error6 != null)
            if (error == null)
              error = error6;
            else
              error += error6;

          String error7 = CheckConfigBean.checkMVCActionXmlFile(cb
              .getMvc().getActionXmlFiles());
          if (error7 != null)
            if (error == null)
              error = error7;
            else
              error += error7;

          String error8 = CheckConfigBean.checkInter(cb.getMvc()
              .getInterXmlFiles());
          if (error8 != null)
            if (error == null)
              error = error8;
            else
              error += error8;

          if (error == null) {
            // 验证通过,将读取到的信息放入缓存池中
            SingleBeanCache.add(ConfigConstant.CONFIGBEAN_ID, cb);
            SingleBeanCache.add(cb.getClass(), cb);
            // ------log-------
            String info = "EWeb4J框架启动配置文件验证通过,已将读取到的配置信息存入缓存;";
            LogFactory.getConfigLogger("INFO").write(info);
            // ------log-------
            // 继续验证其他组件配置信息

            // properties
            String error13 = null;
            try {
              for (org.eweb4j.config.bean.Prop f : cb
                  .getProperties().getFile()) {
                error13 = Props.readProperties(f, true);
                if (error13 != null)
                  if (error == null)
                    error = error13;
                  else
                    error += error13;
              }
            } catch (Exception e) {
              LogFactory.getIOCLogger("warring").write(
                  e.toString());
              if (error == null)
                error = e.toString();
              else
                error += e.toString();
            }

            if ("true".equals(cb.getIoc().getOpen())
                || "1".equals(cb.getIoc().getOpen())) {
              String error10 = IOCConfig.check();
              if (error10 != null)
                if (error == null)
                  error = error10;
                else
                  error += error10;
            }
            if ("true".equals(cb.getOrm().getOpen())
                || "1".equals(cb.getOrm().getOpen())) {
              String error14 = DAOConfig.check();
              if (error14 != null)
                if (error == null)
                  error = error14;
                else
                  error += error14;

              String error10 = PojoAnnotationConfig
                  .readAnnotation(cb.getOrm()
                      .getScanPojoPackage().getPath());
              if (error10 != null)
                if (error == null)
                  error = error10;
                else
                  error += error10;

              String error11 = ORMConfig.check();
              if (error11 != null)
                if (error == null)
                  error = error11;
                else
                  error += error11;

            }
            if ("true".equals(cb.getMvc().getOpen())
                || "1".equals(cb.getMvc().getOpen())) {
              String error20 = ActionAnnotationConfig
                  .readAnnotation(cb.getMvc()
                      .getScanActionPackage().getPath());
              if (error20 != null)
                if (error == null)
                  error = error20;
                else
View Full Code Here

    return error;
  }

  public static boolean isIocDebug() {
    ConfigBean cb = (ConfigBean) SingleBeanCache
        .get(ConfigConstant.CONFIGBEAN_ID);
    String debug = (cb == null ? "true" : cb.getIoc().getDebug());

    if ("1".equals(debug) || "true".equals(debug))
      return true;
    else
      return false;
View Full Code Here

    String startXmlPath = aStartXmlPath;
    String error = null;
    File file = null;
    boolean readXml = true;
    if (ConfigConstant.SUCCESS_START.equals(String.valueOf(SingleBeanCache.get(ConfigConstant.SUCCESS_START)))) {
      ConfigBean cb = (ConfigBean) SingleBeanCache.get(ConfigConstant.CONFIGBEAN_ID);

      String reload = (cb == null ? "true" : cb.getReload());
      if ("true".equals(reload) || "1".equals(reload)) {
        // 如果开了DEBUG,清空缓存,重新读取配置文件
        SingleBeanCache.clear();
        ORMConfigBeanCache.clear();
        IOCConfigBeanCache.clear();
        ActionConfigBeanCache.clear();
        log.debug("EWeb4J clear cache");
        readXml = true;
      } else {
        // 否则,不需要读取配置文件
        readXml = false;
      }
    }

    if (readXml) {
      // 1.读取配置文件
      try {
        file = new File(startXmlPath);
        XMLReader reader = BeanXMLUtil.getBeanXMLReader(file);
        reader.setBeanName("eweb4j");
        reader.setClass("eweb4j", ConfigBean.class);
        ConfigBean cb = reader.readOne();
        if (cb == null) {
          error = " can not read any configuration info! But now have bean repaired, please restart.";
        } else {

          StringBuilder infos = new StringBuilder("EWeb4JConfig.start \n");
          infos.append("start-config-xml-path --> ").append(ConfigConstant.START_FILE_PATH()).append("\n");
          infos.append("${RootPath} --> ").append(ConfigConstant.ROOT_PATH).append("\n");
          infos.append(cb).append("\n");

          log.debug(infos.toString());

          // 检查配置信息格式是否填写正确
          String error1 = CheckConfigBean.checkEWeb4JConfigBean(cb);
          if (error1 != null)
            error = error1;

          String error2 = CheckConfigBean.checkEWeb4JIOCPart(cb.getIoc());
          if (error2 != null)
            if (error == null)
              error = error2;
            else
              error += error2;

          String error3 = CheckConfigBean.checkIOCXml(cb.getIoc().getIocXmlFiles());
          if (error3 != null)
            if (error == null)
              error = error3;
            else
              error += error3;

          String error4 = CheckConfigBean.checkEWeb4JORMPart(cb.getOrm());
          if (error4 != null)
            if (error == null)
              error = error4;
            else
              error += error4;

          String error5 = CheckConfigBean.checkORMXml(cb.getOrm().getOrmXmlFiles());
          if (error5 != null)
            if (error == null)
              error = error5;
            else
              error += error5;

          String error6 = CheckConfigBean.checkEWeb4JMVCPart(cb.getMvc());
          if (error6 != null)
            if (error == null)
              error = error6;
            else
              error += error6;

          String error7 = CheckConfigBean.checkMVCActionXmlFile(cb.getMvc().getActionXmlFiles());
          if (error7 != null)
            if (error == null)
              error = error7;
            else
              error += error7;

          String error8 = CheckConfigBean.checkInter(cb.getMvc().getInterXmlFiles());
          if (error8 != null)
            if (error == null)
              error = error8;
            else
              error += error8;

          if (error == null) {
            // 验证通过,将读取到的信息放入缓存池中
            SingleBeanCache.add(ConfigConstant.CONFIGBEAN_ID, cb);
            SingleBeanCache.add(cb.getClass(), cb);
            // ------log-------
            String info = "EWeb4J start configuration info have bean validated and pushed to the cache. ";
            log.debug(info);
            // ------log-------
            // 继续验证其他组件配置信息

            // properties
            String error13 = null;
            try {
              for (org.eweb4j.config.bean.Prop f : cb.getProperties().getFile()) {
                error13 = Props.readProperties(f, true);
                if (error13 != null)
                  if (error == null)
                    error = error13;
                  else
                    error += error13;
              }
            } catch (Exception e) {
              log.warn(e.toString());
              if (error == null)
                error = e.toString();
              else
                error += e.toString();
            }

            if ("true".equals(cb.getIoc().getOpen()) || "1".equals(cb.getIoc().getOpen())) {
              String error10 = IOCConfig.check();
              if (error10 != null)
                if (error == null)
                  error = error10;
                else
                  error += error10;
            }
            if ("true".equals(cb.getOrm().getOpen()) || "1".equals(cb.getOrm().getOpen())) {
              String error14 = DAOConfig.check();
              if (error14 != null)
                if (error == null)
                  error = error14;
                else
                  error += error14;

              String error10 = new PojoAnnotationConfig().readAnnotation(cb.getOrm().getScanPojoPackage().getPath());
              if (error10 != null)
                if (error == null)
                  error = error10;
                else
                  error += error10;

              String error11 = ORMConfig.check();
              if (error11 != null)
                if (error == null)
                  error = error11;
                else
                  error += error11;

            }
            if ("true".equals(cb.getMvc().getOpen()) || "1".equals(cb.getMvc().getOpen())) {
              String error20 = new ActionAnnotationConfig().readAnnotation(cb.getMvc().getScanActionPackage().getPath());
              if (error20 != null)
                if (error == null)
                  error = error20;
                else
                  error += error20;

              String error11 = ActionConfig.check();
              if (error11 != null)
                if (error == null)
                  error = error11;
                else
                  error += error11;

              String error12 = new InterceptorAnnotationConfig().readAnnotation(cb.getMvc().getScanInterceptorPackage().getPath());
              if (error12 == null)
                error = error12;
              else
                error += error12;
             
View Full Code Here

  private static Log log = LogFactory.getORMLogger(DAOConfig.class);

  public synchronized static String check() {
    String error = null;
    ConfigBean cb = (ConfigBean) SingleBeanCache.get(ConfigConstant.CONFIGBEAN_ID);
    if (cb == null)
      return null;

    DBInfoXmlFiles dbInfoXmlFiles = cb.getOrm().getDbInfoXmlFiles();
    if (dbInfoXmlFiles == null)
      return ConfigInfoCons.CANNOT_READ_CONFIG_FILE;

    for (String filePath : dbInfoXmlFiles.getPath()) {
      if (filePath == null || filePath.length() == 0)
View Full Code Here

  private static Log log = LogFactory.getIOCLogger(IOCConfig.class);

  public synchronized static String check() {
    String error = null;
    ConfigBean cb = (ConfigBean) SingleBeanCache.get(ConfigConstant.CONFIGBEAN_ID);
    if (cb == null)
      return null;

    List<String> iocXmlFilePaths = cb.getIoc().getIocXmlFiles().getPath();
    for (String filePath : iocXmlFilePaths) {
      if (filePath == null || filePath.length() == 0)
        continue;

      File configFile = new File(ConfigConstant.CONFIG_BASE_PATH+ filePath);
View Full Code Here

TOP

Related Classes of org.eweb4j.config.bean.ConfigBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.