コード例 #1
0
 public static void loadExtendTypeRegConfig(String component) {
   if (SystemUtils.isDebug() || !regLoadeds.contains(component)) {
     if (hasRegConfig(component)) {
       if (readConfig(component)) regLoadeds.add(component);
     }
   }
 }
コード例 #2
0
  private static boolean readConfig(String component) {
    FileSystem fs = FileSystemWrapper.instance();
    String path = fs.getRealPath(component + CONFIG_EXT);
    FileReader fr = null;
    boolean ret = false;
    try {
      fr = new FileReader(new File(path));
      String content = NetUtils.readStreamAsString(fr);
      int start = content.indexOf("{");
      int end = content.lastIndexOf("}");
      if ((start != -1) && (end != -1) && (end > start + 1)) {
        String body = content.substring(start + 1, end);
        if (SystemUtils.isNotEmptyString(body)) {
          start = body.indexOf("[");
          end = body.indexOf("]");
          if ((start != -1) && (end != -1)) {
            String config = body.substring(start, end + 1);
            JSONArray defs = JSONArray.parseArray(config);
            int len = defs.size();
            for (int i = 0; i < len; i++) {
              JSONObject o = defs.getJSONObject(i);
              String name = o.containsKey(STR_NAME) ? o.getString(STR_NAME) : null;
              if (null != name && !"".equals(name)) {
                ExtendTypeDef etd =
                    new ExtendTypeDef(
                        name, o.containsKey(STR_EDITOR) ? o.getString(STR_EDITOR) : null);
                extendTypeDefs.put(name, etd);
              }
            }

            ret = true;
          }
        }
      }
      return ret;
    } catch (Exception e) {
      throw UIException.create(e, UIMessages.READ_COMPONENT_CONFIG_ERROR2, component, path);
    } finally {
      try {
        if (fr != null) fr.close();
      } catch (IOException e) {
      }
    }
  }